File tree Expand file tree Collapse file tree 4 files changed +9
-18
lines changed Expand file tree Collapse file tree 4 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -2639,7 +2639,8 @@ GLShader_fogGlobal::GLShader_fogGlobal() :
26392639 u_UnprojectMatrix( this ),
26402640 u_Color_Float( this ),
26412641 u_Color_Uint( this ),
2642- u_FogDistanceVector( this )
2642+ u_ViewOrigin( this ),
2643+ u_FogDensity( this )
26432644{
26442645}
26452646
Original file line number Diff line number Diff line change @@ -3481,7 +3481,8 @@ class GLShader_fogGlobal :
34813481 public u_UnprojectMatrix,
34823482 public u_Color_Float,
34833483 public u_Color_Uint,
3484- public u_FogDistanceVector
3484+ public u_ViewOrigin,
3485+ public u_FogDensity
34853486{
34863487public:
34873488 GLShader_fogGlobal ();
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ uniform sampler2D u_DepthMap;
2929
3030uniform colorPack u_Color;
3131
32- uniform vec4 u_FogDistanceVector;
32+ uniform vec3 u_ViewOrigin;
33+ uniform float u_FogDensity;
3334uniform mat4 u_UnprojectMatrix;
3435
3536DECLARE_OUTPUT(vec4 )
@@ -45,7 +46,7 @@ void main()
4546 P.xyz /= P.w;
4647
4748 // calculate the length in fog (t is always 1 if eye is in fog)
48- st.s = dot (P.xyz, u_FogDistanceVector .xyz) + u_FogDistanceVector.w ;
49+ st.s = distance (u_ViewOrigin, P .xyz) * u_FogDensity ;
4950 st.t = 1.0 ;
5051
5152 vec4 color = texture2D (u_ColorMap, st);
Original file line number Diff line number Diff line change @@ -1377,20 +1377,8 @@ void RB_RenderGlobalFog()
13771377
13781378 GL_State ( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
13791379
1380- // all fogging distance is based on world Z units
1381- vec4_t fogDistanceVector;
1382- vec3_t local;
1383- VectorSubtract ( backEnd.orientation .origin , backEnd.viewParms .orientation .origin , local );
1384- fogDistanceVector[ 0 ] = -backEnd.orientation .modelViewMatrix [ 2 ];
1385- fogDistanceVector[ 1 ] = -backEnd.orientation .modelViewMatrix [ 6 ];
1386- fogDistanceVector[ 2 ] = -backEnd.orientation .modelViewMatrix [ 10 ];
1387- fogDistanceVector[ 3 ] = DotProduct ( local, backEnd.viewParms .orientation .axis [ 0 ] );
1388-
1389- // scale the fog vectors based on the fog's thickness
1390- VectorScale ( fogDistanceVector, fog->tcScale , fogDistanceVector );
1391- fogDistanceVector[ 3 ] *= fog->tcScale ;
1392-
1393- gl_fogGlobalShader->SetUniform_FogDistanceVector ( fogDistanceVector );
1380+ gl_fogGlobalShader->SetUniform_FogDensity ( fog->tcScale );
1381+ gl_fogGlobalShader->SetUniform_ViewOrigin ( backEnd.viewParms .orientation .origin );
13941382 SetUniform_Color ( gl_fogGlobalShader, fog->color );
13951383 }
13961384
You can’t perform that action at this time.
0 commit comments