source: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPathMap/PathMap.hlsl @ 2337

Revision 2337, 1.8 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 sampler2D colorSampler : register(s3);
7uniform float allClusterCount;
8uniform float clusterCount;
9
10struct vsInputWalk
11{
12    float4 pos                  : POSITION;
13    float2 tex                  : TEXCOORD1;
14    float2 texAtlas             : TEXCOORD2;
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                float3 weight = tex2D(clusterWeightSampler, float2((weightIndex + 0.5)/allClusterCount, 0.5)).rgb;
48                //weight = 0.0002 + 0.000000000001 * weight;
49                float3 val = tex2D(filteredAtlasSampler, prmTexPos).xyz;
50                if(length(val - float3(1,1,1))== 0)
51                val = 0;
52                col += val.xyz * weight;               
53        }
54       
55        float3 color = tex2D(colorSampler, input.tex).rgb;
56
57        return float4(col * color, 1);
58
59
60        //return float4(col,1) * 0.0000000000001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x / 32.0, input.texAtlas.y));
61}
62
Note: See TracBrowser for help on using the repository browser.