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 | 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 |
|
---|