struct VertexOut { float4 VertexPosition :POSITION; float2 TexCoord :TEXCOORD; }; /* Vertex program for cloud rendering */ VertexOut VertexProgram( float4 Position :POSITION, float2 Texcoord: TEXCOORD ) { VertexOut Out; Out.VertexPosition=Position; Out.TexCoord=Texcoord; return Out; } /* Fragment program for cloud rendering */ float4 FragmentProgram( VertexOut In, uniform float Albedo, uniform float Transparency, uniform float Symmetry, uniform samplerRECT IllumTexture, uniform samplerRECT PhaseTexture, uniform samplerRECT AngleTexture):COLOR { In.TexCoord.y=1-In.TexCoord.y; float uvsize=256; float4 Color=texRECT(IllumTexture,In.TexCoord*uvsize); if(Color.a!=1) { //3 random uv's float transparency=Transparency; float albedo=Albedo; float t=0.3; float g=Symmetry; float2 Rand1=(float2(noise(float3(In.TexCoord,t)),noise(float3(In.TexCoord.x,t,In.TexCoord.y))))*10; float2 Rand2=(float2(noise(float3(In.TexCoord.yx,t)),noise(float3(In.TexCoord.y,t,In.TexCoord.x))))*10; float2 Rand3=(float2(noise(float3(t,In.TexCoord)),noise(float3(t,In.TexCoord.yx))))*10; float3 dist; float3 Cosangles; float3 PhasesFront; float3 PhasesBack; float3 Scattering; float3 RedSamples; float3 GreenSamples; float3 BlueSamples; float3 AlphaSamples; /* float2 point1=saturate(In.TexCoord+Rand1)*uvsize; float2 point2=saturate(In.TexCoord+Rand2)*uvsize; float2 point3=saturate(In.TexCoord+Rand3)*uvsize; RedSamples=float3(texRECT(IllumTexture,point1).r,texRECT(IllumTexture,point2).r,texRECT(IllumTexture,point3).r); GreenSamples=float3(texRECT(IllumTexture,point1).g,texRECT(IllumTexture,point2).g,texRECT(IllumTexture,point3).g); BlueSamples=float3(texRECT(IllumTexture,point1).b,texRECT(IllumTexture,point2).b,texRECT(IllumTexture,point3).b); AlphaSamples=float3(texRECT(IllumTexture,point1).a,texRECT(IllumTexture,point2).a,texRECT(IllumTexture,point3).a); */ In.TexCoord*=uvsize; RedSamples=float3(texRECT(IllumTexture,In.TexCoord+Rand1).r,texRECT(IllumTexture,In.TexCoord+Rand2).r,texRECT(IllumTexture,In.TexCoord+Rand3).r); GreenSamples=float3(texRECT(IllumTexture,In.TexCoord+Rand1).g,texRECT(IllumTexture,In.TexCoord+Rand2).g,texRECT(IllumTexture,In.TexCoord+Rand3).g); BlueSamples=float3(texRECT(IllumTexture,In.TexCoord+Rand1).b,texRECT(IllumTexture,In.TexCoord+Rand2).b,texRECT(IllumTexture,In.TexCoord+Rand3).b); AlphaSamples=float3(texRECT(IllumTexture,In.TexCoord+Rand1).a,texRECT(IllumTexture,In.TexCoord+Rand2).a,texRECT(IllumTexture,In.TexCoord+Rand3).a); /* //background if(RedSamples.x==1)RedSamples.x=0; if(RedSamples.y==1)RedSamples.y=0; if(RedSamples.z==1)RedSamples.z=0; if(GreenSamples.x==1)GreenSamples.x=0; if(GreenSamples.y==1)GreenSamples.y=0; if(GreenSamples.z==1)GreenSamples.z=0; if(BlueSamples.x==1)BlueSamples.x=0; if(BlueSamples.y==1)BlueSamples.y=0; if(BlueSamples.z==1)BlueSamples.z=0; */ dist=float3(length(Rand1),length(Rand2),length(Rand3)); Cosangles=float3(texRECT(AngleTexture,float2(dist.x,0.25)).r, texRECT(AngleTexture,float2(dist.y,0.25)).r, texRECT(AngleTexture,float2(dist.z,0.25)).r)/2; PhasesFront=float3(texRECT(PhaseTexture,float2(g,0.5+Cosangles.x)*256).r, texRECT(PhaseTexture,float2(g,0.5+Cosangles.y)*256).r, texRECT(PhaseTexture,float2(g,0.5+Cosangles.z)*256).r); PhasesBack=float3(texRECT(PhaseTexture,float2(g,0.5-Cosangles.x)*256).r, texRECT(PhaseTexture,float2(g,0.5-Cosangles.y)*256).r, texRECT(PhaseTexture,float2(g,0.5-Cosangles.z)*256).r); PhasesFront*=transparency*albedo/12.5; PhasesBack*=transparency*albedo/12.5; //Red Channel //Scattering=Color.g*PhasesBack; Scattering=GreenSamples*PhasesBack; Color.r+=Scattering.x+Scattering.y+Scattering.z; //Green Channel //Scattering=Color.b*PhasesBack+Color.r*PhasesFront; Scattering=RedSamples*PhasesFront+BlueSamples*PhasesBack; Color.g+=Scattering.x+Scattering.y+Scattering.z; //Blue Channel //Scattering=Color.a*PhasesBack+Color.g*PhasesFront; Scattering=GreenSamples*PhasesFront+AlphaSamples*PhasesBack; Color.b+=Scattering.x+Scattering.y+Scattering.z; //Alpha Channel //Scattering=Color.b*PhasesFront; Scattering=BlueSamples*PhasesFront; Color.a+=Scattering.x+Scattering.y+Scattering.z; } else { Color=float4(1,1,1,1); } return Color; }