@@ -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 );
@@ -331,7 +326,7 @@ static void GLSL_InitGPUShadersOrError()
331326
332327 gl_contrastShader->MarkProgramForBuilding ();
333328 }
334-
329+
335330 // portal process effect
336331 gl_shaderManager.LoadShader ( gl_portalShader );
337332
@@ -384,6 +379,12 @@ static void GLSL_InitGPUShadersOrError()
384379 gl_shaderManager.PostProcessGlobalUniforms ();
385380 gl_shaderManager.InitShaders ();
386381
382+ // Init world shaders last so that everyhthing is already initialized.
383+ if ( tr.world ) // this only happens with /glsl_restart
384+ {
385+ GLSL_InitWorldShaders ();
386+ }
387+
387388 if ( r_lazyShaders.Get () == 0 )
388389 {
389390 gl_shaderManager.BuildAll ( false );
@@ -1447,7 +1448,7 @@ void Render_heatHaze( shaderStage_t *pStage )
14471448
14481449 // bind u_NormalMap
14491450 gl_heatHazeShader->SetUniform_NormalMapBindless (
1450- GL_BindToTMU ( 0 , pStage->bundle [TB_NORMALMAP].image [0 ] )
1451+ GL_BindToTMU ( 0 , pStage->bundle [TB_NORMALMAP].image [0 ] )
14511452 );
14521453
14531454 if ( pStage->enableNormalMapping )
@@ -1463,7 +1464,7 @@ void Render_heatHaze( shaderStage_t *pStage )
14631464
14641465 // bind u_CurrentMap
14651466 gl_heatHazeShader->SetUniform_CurrentMapBindless (
1466- GL_BindToTMU ( 1 , tr.currentRenderImage [backEnd.currentMainFBO ] )
1467+ GL_BindToTMU ( 1 , tr.currentRenderImage [backEnd.currentMainFBO ] )
14671468 );
14681469
14691470 gl_heatHazeShader->SetRequiredVertexPointers ();
@@ -1473,7 +1474,7 @@ void Render_heatHaze( shaderStage_t *pStage )
14731474 // copy to foreground image
14741475 R_BindFBO ( tr.mainFBO [ backEnd.currentMainFBO ] );
14751476 gl_heatHazeShader->SetUniform_CurrentMapBindless (
1476- GL_BindToTMU ( 1 , tr.currentRenderImage [1 - backEnd.currentMainFBO ] )
1477+ GL_BindToTMU ( 1 , tr.currentRenderImage [1 - backEnd.currentMainFBO ] )
14771478 );
14781479 gl_heatHazeShader->SetUniform_DeformMagnitude ( 0 .0f );
14791480 Tess_DrawElements ();
0 commit comments