#define SAMPLECUTDIST2 0.01 #define WEIGHTCUTOFF 0.01 uniform int nRadionColumns; uniform sampler2D radionSampler : register(s0); uniform float3 lightPos; uniform float3 lightDir; struct vsInputComputeWeights { float4 pos : POSITION; float2 tex : TEXCOORD0; }; struct vsOutputComputeWeights { float4 pos : POSITION; float2 tex : TEXCOORD0; }; vsOutputComputeWeights vsComputeWeights(vsInputComputeWeights input) { vsOutputComputeWeights output = (vsOutputComputeWeights)0; output.pos = input.pos; output.tex = input.tex; return output; } float4 psComputeWeights(vsOutputComputeWeights input) : COLOR0 { float dataColumnWidth = 1.0 / (float)nRadionColumns; int bushIndex = input.tex.x * 4096 + input.tex.y * nRadionColumns * 4096; int werx = bushIndex % nRadionColumns; int wery = bushIndex / nRadionColumns; float3 pos = tex2D(radionSampler, float2((werx + 0.25) * dataColumnWidth, (wery + 0.5) / 4096.0) ).xyz; float3 dir = tex2D(radionSampler, float2((werx + 0.75) * dataColumnWidth, (wery + 0.5) / 4096.0) ).xyz; float3 diff = lightPos - pos; float dist2 = dot(diff, diff); if(dist2 < SAMPLECUTDIST2) dist2 = SAMPLECUTDIST2; diff = normalize(diff); float cosa = - dot(lightDir, diff); float cosb = dot(dir, diff); /* float4 occProjPos = mul(float4(pos, 1), occWorldToProjMatrix); occProjPos /= occProjPos.w; float2 occTexPos = mul( occProjPos.xyw, occProjToTexMatrix); float visibility = tex2Dproj(depthMapSampler, float4(occTexPos, occProjPos.z - 0.1, 1) ); float3 lightToPos = pos - lightPos; float actualDepth = length(lightToPos); */ float visibility = 1; float ret; if( visibility < 0.5 || cosa < 0 || cosb < 0) ret = 0.0; else ret = pow(cosa, 9) * cosb / dist2; if(ret < 0.000001) ret = 0.0; return 1 + ret * 0.0000000001; return float4(ret, ret, ret, ret); }