[845] | 1 | #define D 128
|
---|
| 2 | #define N 512
|
---|
| 3 |
|
---|
| 4 | struct VertexOut
|
---|
| 5 | {
|
---|
| 6 | float4 VertexPosition :POSITION;
|
---|
| 7 | float2 TexCoord :TEXCOORD;
|
---|
| 8 | };
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | /*
|
---|
| 12 | Vertex program for cloud rendering
|
---|
| 13 | */
|
---|
| 14 | VertexOut VertexProgram( float4 Position :POSITION,
|
---|
| 15 | float2 Texcoord: TEXCOORD
|
---|
| 16 | )
|
---|
| 17 | {
|
---|
| 18 | VertexOut Out;
|
---|
| 19 |
|
---|
| 20 | Out.VertexPosition=Position;
|
---|
| 21 | Out.TexCoord=Texcoord;
|
---|
| 22 |
|
---|
| 23 | return Out;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | /*
|
---|
| 27 | Fragment program for cloud rendering
|
---|
| 28 | */
|
---|
| 29 | float3 FragmentProgram( VertexOut In,
|
---|
| 30 | uniform samplerRECT IllumTexture,
|
---|
| 31 | uniform samplerRECT TauTexture,
|
---|
| 32 | uniform samplerRECT VisMap,
|
---|
| 33 | uniform samplerRECT DirectIllum,
|
---|
| 34 | uniform samplerRECT Phase,
|
---|
| 35 | uniform float3 Alb_Op,
|
---|
| 36 | uniform float3 SkyColor
|
---|
| 37 | ):COLOR
|
---|
| 38 | {
|
---|
| 39 | float3 Color=float3(0,0,0);
|
---|
| 40 |
|
---|
| 41 | int particle=floor(In.TexCoord.x);
|
---|
| 42 | int direction=floor(In.TexCoord.y);
|
---|
| 43 |
|
---|
| 44 | int vp=floor(texRECT(VisMap,float2(particle,direction)).r);
|
---|
| 45 |
|
---|
| 46 | if(vp<N)
|
---|
| 47 | {
|
---|
| 48 | Color=texRECT(DirectIllum,float2(vp,direction));
|
---|
| 49 | float ds=texRECT(VisMap,float2(particle,direction)).g;
|
---|
| 50 | float tau=texRECT(TauTexture,float2(particle,1)).r;
|
---|
| 51 | //tau=5.0;
|
---|
| 52 | //ds=0.1;
|
---|
| 53 | //if(ds<0.1)ds=0.1;
|
---|
| 54 | float alpha=1-exp(-ds*tau);
|
---|
| 55 | //float alpha=Alb_Op.y;
|
---|
| 56 |
|
---|
| 57 | float3 I=texRECT(IllumTexture,float2(vp,direction));
|
---|
| 58 | //Color+=I.rgb*(1-Alb_Op.y);
|
---|
| 59 | Color+=I.rgb*(1-alpha);
|
---|
| 60 |
|
---|
| 61 | for(int d=0;d<D;d++)
|
---|
| 62 | {
|
---|
| 63 | I=texRECT(IllumTexture,float2(vp,d));
|
---|
| 64 | //Color+=I.rgb*Alb_Op.z*texRECT(Phase,float2(d,direction)).r;
|
---|
| 65 | Color+=I.rgb*alpha*Alb_Op.z*texRECT(Phase,float2(d,direction)).r;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | }
|
---|
| 70 | else
|
---|
| 71 | {
|
---|
| 72 | //Color=float3(2.2,2.9,4.5);
|
---|
| 73 | Color=SkyColor;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | return Color;
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 |
|
---|