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() :
2639
2639
u_UnprojectMatrix( this ),
2640
2640
u_Color_Float( this ),
2641
2641
u_Color_Uint( this ),
2642
- u_FogDistanceVector( this )
2642
+ u_ViewOrigin( this ),
2643
+ u_FogDensity( this )
2643
2644
{
2644
2645
}
2645
2646
Original file line number Diff line number Diff line change @@ -3481,7 +3481,8 @@ class GLShader_fogGlobal :
3481
3481
public u_UnprojectMatrix,
3482
3482
public u_Color_Float,
3483
3483
public u_Color_Uint,
3484
- public u_FogDistanceVector
3484
+ public u_ViewOrigin,
3485
+ public u_FogDensity
3485
3486
{
3486
3487
public:
3487
3488
GLShader_fogGlobal ();
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ uniform sampler2D u_DepthMap;
29
29
30
30
uniform colorPack u_Color;
31
31
32
- uniform vec4 u_FogDistanceVector;
32
+ uniform vec3 u_ViewOrigin;
33
+ uniform float u_FogDensity;
33
34
uniform mat4 u_UnprojectMatrix;
34
35
35
36
DECLARE_OUTPUT(vec4 )
@@ -45,7 +46,7 @@ void main()
45
46
P.xyz /= P.w;
46
47
47
48
// 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 ;
49
50
st.t = 1.0 ;
50
51
51
52
vec4 color = texture2D (u_ColorMap, st);
Original file line number Diff line number Diff line change @@ -1377,20 +1377,8 @@ void RB_RenderGlobalFog()
1377
1377
1378
1378
GL_State ( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
1379
1379
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 );
1394
1382
SetUniform_Color ( gl_fogGlobalShader, fog->color );
1395
1383
}
1396
1384
You can’t perform that action at this time.
0 commit comments