well, its nothing special, but while i was using it i thought maybe someone else will have usage for it, too.
in the screenshot its applied to a skydome and gives a quite nice transition to the sky.
Code:
float4x4 matWorldViewProj;
float4 vecFog;
struct VS_IN
{
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
};
struct VS_OUT
{
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
float Fog : FOG;
};
VS_OUT mainVS (VS_IN In)
{
VS_OUT Out;
Out.position = mul(In.position,matWorldViewProj);
Out.Fog = (In.position.y/1500)-0.25; // you may need to adjust these values till it fits
Out.texCoord = In.texCoord;
return Out;
}
texture entSkin1;
sampler basemap = sampler_state
{
Texture = <entSkin1>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};
float4 mainPS (VS_OUT In) : COLOR0
{
return tex2D(basemap,In.texCoord);
}
technique heightFog
{
pass p0
{
VertexShader = compile vs_1_1 mainVS();
PixelShader = compile ps_1_1 mainPS();
}
}