diff --git a/changelog.txt b/changelog.txt index 1fa9a40..8f48b43 100644 --- a/changelog.txt +++ b/changelog.txt @@ -29,6 +29,8 @@ chg: with r_backend GL3, depth fade with MSAA now requires GLSL 4.00 at a minimu chg: with r_backend GL3, alpha to coverage now requires GLSL 4.00 at a minimum +fix: with r_lightmap 1 and r_dynamiclight 1, lighting transparent surfaces could crash + fix: r_vertexLight 1 no longer applies to non-lightmapped surfaces fix: delayed shader loads could lead to incorrect rendering and crashes (mostly with dynamic lights) diff --git a/code/renderer/tr_shader.cpp b/code/renderer/tr_shader.cpp index d06a445..05c0e7d 100644 --- a/code/renderer/tr_shader.cpp +++ b/code/renderer/tr_shader.cpp @@ -2339,7 +2339,6 @@ static shader_t* FinishShader() stages[0].mtStages = 0; shader.lightingStages[ST_DIFFUSE] = 0; // for working dynamic lights shader.lightingStages[ST_LIGHTMAP] = 0; - shader.numStages = 1; } } else if ( r_lightmap->integer ) { // now we deal with r_lightmap on a non-opaque shader @@ -2367,6 +2366,9 @@ static shader_t* FinishShader() for ( int i = 2; i < shader.numStages; ++i ) { stages[i].active = qfalse; } + + shader.lightingStages[ST_DIFFUSE] = 0; // for working dynamic lights + shader.lightingStages[ST_LIGHTMAP] = 0; } } } diff --git a/code/renderer/tr_world.cpp b/code/renderer/tr_world.cpp index d09f824..df9df6c 100644 --- a/code/renderer/tr_world.cpp +++ b/code/renderer/tr_world.cpp @@ -345,7 +345,7 @@ static void R_AddLitSurface( msurface_t* surf, const dlight_t* light ) return; // already in the lit list (or already culled) for this light const int stageIndex = surf->shader->lightingStages[ST_DIFFUSE]; - if ( stageIndex < 0 ) + if ( stageIndex < 0 || stageIndex >= surf->shader->numStages ) return; const shaderStage_t* const stage = surf->shader->stages[stageIndex];