source: GTP/trunk/App/Demos/Illum/Illumination Networks Demo [OpenGL]/src/FinalizeIllumMap.cg @ 845

Revision 845, 1.5 KB checked in by szirmay, 18 years ago (diff)
Line 
1#define D 128
2//#define Dper4Pi 14.33
3
4struct VertexOut
5{
6        float4 Position                         :POSITION;
7        float4 Color                            :COLOR0;
8        float2 TexCoord                         :TEXCOORD;
9        int ID                                          :TEXCOORD1;     
10};
11
12
13VertexOut VertexProgram(
14                  float4 Position   : POSITION,
15          float2 TexCoord       : TEXCOORD0,
16          float4 Color          : COLOR0,                               
17          uniform float4x4 ModelViewProj:state.matrix.mvp                       
18          )
19{
20        VertexOut Out; 
21       
22        Out.TexCoord=TexCoord;
23        //Out.Position=mul(ModelViewProj, Position);
24        Out.Position=Position;
25        Out.ID=TexCoord.x;
26        return Out;     
27}
28
29float4 FragmentProgram(VertexOut In,
30                                        uniform samplerRECT IllumTexture,
31                                        uniform samplerRECT TauTexture,                                         
32                                        uniform samplerRECT VisMap,
33                                        uniform samplerRECT DirectIllumTexture,
34                                        uniform samplerRECT Phase,                                             
35                                        uniform float4 EyeDirsWeights ,
36                                        uniform float3 Alb_Op) : COLOR
37{
38       
39                float4 Color=float4(0,0,0,1);
40                       
41                int particle=In.ID;
42                int direction=floor(EyeDirsWeights.x);
43                float4 I;
44               
45                float ds=texRECT(VisMap,float2(particle,direction)).g;
46                float tau=texRECT(TauTexture,float2(particle,1)).r;
47                float alpha=1-exp(-ds*tau);
48                //float alpha=Alb_Op.y;
49                               
50                I=texRECT(IllumTexture,float2(particle,direction));
51                Color=texRECT(DirectIllumTexture,float2(particle,direction))+(1-alpha)*I;
52                                               
53                for(int d=0;d<D;d++)
54                {
55                                I=texRECT(IllumTexture,float2(particle,d));
56                                Color+=I*(alpha*Alb_Op.z*texRECT(Phase,float2(d,direction)).r);
57                }
58                       
59               
60                return  Color;       
61}
Note: See TracBrowser for help on using the repository browser.