uniform float4x4 WorldViewProj; uniform float4 prmAtlasTilesHalfPixel; uniform sampler2D filteredAtlasSampler : register(s0); uniform sampler1D clusterWeightIndexSampler : register(s1); uniform sampler2D clusterWeightSampler : register(s2); uniform float allClusterCount; uniform float clusterCount; //clustercount / 4 //uniform float weights[32]; struct vsInputWalk { float4 pos : POSITION; float2 tex : TEXCOORD0; float2 texAtlas : TEXCOORD1; }; struct vsOutputWalk { float4 pos : POSITION; float2 tex : TEXCOORD0; float2 texAtlas : TEXCOORD1; }; vsOutputWalk vsWalk(vsInputWalk input) { vsOutputWalk output = (vsOutputWalk)0; output.pos = mul(WorldViewProj, input.pos); output.tex = input.tex; output.texAtlas = input.texAtlas; return output; } float4 psWalk(vsOutputWalk input) : COLOR { int2 prmAtlasTiles = prmAtlasTilesHalfPixel.xy; float2 atlasHalfPixel = prmAtlasTilesHalfPixel.zw; float3 col = 0; for(int iCluster=0; iCluster<16; iCluster++) { float2 prmTexPos = float2( (input.texAtlas.x + (iCluster % prmAtlasTiles.x)) / prmAtlasTiles.x, 1.0 - (input.texAtlas.y + (iCluster / prmAtlasTiles.x)) / prmAtlasTiles.y) + atlasHalfPixel; //float4 weight = 0.065; //weight = float4(weights[iCluster/4], weights[iCluster/4 + 1],weights[iCluster/4 + 2], weights[iCluster/4 + 3]); //float4 weight = weights[iCluster/4]; float4 weightIndex = tex1D(clusterWeightIndexSampler, ((float)iCluster/4) / clusterCount).r / allClusterCount; float weight1 = tex2D(clusterWeightSampler, float2(weightIndex.r, 0.5)).r; float weight2 = tex2D(clusterWeightSampler, float2(weightIndex.g, 0.5)).r; float weight3 = tex2D(clusterWeightSampler, float2(weightIndex.b, 0.5)).r; float weight4 = tex2D(clusterWeightSampler, float2(weightIndex.a, 0.5)).r; float4 weight = float4(weight1, weight2, weight3, weight4); float3 val = tex2D(filteredAtlasSampler, prmTexPos); col += val.xyz * weight.x; iCluster++; prmTexPos.x += 1.0 / prmAtlasTiles.x; val = tex2D(filteredAtlasSampler, prmTexPos); col += val.xyz * weight.y; iCluster++; prmTexPos.x += 1.0 / prmAtlasTiles.x; val = tex2D(filteredAtlasSampler, prmTexPos); col += val.xyz * weight.z; iCluster++; prmTexPos.x += 1.0 / prmAtlasTiles.x; val = tex2D(filteredAtlasSampler, prmTexPos); col += val.xyz * weight.w; } //return col.xxxx *0.00001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x /32.0f, 1.0 - input.texAtlas.y)); //return float4(1,0,0,1)+col.xxxx*0.0000000001; //return prmAtlasTilesHalfPixel.x*allClusterCount*clusterCount*0.000000000001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x /32.0f, 1.0 - input.texAtlas.y)).r; return float4(col, 1); }