Am Donnerstag, 8. März 2012, 18:22:15 schrieb Matteo Bruni:
shader_addline(buffer, "gl_FogFragCoord = OUT[%u].%c;\n",
i, reg_mask[1]);
shader_addline(buffer, "gl_FogFragCoord =
clamp(OUT[%u].%c, 0.0, 1.0);\n", i, reg_mask[1]);
Is it correct to clamp the fog coord in the vertex shader, or should this be done in the pixel shader? The tests do not answer this question because they write the same fog coordinate for each vertex.
Imagine for example two lines. In each of those lines, one vertex has oFog = 0.0. The other vertex has oFog = 1.1 in one line, and oFog = 100 in the other. If the value is clamped per vertex, those lines will look the same. If it's clamped per pixel, the latter line will have much steeper gradient
Also, what happens to shaders that do not write oFog, but use oPos.z, especially in the situations where the near and far clipping planes are disabled?