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

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