1 | struct VertexOut
|
---|
2 | {
|
---|
3 | float4 VertexPosition :POSITION;
|
---|
4 | float2 TexCoord :TEXCOORD;
|
---|
5 | };
|
---|
6 |
|
---|
7 |
|
---|
8 | /*
|
---|
9 | Vertex program for cloud rendering
|
---|
10 | */
|
---|
11 | VertexOut VertexProgram( float4 Position :POSITION,
|
---|
12 | float2 Texcoord: TEXCOORD,
|
---|
13 | uniform float4x4 ModelViewProj :state.matrix.mvp
|
---|
14 | )
|
---|
15 | {
|
---|
16 | VertexOut Out;
|
---|
17 |
|
---|
18 | Out.VertexPosition=mul(ModelViewProj, Position);
|
---|
19 | Out.TexCoord=Texcoord;
|
---|
20 |
|
---|
21 | return Out;
|
---|
22 | }
|
---|
23 |
|
---|
24 | /*
|
---|
25 | Fragment program for cloud rendering
|
---|
26 | */
|
---|
27 | float3 FragmentProgram( VertexOut In,
|
---|
28 | uniform samplerRECT IllumTexture,
|
---|
29 | uniform samplerRECT VisMap,
|
---|
30 | uniform samplerRECT DirectIllum,
|
---|
31 | uniform samplerRECT Phase,
|
---|
32 | uniform float2 Alb_Op
|
---|
33 | ):COLOR
|
---|
34 | {
|
---|
35 |
|
---|
36 | int thisDir=round(In.TexCoord.y);
|
---|
37 | int thisID=round(In.TexCoord.x);
|
---|
38 | float3 DirectRad;
|
---|
39 | float3 Radin;
|
---|
40 |
|
---|
41 | float3 Color=float3(0,0,0);
|
---|
42 | //texRECT(IllumTexture,float2(thisID,thisDir)).rgb;
|
---|
43 |
|
---|
44 | int visibleID=round(texRECT(VisMap,float2(thisID,thisDir)).r);
|
---|
45 |
|
---|
46 | if(visibleID<512)
|
---|
47 | {
|
---|
48 | DirectRad=texRECT(DirectIllum,float2(visibleID,thisDir)).rgb;
|
---|
49 | Radin=texRECT(IllumTexture,float2(visibleID,thisDir)).rgb;
|
---|
50 |
|
---|
51 | Color+=(1-Alb_Op.y)*(Radin+DirectRad);
|
---|
52 | }
|
---|
53 |
|
---|
54 | float a_o=Alb_Op.x*Alb_Op.y*1.0/4.0;
|
---|
55 |
|
---|
56 | for(int d=0;d<4;d++)
|
---|
57 | {
|
---|
58 | visibleID=round(texRECT(VisMap,float2(thisID,d)).r);
|
---|
59 |
|
---|
60 | if(visibleID<4)
|
---|
61 | {
|
---|
62 | DirectRad=texRECT(DirectIllum,float2(visibleID,thisDir)).rgb;
|
---|
63 | Radin=texRECT(IllumTexture,float2(visibleID,d));
|
---|
64 | Color+=(Radin+DirectRad)*a_o*texRECT(Phase,float2(d,thisDir)).r;
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | return Color;
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|