Original Post
I thought I had sorted my depth rendering problem out, but something is still amiss. I'm doing per-pixel fog and packing the results of short, medium and long ranges into the rgb value of my depth render target. Because of the way I've packed it into different channels, it should display as black for close, red for short, yellow for medium and white for far. Somehow I'm getting a weird spot that moves around in relation to the camera, almost like some kind of evil specular hilight. It's not specific to any one object such as my terrain. Depth map: http://www.flickr.com/photos/nih7777/3419935584/sizes/o/ Screenshot: http://www.flickr.com/photos/nih7777/3419126857/sizes/o/ Because of the way I've packed it into different channels, it should be black for close, red for short, yellow for medium and white for far. The black spot in that shot is way off in the distance however. It's messing up my transmissive textures badly. All the examples I've found do it this way. What could I be doing wrong here? Also, would vertex fog be a better option? [Edited by - ooooooooOoo on April 6, 2009 8:09:48 PM]
VertexShaderOutput VertexShader(VertexShaderInput In)
{
Out.Position = mul(mul(mul(In.Position, World), View), Projection);
Out.TransformedPosition = Out.Position;
float3 PositionWorld = mul(In.Position, World).xyz;
Out.WorldView = ViewInverse[3].xyz - PositionWorld;
}
float4 PixelShader(PixelShaderInput In) : COLOR0
{
float3 Eye = In.WorldView;
float EyeDistance = distance(Eye, In.TransformedPosition);
}