I get clouds shader in http://forum.thegamecreators.com/?m=forum_view&t=109300&b=8
In my project i make infinity sky, but i need apply fog to clouds. I dont know shader language, help me please
ps. I put "FOGENABLE = TRUE;" and get very strange picture
//--------------------------------
// Un-tweaks
//--------------------------------
matrix WorldVP : WorldViewProjection;
matrix World : World;
matrix ViewInv : ViewInverse;
float3 ViewPosition : CameraPosition;
//--------------------------------
// Tweaks
//--------------------------------
float Scale = 400.5;
float4 SunDirection = { 0.0f, -1.0f, 0.0f, 0.0f };
//--------------------------------
// Textures
//--------------------------------
texture Cloud
<
string Name = "";
>;
sampler2D CloudSample = sampler_state
{
texture = <Cloud>;
};
//--------------------------------
// structs
//--------------------------------
struct VertexInput
{
float4 Pos : POSITION ;
float2 UV : TEXCOORD0 ;
float3 Normal : NORMAL ;
};
struct VertexOutput
{
float4 Pos : POSITION ;
float2 UV : TEXCOORD0 ;
float3 Normal : TEXCOORD1 ;
float3 View : TEXCOORD2 ;
};
//--------------------------------
// Vertex Shader
//--------------------------------
VertexOutput VertexMain( VertexInput Input, uniform float DepthScale )
{
VertexOutput Output;
float4 Position = mul( Input.Pos, WorldVP );
//Output.Pos = Position + float4( ( Input.UV - 0.5 ), 0.0, 0.0);
Output.Pos = Position + float4( ( Input.UV - 0.5 ) * Scale, 0.0, 0.0);
Output.UV = Input.UV;
Output.Normal = Input.Normal;
Output.View = Position;
return Output;
}
//--------------------------------
// Pixel Shader
//--------------------------------
float4 PixelMain( float2 UV: TEXCOORD0, float3 Normal: TEXCOORD1, float3 View : TEXCOORD2 ) : COLOR
{
float4 Colour = tex2D( CloudSample, UV );
float Dot = dot( normalize( View ), SunDirection );
Dot = 0.5 * ( 1.0 + Dot );
float Shade = 1.0 - 0.75 * ( Dot * Dot * Dot );
Colour.rgb = Colour.rgb * Shade;
return Colour;
}
float4 zDepthPixel( float2 UV: TEXCOORD0 ) : COLOR
{
float4 Colour = { 0.0f, 0.0f, 0.0f, 0.0f };
return Colour;
}
//--------------------------------
// Techniques
//--------------------------------
technique Main
{
pass DrawPass
{
//ZWRITEENABLE = false;
SRCBLEND = SRCALPHA;
DESTBLEND = INVSRCALPHA;
// ALPHABLENDENABLE = TRUE;
//alphatestenable = true;
//cullmode = none;
//FOGENABLE = TRUE;
vertexShader = compile vs_1_1 VertexMain( 0.0 );
pixelShader = compile ps_2_0 PixelMain();
}
}
zzz!