1 | uniform float4x4 WorldViewProj;
|
---|
2 | uniform float4 prmAtlasTilesHalfPixel;
|
---|
3 | uniform sampler2D filteredAtlasSampler : register(s0);
|
---|
4 | uniform sampler2D clusterWeightIndexSampler : register(s1);
|
---|
5 | uniform sampler2D clusterWeightSampler : register(s2);
|
---|
6 | uniform sampler2D colorSampler : register(s3);
|
---|
7 | uniform float allClusterCount;
|
---|
8 | uniform float clusterCount;
|
---|
9 |
|
---|
10 | struct vsInputWalk
|
---|
11 | {
|
---|
12 | float4 pos : POSITION;
|
---|
13 | float2 tex : TEXCOORD0;
|
---|
14 | float2 texAtlas : TEXCOORD1;
|
---|
15 | };
|
---|
16 |
|
---|
17 | struct vsOutputWalk
|
---|
18 | {
|
---|
19 | float4 pos : POSITION;
|
---|
20 | float2 tex : TEXCOORD0;
|
---|
21 | float2 texAtlas : TEXCOORD1;
|
---|
22 | };
|
---|
23 |
|
---|
24 |
|
---|
25 | vsOutputWalk 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 |
|
---|
34 | float4 psWalk(vsOutputWalk input) : COLOR
|
---|
35 | {
|
---|
36 | float2 texAtlas = input.texAtlas;
|
---|
37 |
|
---|
38 | int2 prmAtlasTiles = prmAtlasTilesHalfPixel.xy;
|
---|
39 | float2 atlasHalfPixel = prmAtlasTilesHalfPixel.zw;
|
---|
40 |
|
---|
41 | float3 col = 0;
|
---|
42 | for(int iCluster = 0; iCluster < 32; iCluster++)
|
---|
43 | {
|
---|
44 | float2 prmTexPos = float2(
|
---|
45 | (texAtlas.x + (iCluster % prmAtlasTiles.x)) / prmAtlasTiles.x,
|
---|
46 | 1.0 - (texAtlas.y + (iCluster / prmAtlasTiles.x)) / prmAtlasTiles.y) + atlasHalfPixel;
|
---|
47 |
|
---|
48 | float weightIndex = tex2D(clusterWeightIndexSampler, float2(((float)iCluster + 0.5) / clusterCount, 0.5)).r;
|
---|
49 | float3 weight = tex2D(clusterWeightSampler, float2((weightIndex + 0.5)/allClusterCount, 0.5)).rgb;
|
---|
50 | float3 val = tex2D(filteredAtlasSampler, prmTexPos).xyz;
|
---|
51 | //if(length(val - float3(1,1,1))== 0)
|
---|
52 | //val = 0;
|
---|
53 | col += val.xyz * weight;
|
---|
54 | //col = 0.00000000001 * col + float3(prmTexPos,1);
|
---|
55 | }
|
---|
56 |
|
---|
57 | float3 color = tex2D(colorSampler, input.tex).rgb;
|
---|
58 |
|
---|
59 | //return float4(col,1);
|
---|
60 | //return float4(color + 0.0000000001 * col, 1) ;
|
---|
61 | return float4(col * color, 1);
|
---|
62 |
|
---|
63 |
|
---|
64 | //return float4(col,1) * 0.0000000000001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x / 32.0, input.texAtlas.y));
|
---|
65 | }
|
---|
66 |
|
---|