Sign in to follow this  
Joeman

fog and vertex shaders?

Recommended Posts

I'm rendering a scene with terrain, water, and objects. I am rendering the terrain and the water using the programmable pipeline (both pixel and vertex shaders). I'm using the fixed function pipeline for objects. I am having a problem getting fog to work correctly on different graphics cards. On a GeForce 6800 ULTRA, I have no problem, the fog renders correctly for the objects, terrain, and water. When running the application on a GeForce FX Go5600 however, the fog does not render on primitives rendered using the programmable pipeline. I figured out that when using the programmable pipeline, the fog was being automatically calculated for me on the GeForce 6800 but not on the 5600. Therefore to make the application run correctly on both cards I attempted calculated the fog ratio in the vertex shader by hand. This is a snippet of calculating the fog by hand. struct VS_OUTPUT { float4 Pos : POSITION; float4 Diff : COLOR0; float2 TexCoord1 : TEXCOORD0; float2 TexCoord2 : TEXCOORD1; float1 Fog : FOG; }; VS_OUTPUT VS( float3 Pos : POSITION ) { VS_OUTPUT Out; Out.Fog = calculateFog(Pos); .... .... process lots of other stuff .... return Out; } The "Fog" variable outputed from the vertex shader has absolutely no effect on the render. Fog is still displayed on the 6800 and breaks on the 5600. My questions are: Is there a way to make the 5600 calculate fog for me (like the 6800) so that I don't have to do it myself in the vertex shader? Is there a setting I need to change so that the output fog variable in the vertex shader is used as the fog intensity? Any help is appreciated!

Share this post


Link to post
Share on other sites
Hi,

Just blend your fog parameter with the diffuse color yourself. (e.g. pass the fog parameter as a COLORN to your pixel shader, and in your pixel shader, blend it with the pixel color)

Share this post


Link to post
Share on other sites
That is a valid option. However, not using the FOG semantic to export the fog value from the vertex shader is kind of a hack. The fog output should work and I need to find out why it doesn't.

Share this post


Link to post
Share on other sites

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