1 | uniform float4x4 WorldViewProj;
|
---|
2 | uniform float4 prmAtlasTilesHalfPixel;
|
---|
3 | uniform sampler2D filteredAtlasSampler : register(s0);
|
---|
4 | uniform float weights[32];
|
---|
5 |
|
---|
6 | struct vsInputWalk
|
---|
7 | {
|
---|
8 | float4 pos : POSITION;
|
---|
9 | float2 tex : TEXCOORD0;
|
---|
10 | float2 texAtlas : TEXCOORD1;
|
---|
11 | };
|
---|
12 |
|
---|
13 | struct vsOutputWalk
|
---|
14 | {
|
---|
15 | float4 pos : POSITION;
|
---|
16 | float2 tex : TEXCOORD0;
|
---|
17 | float2 texAtlas : TEXCOORD1;
|
---|
18 | };
|
---|
19 |
|
---|
20 |
|
---|
21 | vsOutputWalk vsWalk(vsInputWalk input)
|
---|
22 | {
|
---|
23 | vsOutputWalk output = (vsOutputWalk)0;
|
---|
24 | output.pos = mul(WorldViewProj, input.pos);
|
---|
25 | output.tex = input.tex;
|
---|
26 | output.texAtlas = input.texAtlas;
|
---|
27 | return output;
|
---|
28 | }
|
---|
29 |
|
---|
30 | float4 psWalk(vsOutputWalk input) : COLOR
|
---|
31 | {
|
---|
32 | int2 prmAtlasTiles = prmAtlasTilesHalfPixel.xy;
|
---|
33 | float2 atlasHalfPixel = prmAtlasTilesHalfPixel.zw;
|
---|
34 |
|
---|
35 | float3 col = 0;
|
---|
36 | for(int iCluster=0; iCluster<16; iCluster++)
|
---|
37 | {
|
---|
38 | float2 prmTexPos = float2(
|
---|
39 | (input.texAtlas.x + (iCluster % prmAtlasTiles.x)) / prmAtlasTiles.x,
|
---|
40 | 1.0 - (input.texAtlas.y + (iCluster / prmAtlasTiles.x)) / prmAtlasTiles.y) + atlasHalfPixel;
|
---|
41 |
|
---|
42 | float4 weight = 0.065;
|
---|
43 | float3 val = tex2D(filteredAtlasSampler, prmTexPos);
|
---|
44 | col += val.xyz * weight.x;
|
---|
45 | iCluster++;
|
---|
46 |
|
---|
47 | prmTexPos.x += 1.0 / prmAtlasTiles.x;
|
---|
48 | val = tex2D(filteredAtlasSampler, prmTexPos);
|
---|
49 | col += val.xyz * weight.y;
|
---|
50 | iCluster++;
|
---|
51 |
|
---|
52 | prmTexPos.x += 1.0 / prmAtlasTiles.x;
|
---|
53 | val = tex2D(filteredAtlasSampler, prmTexPos);
|
---|
54 | col += val.xyz * weight.z;
|
---|
55 | iCluster++;
|
---|
56 |
|
---|
57 | prmTexPos.x += 1.0 / prmAtlasTiles.x;
|
---|
58 | val = tex2D(filteredAtlasSampler, prmTexPos);
|
---|
59 | col += val.xyz * weight.w;
|
---|
60 | }
|
---|
61 |
|
---|
62 | //return col.xxxx *0.00001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x /32.0f, 1.0 - input.texAtlas.y));
|
---|
63 | //return float4(1,0,0,1)+col.xxxx*0.0000000001;
|
---|
64 | return float4(col, 1);
|
---|
65 | }
|
---|
66 |
|
---|