Jump to content
  • Advertisement
Sign in to follow this  

DirectX Shaders and Fog

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

I'm having a little trouble understanding the FOG semantic in effect files. I've enabled hardware fog in the renderstate, and unless i set FOG on the vertex to 1, I get full fog. Toying around with the values seemed to give me mixed results, so I was wondering if someone could explain how to properly handle fog in the shader or at least point me in the direction to some usefull information, as my searches haven't shown anything.

Share this post


Link to post
Share on other sites
Advertisement
hey man

The HLSL looks like this:

//Transform to view space

float4 fDistanceFromCamera = mul ( vPos, matWorldView );

// clamp 0 to 1. fRcpFogEndMinusFogStart is the reciprocal of the fog end - fog start : ( 1 / ( FOG_END - FOG_START ) ) . I preprocess that float for efficiency.

Out.oFog = max ( min ( ( fFogEnd - fDistanceFromCamera.z ) * fRcpFogEndMinusFogStart, 1.0f ), 0.0f );


-programmer_tom

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!