Is there BasicEffect.Fog in Xen?

Mar 11, 2010 at 12:46 AM

Hi.

I want that distance objects look blurry or gray. I searched MSDN, find that BasicEffect.Fog parameter in XNA.

Is there same effect in Xen?

 

thanks.

 

Mar 11, 2010 at 4:58 PM

Nope, the MaterialShader does not implement fog.

However, you can add it yourself inside Material.fx. The following code is from BasicEffect.fx (http://creators.xna.com/en-US/utilities/basiceffectshader):

//-----------------------------------------------------------------------------
// Compute fog factor
//-----------------------------------------------------------------------------
float ComputeFogFactor(float d)
{
    return clamp((d - FogStart) / (FogEnd - FogStart), 0, 1) * FogEnabled;
}

Then to compute the fog factor use ComputeFogFactor(length(EyePosition - position_ws)); either in the vertex shader or pixel shader.

 

Coordinator
Mar 11, 2010 at 11:09 PM

Hi. Yes, MaterialShader doesn't support fog. I made the decision to keep the number of shader combinations down - however it could be added as an 'always on' feature. (As I'm sure you have noticed, MaterialShader is *rather* complex under the hood :-)

Mar 12, 2010 at 1:48 AM

Thanks arriu, StatusUnknown!