DirectX Shaders and Fog

Started by
2 comments, last by programmer_tom 18 years ago
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.
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
Thanks a lot for that. Makes sense.
good luck

-programmer_tom

This topic is closed to new replies.

Advertisement