Sign in to follow this  

GLSL vertex shaders and fog

This topic is 3594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If I am just using a GLSL vertex shader and my GL_FOG_COORDINATE_SRC is set to default (GL_FRAGMENT_DEPTH), how do I get the fixed pipeline to handle the fog? Do I set gl_FogFragCoord = abs((gl_ModelViewMatrix * pos).z) ? When I do this, I get very strange colors. Or do I have to use GL_FOG_COORDINATE and set the fog coordinates in order to access gl_FogCoord? I don't recall having to do that with vertex shaders using Cg. I'm only using a vertex shader for my object.

Share this post


Link to post
Share on other sites
just a guess:

The vertex shader has a varying output variable gl_FogFragCoord (float). If the fragments are handled by the fixed function pipeline than it will use the default varying output and input variables.

Just try something like:

vec3 ecposition = vec3(gl_ModelViewMatrix * gl_Vertex);
gl_FogFragCoord = ecposition.z/ecposition.w;

Share this post


Link to post
Share on other sites
I have used a fragment shader to make it work on ATI, without the color anomalies. But the only purpose of this shader is to make foliage sway in the wind. I can do this with a vertex shader only. And it works on nVidia. But ATI gives me strange color anomalies. Reading the 2.0 spec, all I should have to do is give gl_FogFragCoord my eyepoint position, as shown in the previous post.(??)

I've noticed that ATI is less forgiving than nVidia with shader specs, so hopefully someone can point out what I am missing by using only a Vertex Shader.

Share this post


Link to post
Share on other sites
Quote:
Original post by Duel93
I have used a fragment shader to make it work on ATI, without the color anomalies. But the only purpose of this shader is to make foliage sway in the wind. I can do this with a vertex shader only. And it works on nVidia. But ATI gives me strange color anomalies.
This is just to point out that there's no prize in using FFP instead of a simple FFP-like shader stage. You're not winning anything and nobody will ever think this is an awesome idea, especially if when doing that, you run in this kind of issues.
The fact that mixing FFP with shaders on ATi gives headaches is a point to leave FFP alone and begin starting to think that "it's better to do that with shaders anyway" for safety.

Share this post


Link to post
Share on other sites

This topic is 3594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this