From 616e77dc6173924688965e57170c4c6101697310 Mon Sep 17 00:00:00 2001 From: temx Date: Tue, 1 Nov 2022 19:12:05 +0100 Subject: [PATCH] Allow mixing lit and unlit textures in the same map --- Quake/r_world.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Quake/r_world.c b/Quake/r_world.c index 1953d6eb..eabb285f 100644 --- a/Quake/r_world.c +++ b/Quake/r_world.c @@ -573,10 +573,15 @@ void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain qboolean bound; float entalpha; int lastlightmap; + qboolean has_lit_water; + qboolean has_unlit_water; if (r_drawflat_cheatsafe || r_lightmap_cheatsafe) // ericw -- !r_drawworld_cheatsafe check moved to R_DrawWorld_Water () return; + has_lit_water = false; + has_unlit_water = false; + if (r_oldwater.value) { for (i=0 ; inumtextures ; i++) @@ -606,6 +611,8 @@ void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain } else if (cl.worldmodel->haslitwater && r_litwater.value && r_world_program != 0) { + has_lit_water = true; + GL_UseProgramFunc (r_world_program); // Bind the buffers @@ -635,6 +642,12 @@ void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain if (!t || !t->texturechains[chain] || !(t->texturechains[chain]->flags & SURF_DRAWTURB)) continue; + if (t->texturechains[chain]->texinfo->flags & TEX_SPECIAL) + { + has_unlit_water = true; + continue; + } + bound = false; entalpha = 1.0f; lastlightmap = 0; @@ -686,6 +699,9 @@ void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain GL_SelectTexture (GL_TEXTURE0); } else + has_unlit_water = true; + + if (has_unlit_water) { // Unlit water for (i=0 ; inumtextures ; i++) @@ -693,6 +709,8 @@ void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain t = model->textures[i]; if (!t || !t->texturechains[chain] || !(t->texturechains[chain]->flags & SURF_DRAWTURB)) continue; + if (has_lit_water && !(t->texturechains[chain]->texinfo->flags & TEX_SPECIAL)) + continue; bound = false; entalpha = 1.0f; for (s = t->texturechains[chain]; s; s = s->texturechain)