source: GTP/trunk/App/Demos/Illum/Rain/rainMaterials/billboardPosTexUpdaterFP.cg @ 2221

Revision 2221, 1.3 KB checked in by plemenos, 18 years ago (diff)
  • Property svn:executable set to *
Line 
1
2///////////////////////////////////////////////////////////////////////////
3//
4//                 fragment program in charge
5//                 of position texture update
6//
7///////////////////////////////////////////////////////////////////////////
8
9
10
11float4 main(float2 coords          : TEXCOORD0,
12            uniform float tslf,
13            uniform float bbposTexSide,
14            uniform float partCount,
15            uniform float3 randomMove,
16            uniform float3 lastMove,
17            uniform float3 fallVect,
18            uniform sampler2D oldPos : TEXUNIT0) : COLOR
19{
20  float4 newPos;
21
22    newPos = tex2D(oldPos, coords);
23    newPos.a =1;
24
25    // compute the newt position, based on fall direction and speed, and user movement to compensate
26    newPos.xyz += fallVect * tslf - lastMove;
27
28    // keep the particles within the box
29    if (newPos.y <= 0.05)
30    {
31            newPos.y += 0.9;
32            newPos.xz += randomMove.xz;
33    }
34    else if (newPos.y >= 0.95)
35    {
36            newPos.y -= 0.9;
37    }
38
39    if (newPos.x <= 0.05)
40    {
41            newPos.x += 0.9;
42    }
43    else if (newPos.x >= 0.95)
44    {
45            newPos.x -= 0.9;
46    }
47
48    if (newPos.z <= 0.05)
49    {
50            newPos.z += 0.9;
51    }
52    else if (newPos.z >= 0.95)
53    {
54            newPos.z -= 0.9;
55    }
56
57  return newPos;
58}
Note: See TracBrowser for help on using the repository browser.