source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/Standalone/Hierarchical Systems Demo [OpenGL]/src/IllumPrograms.cg @ 3255

Revision 3255, 1.3 KB checked in by szirmay, 15 years ago (diff)
Line 
1struct VertexOut
2{
3        float4 VertexPosition           :POSITION;
4        float2 TexCoord                         :TEXCOORD;
5        float4 Color1                           :COLOR;
6};
7
8
9/*
10  Vertex program for displaying particle system with rectangle rendertexture
11*/
12VertexOut VertexProgram( float4 Position :POSITION,
13                                                float4 Texcoord: TEXCOORD,
14                                                uniform float transparency,
15                                                uniform float4x4 ModelViewProj  :state.matrix.mvp
16                                                )                                                                       
17{
18        VertexOut Out; 
19       
20        Out.VertexPosition=mul(ModelViewProj, Position);
21        Out.TexCoord=Texcoord.xy;       
22       
23        Out.Color1=float4(transparency,transparency,transparency,transparency);
24       
25       
26        float z=(Out.VertexPosition.z/Out.VertexPosition.w+1)/2;
27       
28        float4 planes=float4(0.33,0.5,0.66,1); 
29        if(z>planes.x)
30        {
31                Out.Color1.r=0;
32        }
33        if(z>planes.y)
34        {
35                Out.Color1.g=0;
36        }
37        if(z>planes.z)
38        {
39                Out.Color1.b=0;
40        }
41       
42        return Out;     
43}
44
45
46/*
47  Fragment program for displaying particle system with rectangle rendertexture
48*/
49void FragmentProgram(   VertexOut       In,
50                                                uniform sampler2D Texture,
51                                                uniform samplerRECT PhaseTexture,
52                                                uniform float Albedo,
53                                                uniform float Symmetry,
54                                                out float4 Color:COLOR
55                                                )
56{
57       
58        float4 extintion=tex2D(Texture,In.TexCoord).r*In.Color1;       
59        float scattered=Albedo*texRECT(PhaseTexture,float2(Symmetry,1)*256)/1.5;
60        Color=1-extintion+extintion*scattered; 
61        //Color=float4(0,0,0,0);       
62}
63
Note: See TracBrowser for help on using the repository browser.