source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/OgreGames/CarGame/Media/materials/programs/GameTools_Cau.hlsl @ 3255

Revision 3255, 2.3 KB checked in by szirmay, 15 years ago (diff)
Line 
1float CauSpriteSize;
2float CauSpriteIntens;
3
4struct VS_OUT
5{
6        float4 hPosition        : POSITION;
7        float4 texCoord         : TEXCOORD0;
8        float4 color            : COLOR0;
9        float2 r                        : TEXCOORD1;
10        float2 center           : TEXCOORD2;
11        float4 position         : TEXCOORD3;
12        float pSize                     : PSIZE;
13        float dist                      : TEXCOORD4;
14};
15
16VS_OUT CauVS(float4 position : POSITION,       
17                float4 texCoord : TEXCOORD0,
18                float4 color    : COLOR0,
19                uniform float4x4 worldView,
20                uniform float4x4 Proj,
21                uniform float4x4 worldViewProj,
22                uniform float resolution,
23                uniform sampler2D PhotonHitMap : register(s0))
24{
25  VS_OUT OUT;
26     
27   float radius = CauSpriteSize;
28   OUT.pSize = radius;
29   float4 cPosition; 
30
31  float4 pos = tex2Dlod(PhotonHitMap, float4(position.x, 1.0 - position.y,0,0)).rgba;
32//      float4 pos = float4(0,0,-0.5,1);
33   if(pos.a == 0)//no photon hit
34   {
35                OUT.center = 1000.0f;
36                OUT.position = OUT.hPosition = 1000.0f; //transform out of view
37   }
38   else
39   {
40                float4 wPosition = float4(normalize(pos.xyz),1);
41   
42                cPosition = mul(worldView, wPosition);
43                OUT.center = cPosition.xy;
44                OUT.position = cPosition;       
45                OUT.hPosition = mul(Proj, cPosition);   
46                OUT.center = float2(OUT.hPosition.x, OUT.hPosition.y) / OUT.hPosition.w;       
47         }     
48 
49   OUT.r.x = radius;
50   OUT.r.y = radius;
51   OUT.texCoord = texCoord;
52   OUT.color = 1;
53   OUT.color = float4(pos);
54   OUT.dist = length(pos.xyz);
55   
56   return OUT;
57}
58
59
60float4 CauPS(VS_OUT IN,
61                uniform float3 color,
62                uniform sampler2D intensityTex : register(s1)
63                 ):COLOR
64{
65
66 // float2 texcoord = (IN.center - IN.position.xy) / IN.r.x;
67 // texcoord = (texcoord + 1.0) * 0.5;
68  IN.color.rgb = color;
69  float intens = tex2D(intensityTex, IN.texCoord).r;
70  IN.color.a = intens * CauSpriteIntens;
71  return IN.color; 
72}
73
74float4 CauCube_Point_PS(VS_OUT IN,
75                        uniform float targetResolution,
76                        float2 pixelPos : VPOS,
77                        uniform float3 color,
78                        uniform sampler2D intensityTex : register(s1)
79                                 ):COLOR
80{
81 
82 float2 screen = pixelPos / targetResolution;
83 screen *= float2(2, 2);
84 screen -= float2(1, 1);
85 screen.y *= -1;
86 float2 texCoord = (screen - IN.center) / (IN.r / targetResolution);
87 
88 float intens = 1.0 - saturate(length(texCoord));
89 
90IN.color.rgb = color;
91  IN.color.a *=  CauSpriteIntens * intens;
92
93  return IN.color; 
94}
95
96
Note: See TracBrowser for help on using the repository browser.