source: GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMap.hlsl @ 2217

Revision 2217, 1.6 KB checked in by szirmay, 17 years ago (diff)
Line 
1uniform float4x4 WorldViewProj;
2uniform float4 prmAtlasTilesHalfPixel;
3uniform sampler2D filteredAtlasSampler : register(s0);
4uniform sampler2D clusterWeightIndexSampler : register(s1);
5uniform sampler2D clusterWeightSampler : register(s2);
6uniform float allClusterCount;
7uniform float clusterCount;
8
9struct vsInputWalk
10{
11    float4 pos                  : POSITION;
12    float2 tex                  : TEXCOORD0;
13    float2 texAtlas             : TEXCOORD1;
14};
15
16struct vsOutputWalk
17{
18    float4 pos                  : POSITION;
19    float2 tex                  : TEXCOORD0;
20    float2 texAtlas             : TEXCOORD1;
21};
22
23
24vsOutputWalk vsWalk(vsInputWalk input)
25{
26        vsOutputWalk output = (vsOutputWalk)0;
27        output.pos = mul(WorldViewProj, input.pos);
28        output.tex = input.tex;
29        output.texAtlas = input.texAtlas;       
30        return output;
31}
32
33float4  psWalk(vsOutputWalk input) : COLOR
34{
35        int2 prmAtlasTiles = prmAtlasTilesHalfPixel.xy;
36        float2 atlasHalfPixel = prmAtlasTilesHalfPixel.zw;
37       
38        float3 col = 0;
39        for(int iCluster = 0; iCluster < 32; iCluster++)
40        {
41                float2 prmTexPos = float2(
42                        (input.texAtlas.x + (iCluster % prmAtlasTiles.x)) / prmAtlasTiles.x,
43                        1.0 - (input.texAtlas.y + (iCluster / prmAtlasTiles.x)) / prmAtlasTiles.y) + atlasHalfPixel;
44
45                float weightIndex = tex2D(clusterWeightIndexSampler, float2(((float)iCluster + 0.5) / clusterCount, 0.5)).r;
46                float weight = tex2D(clusterWeightSampler, float2((weightIndex + 0.5)/allClusterCount, 0.5)).r;
47                //weight = 0.0002 + 0.000000000001 * weight;
48                float3 val = tex2D(filteredAtlasSampler, prmTexPos).xyz;
49                col += val.xyz * weight;               
50        }
51       
52        return float4(col * 300, 1);
53}
54
Note: See TracBrowser for help on using the repository browser.