Pixel fog.

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

Recommended Posts

Correct me if i'm wrong, but the pixel fog render state are only valid for fixed pipeline ? I mean that there is no effect when using pixel shaders...

Share on other sites

you just have to calculate it yourself in the vertex shader, and output it.

struct VS_OUTPUT   {   float4 oPos : POSITION;   float2 oT0  : TEXCOORD0;   float  oFog : FOG;      };//RcpFogEndMinusFogStart is the reciprical of the FOG_END - the FOG_START.... 1.0f / ( FOG_END - FOG_START ).float CalculateFog ( float fDistanceFromCamera )   {   return max ( min ( ( FOG_END - fDistanceFromCamera ) * RcpFogEndMinusFogStart, 1.0f ), 0.0f );   }float4 fDistanceFromCamera = mul ( vPos, matWorldView );   // vPos is vertex position Out.oFog = CalculateFog ( fDistanceFromCamera.z );

Share on other sites
You can do anything and more advance stuff with vertex/pixel shaders just as with the FVF. So you can do pixel fog in HLSL.

Share on other sites
Shader model 3 removes the built in fog. If you use SM3 you must do your own fogging.

Share on other sites

Quote:
 Original post by programmer_tomno, it works if you are writing your own shaders.you just have to calculate it yourself in the vertex shader, and output it.*** Source Snippet Removed ***

Is that pixel fog or vertex fog ? ;)

Share on other sites
The fog parameter is calculated per vertex, and then interpolated. However you get the same result you would have gotten had you calculated the parameter per pixel, since the fog equation is linear.

Share on other sites
Quote:
 Original post by ZipsterThe fog parameter is calculated per vertex, and then interpolated. However you get the same result you would have gotten had you calculated the parameter per pixel, since the fog equation is linear.

I see, your right, thank you very much.

A last question, do this technic works on shader model 3 (vertex oFog) ?

Share on other sites
Quote:
 Original post by NamethatnobodyelsetookShader model 3 removes the built in fog. If you use SM3 you must do your own fogging.

Share on other sites
Quote:
Original post by Namethatnobodyelsetook
Quote:
 Original post by NamethatnobodyelsetookShader model 3 removes the built in fog. If you use SM3 you must do your own fogging.

That's it. ;) Thank you !