Calculating the length of the vertex results in quite broken values for fogging when the vertices are traversing the view frustum. The hardware also wouldn't have been doing a square root per vertex for fogging. Simply using the z values is enough. Todo check clamping of values for the near/far planes.

This commit is contained in:
Ian Curtis 2017-09-06 13:07:39 +00:00
parent 2786d95795
commit a3e2fb7906

View file

@ -43,7 +43,7 @@ void main(void)
{
fsViewVertex = vec3(gl_ModelViewMatrix * inVertex);
fsViewNormal = (mat3(gl_ModelViewMatrix) * inNormal) / modelScale;
float z = length(fsViewVertex);
float z = -fsViewVertex.z;
fsFogFactor = fogIntensity * clamp(fogStart + z * fogDensity, 0.0, 1.0);
fsDiscard = CalcBackFace(fsViewVertex);