Sign in to follow this  

Fogging With Pixel/vertex Shader Question

This topic is 4719 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

Could any one please tell me or point me in the direction of how to do fogging using pixel/vertex shaders? Does any one know any could tutorials/examples of pixel shaders, can't seem to find any on the net. Cheers. James.

Share this post


Link to post
Share on other sites
You have to output a scalar value to the oFog register from the vertex shader as well as enable the fixed function fog unit (since fogging isn't done manually in the pixel shader yet). Remember that 0 means full fog and 1 means no fog :) This is perhaps not very intuitive but it's because of the way DirectX blends fog into the output from the pixel shader

FinalColor = fog * pixelColor + (1-fog) * fogColor

Also remember that fogging takes place after the pixel shader has been executed, but *before* the result has been blended into the framebuffer. This can be kinda annoying if you're working with multiple passes.

- Kasper Fauerby

Share this post


Link to post
Share on other sites

This topic is 4719 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