mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-03-06 14:27:44 +00:00
The vertex shader is run before clipping is done. If fogging values are calculated and clamped in the vertex shader it can interpolate bad values, since the range has been truncated. This happens if the polys overlap the near plane. The solution to clamp the values in the fragment shader. This fixes a bunch of fogging errors I long thought were transparency related errors in the ocean hunter.
This commit is contained in:
parent
bc7f1e9fac
commit
bddc86aba9
|
@ -44,7 +44,7 @@ void main(void)
|
|||
fsViewVertex = vec3(gl_ModelViewMatrix * inVertex);
|
||||
fsViewNormal = (mat3(gl_ModelViewMatrix) * inNormal) / modelScale;
|
||||
float z = -fsViewVertex.z;
|
||||
fsFogFactor = fogIntensity * clamp(fogStart + z * fogDensity, 0.0, 1.0);
|
||||
fsFogFactor = fogIntensity * (fogStart + z * fogDensity);
|
||||
|
||||
fsDiscard = CalcBackFace(fsViewVertex);
|
||||
fsColor = inColour;
|
||||
|
@ -152,7 +152,7 @@ void main()
|
|||
discard; //emulate back face culling here
|
||||
}
|
||||
|
||||
fogData = vec4(fogColour.rgb * fogAmbient, fsFogFactor);
|
||||
fogData = vec4(fogColour.rgb * fogAmbient, clamp(fsFogFactor,0.0,1.0));
|
||||
tex1Data = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
if(textureEnabled) {
|
||||
|
|
Loading…
Reference in a new issue