1 | struct VertexOut
|
---|
2 | {
|
---|
3 | float4 VertexPosition :POSITION;
|
---|
4 | float2 TexCoord :TEXCOORD;
|
---|
5 | float4 Position :TEXCOORD1;
|
---|
6 | float4 EyePosition :TEXCOORD2;
|
---|
7 | float2 BbSizeAngleCos :TEXCOORD3;
|
---|
8 | float4 LightSpacePos :TEXCOORD4;
|
---|
9 | float4 Color :COLOR0;
|
---|
10 | };
|
---|
11 |
|
---|
12 |
|
---|
13 | //
|
---|
14 | // Vertex program for displaying particle system with rectangle rendertexture
|
---|
15 | //
|
---|
16 | VertexOut VertexProgram( float4 Position :POSITION,
|
---|
17 | float4 Texcoord: TEXCOORD,
|
---|
18 | float4 Color:COLOR0,
|
---|
19 | uniform float4x4 LightModelViewProj,
|
---|
20 | uniform float3 LightPosition,
|
---|
21 | uniform float3 EyePosition,
|
---|
22 | uniform float4x4 ModelViewProj :state.matrix.mvp,
|
---|
23 | uniform float4x4 ModelViewMatrix:state.matrix.modelview
|
---|
24 | )
|
---|
25 | {
|
---|
26 | VertexOut Out;
|
---|
27 |
|
---|
28 | Out.Color=Color;
|
---|
29 |
|
---|
30 | Out.VertexPosition=mul(ModelViewProj, Position);
|
---|
31 | Out.TexCoord=Texcoord.xy;
|
---|
32 |
|
---|
33 | float3 LightToPoint=normalize(Position.xyz-LightPosition);
|
---|
34 | float3 PointToEye=normalize(EyePosition-Position.xyz);
|
---|
35 | Out.BbSizeAngleCos.y=(dot(LightToPoint,PointToEye)+1)/2;
|
---|
36 |
|
---|
37 | return Out;
|
---|
38 | }
|
---|
39 |
|
---|
40 | //
|
---|
41 | // Fragment program for displaying particle system with rectangle rendertexture
|
---|
42 | //
|
---|
43 | void FragmentProgram( VertexOut In,
|
---|
44 | uniform samplerRECT FrontTexture,
|
---|
45 | uniform samplerRECT PhaseTexture,
|
---|
46 | uniform float Albedo,
|
---|
47 | uniform float Transparency,
|
---|
48 | uniform float Symmetry,
|
---|
49 | uniform float3 LightColor,
|
---|
50 | float4 out Color:COLOR
|
---|
51 | )
|
---|
52 | {
|
---|
53 | float density=texRECT(FrontTexture,In.TexCoord*256).a;
|
---|
54 |
|
---|
55 | float phase=texRECT(PhaseTexture,float2(Symmetry,In.BbSizeAngleCos.y)*256);
|
---|
56 | float realdens=density*Transparency;
|
---|
57 | float outcol=realdens*phase*Albedo;
|
---|
58 |
|
---|
59 | Color=float4(LightColor*outcol*In.Color.rgb,1-realdens);
|
---|
60 |
|
---|
61 | }
|
---|
62 |
|
---|