Here is a sample of my cloud shader and associated source.
Code:
uniform extern texture cloud_tex1;
uniform extern texture cloud_tex2;
float2 cloud_scroll1;
float2 cloud_scroll2;
float4x4 matWorldViewProj;
sampler Cloud0 = sampler_state
{
texture = <cloud_tex1>;
};
sampler Cloud1 = sampler_state
{
texture = <cloud_tex2>;
};
struct VS_OUT
{
float4 Pos : POSITION;
float2 TexUV1 : TEXCOORD0;
float2 TexUV2 : TEXCOORD1;
};
VS_OUT VS(float4 Pos : POSITION,float2 TexUV1 : TEXCOORD0,float2 TexUV2 : TEXCOORD1)
{
VS_OUT outData = (VS_OUT)0;
outData.Pos = mul(Pos,matWorldViewProj);
TexUV1 += cloud_scroll1;
TexUV2 += cloud_scroll2;
outData.TexUV1 = TexUV1;
outData.TexUV2 = TexUV2;
return outData;
}
float4 PS(VS_OUT inData) : COLOR
{
float c0 = tex2D(Cloud0, inData.TexUV1);
float c1 = tex2D(Cloud1, inData.TexUV2);
float total_inverse = 1.0f / (c0 + c1);
//c0 *= c0 * total_inverse;
//c1 *= c1 * total_inverse;
return (1.0f - total_inverse) * 3.0f;
}
technique Clouds
{
pass P0
{
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}