I’m tryng to figure out, how to apply the fog in a fragment shader.
The fog is enabled before going into the shader, some operations are performed in the shader, but i need that the fog is applied in the FragColor too.
I tried, to:
gl_FragColor = gl_Fog.color * Output;
or
gl_FragColor = gl_Fog.color + Output;
Both of them don’t work, i guess there’s some other way to do this ?
When using a fragment shader you replace the fixed function fog computation and your shader needs to calculate the fog itself. Here is an example that shows how to do the EXP, EXP2, and LINEAR fog modes:
Can’t think of any reason it wouldn’t be working then.
I have a small example that does EXP, EXP2, and LINEAR fog and allows you to to switch between fixed function and shaders at runtime. You can download it here . Press ‘f’ to switch between the different fog modes and ‘s’ to toggle shaders and fixed function.
If this example works correctly on your computer (you shouldn’t be able to see any differences when switching between shaders and fixed function) then take a look at the code and see if you can locate what you are doing differently.
If you don’t see any fog in the shader mode then your might be seeing a driver bug.
Thanks,
Your application works fine here, i don’t get it.
Apparently i’m doing everything you do, i must be missing something…,
Oh well, i will eventually find out,