Fluxtah

I have no idea why but I just can not get fog working on my terrain, I have tried setting the fog renderstates as follows, I have tried everything and these are the last values I have tried using...

this.Graphics.GraphicsDevice.RenderState.FogColor = Color.White;

this.Graphics.GraphicsDevice.RenderState.FogVertexMode = FogMode.Linear;

this.Graphics.GraphicsDevice.RenderState.FogStart = 2.0f;

this.Graphics.GraphicsDevice.RenderState.FogEnd = 5000.0f;

this.Graphics.GraphicsDevice.RenderState.FogEnable = true;

here is part of my vertex shader where I set the fog intensity

struct VS_OUTPUT

{

float4 Position : POSITION0;

float2 Texcoord : TEXCOORD0;

float2 Texcoord1 : TEXCOORD1;

float Fog : FOG;

};

VS_OUTPUT Textured_Pass_0_Vertex_Shader_vs_main( VS_INPUT Input )

{

VS_OUTPUT Output;

Output.Position = mul( Input.Position, matViewProjection );

Output.Texcoord = Input.Texcoord;

Output.Texcoord1 = Input.Texcoord;

Output.Texcoord1.xy *= 64.0f;

Output.Fog = 0.1f;

return( Output );

}

I was under the impression (working from my book - Shaders for game programmers and graphic artists) that zero is full fog, regardless I have tried every possible value here :(

I cant get it to work on my terrain, I set no other renderstates anywhere, funny thing is, it actually effects other things that are rendered (text and dev console).

Not sure what I am doing wrong here!

any help much appreciated.



Re: XNA Framework Fog?

Darkside

Have a look at the latest releases of the Quadtree Project on Codeplex.

The sample shows a dynamic terrain and also iplements fog, may give you some ideas!

Works great as well, hope this helps

Darkside






Re: XNA Framework Fog?

Fluxtah

It uses BasicEffect, I already looked :) I don't use BasicEffect.



Re: XNA Framework Fog?

Fluxtah

hmm never mind found the answer: Fog does not work in Shader Model 3, to get fog to work either use SM2 or calculate fog in the pixel shader yourself.