@@ -198,7 +198,7 @@ static void EnableAvailableFeatures()
198198 glConfig.usingGeometryCache = glConfig.usingMaterialSystem && glConfig.geometryCacheAvailable ;
199199}
200200
201- // For shaders that require map data for compile-time values
201+ // For shaders that require map data for compile-time values
202202void GLSL_InitWorldShaders () {
203203 // make sure the render thread is stopped
204204 R_SyncRenderThread ();
@@ -256,11 +256,6 @@ static void GLSL_InitGPUShadersOrError()
256256 gl_depthReductionShader->MarkProgramForBuilding ();
257257 }
258258
259- if ( tr.world ) // this only happens with /glsl_restart
260- {
261- GLSL_InitWorldShaders ();
262- }
263-
264259 if ( glConfig.realtimeLighting )
265260 {
266261 gl_shaderManager.LoadShader ( gl_depthtile1Shader );
@@ -344,7 +339,7 @@ static void GLSL_InitGPUShadersOrError()
344339
345340 gl_contrastShader->MarkProgramForBuilding ();
346341 }
347-
342+
348343 // portal process effect
349344 gl_shaderManager.LoadShader ( gl_portalShader );
350345
@@ -397,6 +392,12 @@ static void GLSL_InitGPUShadersOrError()
397392 gl_shaderManager.PostProcessGlobalUniforms ();
398393 gl_shaderManager.InitShaders ();
399394
395+ // Init world shaders last so that everyhthing is already initialized.
396+ if ( tr.world ) // this only happens with /glsl_restart
397+ {
398+ GLSL_InitWorldShaders ();
399+ }
400+
400401 if ( r_lazyShaders.Get () == 0 )
401402 {
402403 gl_shaderManager.BuildAll ( false );
@@ -1481,7 +1482,7 @@ void Render_heatHaze( shaderStage_t *pStage )
14811482
14821483 // bind u_NormalMap
14831484 gl_heatHazeShader->SetUniform_NormalMapBindless (
1484- GL_BindToTMU ( 0 , pStage->bundle [TB_NORMALMAP].image [0 ] )
1485+ GL_BindToTMU ( 0 , pStage->bundle [TB_NORMALMAP].image [0 ] )
14851486 );
14861487
14871488 if ( pStage->enableNormalMapping )
@@ -1497,7 +1498,7 @@ void Render_heatHaze( shaderStage_t *pStage )
14971498
14981499 // bind u_CurrentMap
14991500 gl_heatHazeShader->SetUniform_CurrentMapBindless (
1500- GL_BindToTMU ( 1 , tr.currentRenderImage [backEnd.currentMainFBO ] )
1501+ GL_BindToTMU ( 1 , tr.currentRenderImage [backEnd.currentMainFBO ] )
15011502 );
15021503
15031504 gl_heatHazeShader->SetRequiredVertexPointers ();
@@ -1507,7 +1508,7 @@ void Render_heatHaze( shaderStage_t *pStage )
15071508 // copy to foreground image
15081509 R_BindFBO ( tr.mainFBO [ backEnd.currentMainFBO ] );
15091510 gl_heatHazeShader->SetUniform_CurrentMapBindless (
1510- GL_BindToTMU ( 1 , tr.currentRenderImage [1 - backEnd.currentMainFBO ] )
1511+ GL_BindToTMU ( 1 , tr.currentRenderImage [1 - backEnd.currentMainFBO ] )
15111512 );
15121513 gl_heatHazeShader->SetUniform_DeformMagnitude ( 0 .0f );
15131514 Tess_DrawElements ();
0 commit comments