[852] | 1 | struct VertexOut
|
---|
| 2 | {
|
---|
| 3 | float4 VertexPosition :POSITION;
|
---|
| 4 | float2 TexCoord :TEXCOORD;
|
---|
| 5 | float4 Position :TEXCOORD2;
|
---|
| 6 | float4 Color :COLOR0;
|
---|
| 7 | };
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | /*
|
---|
| 11 | Vertex program for displaying particle system with rectangle rendertexture
|
---|
| 12 | */
|
---|
| 13 | VertexOut VertexProgram( float4 Position :POSITION,
|
---|
| 14 | float4 Texcoord: TEXCOORD,
|
---|
| 15 | float4 Color:COLOR0,
|
---|
| 16 | float3 BillboardSize: NORMAL,
|
---|
| 17 | uniform float4x4 ModelViewProj :state.matrix.mvp
|
---|
| 18 | )
|
---|
| 19 | {
|
---|
| 20 | VertexOut Out;
|
---|
| 21 |
|
---|
| 22 | Out.Color=Color;
|
---|
| 23 |
|
---|
| 24 | Out.VertexPosition=mul(ModelViewProj, Position);
|
---|
| 25 | Out.TexCoord=Texcoord.xy;
|
---|
| 26 |
|
---|
| 27 | Out.Position=Out.VertexPosition;
|
---|
| 28 | Out.Position.x=Texcoord.w;
|
---|
| 29 | Out.Position.z=(Out.Position.z/Out.Position.w+1)/2;
|
---|
| 30 | Out.Position.y=Out.Position.z-0.5*Out.Position.x;
|
---|
| 31 |
|
---|
| 32 | return Out;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | /*
|
---|
| 36 | Fragment program for displaying particle system with rectangle rendertexture
|
---|
| 37 | */
|
---|
| 38 | void FragmentProgram( VertexOut In,
|
---|
| 39 | uniform sampler2D Texture,
|
---|
| 40 | uniform sampler2D frontTexture,
|
---|
| 41 | out float4 Color:COLOR
|
---|
| 42 | )
|
---|
| 43 | {
|
---|
| 44 | float d=tex2D(frontTexture,In.TexCoord).r;
|
---|
| 45 | float d2=1.0-d;
|
---|
| 46 |
|
---|
| 47 | float frontDepth;
|
---|
| 48 | float backDepth;
|
---|
| 49 |
|
---|
| 50 | frontDepth=In.Position.y+d*In.Position.x;
|
---|
| 51 | backDepth=In.Position.y+d2*In.Position.x;
|
---|
| 52 |
|
---|
| 53 | if(d==1)
|
---|
| 54 | {
|
---|
| 55 | frontDepth=1;
|
---|
| 56 | backDepth=0;
|
---|
| 57 | }
|
---|
| 58 | backDepth=1-backDepth;
|
---|
| 59 |
|
---|
| 60 | Color=float4(frontDepth,backDepth,0,tex2D(Texture,In.TexCoord).r*0.17*In.Color.a);
|
---|
| 61 | //Color=float4(frontDepth,backDepth,0,1-backDepth-frontDepth);
|
---|
| 62 | }
|
---|
| 63 |
|
---|