mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-09 01:01:07 +00:00
GLWorld_CreateShaders: do fog fully in the fragment shader.
Fixes a regression introduced in 0.93.0 when we switched from fixed-function fog to GLSL (for world polys), reported by ItEndsWithTens It was visible on large polygons. For a test case, see: https://sourceforge.net/p/quakespasm/bugs/24/ git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1544 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
da83b3b018
commit
c227b42c51
1 changed files with 11 additions and 4 deletions
|
@ -832,14 +832,14 @@ void GLWorld_CreateShaders (void)
|
|||
"attribute vec2 TexCoords;\n"
|
||||
"attribute vec2 LMCoords;\n"
|
||||
"\n"
|
||||
"varying vec3 VertVarying;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_TexCoord[0] = vec4(TexCoords, 0.0, 0.0);\n"
|
||||
" gl_TexCoord[1] = vec4(LMCoords, 0.0, 0.0);\n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * vec4(Vert, 1.0);\n"
|
||||
" // fog\n"
|
||||
" vec3 ecPosition = vec3(gl_ModelViewMatrix * vec4(Vert, 1.0));\n"
|
||||
" gl_FogFragCoord = abs(ecPosition.z);\n"
|
||||
" VertVarying = Vert;\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar *fragSource = \
|
||||
|
@ -852,6 +852,9 @@ void GLWorld_CreateShaders (void)
|
|||
"uniform bool UseOverbright;\n"
|
||||
"uniform bool UseAlphaTest;\n"
|
||||
"uniform float Alpha;\n"
|
||||
"\n"
|
||||
"varying vec3 VertVarying;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 result = texture2D(Tex, gl_TexCoord[0].xy);\n"
|
||||
|
@ -864,7 +867,11 @@ void GLWorld_CreateShaders (void)
|
|||
" result += texture2D(FullbrightTex, gl_TexCoord[0].xy);\n"
|
||||
" result = clamp(result, 0.0, 1.0);\n"
|
||||
" // apply GL_EXP2 fog (from the orange book)\n"
|
||||
" float fog = exp(-gl_Fog.density * gl_Fog.density * gl_FogFragCoord * gl_FogFragCoord);\n"
|
||||
" // needs to be done fully in the fragment shader to match fixed-function's quality\n"
|
||||
" // (visible on large polygons / large texture scales)\n"
|
||||
" vec3 ecPosition = vec3(gl_ModelViewMatrix * vec4(VertVarying, 1.0));\n"
|
||||
" float fogFragCoord = abs(ecPosition.z);\n"
|
||||
" float fog = exp(-gl_Fog.density * gl_Fog.density * fogFragCoord * fogFragCoord);\n"
|
||||
" fog = clamp(fog, 0.0, 1.0);\n"
|
||||
" result = mix(gl_Fog.color, result, fog);\n"
|
||||
" result.a = Alpha;\n"
|
||||
|
|
Loading…
Reference in a new issue