- Timestamp:
- 03/07/07 17:37:10 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMapWeightCompute.hlsl
r2188 r2202 3 3 4 4 uniform int nRadionColumns; 5 uniform sampler2D radionSampler : register(s0); 5 uniform sampler2D radionSampler : register(s0); 6 uniform sampler2D entryPointCountSampler : register(s1); 7 uniform sampler2D allWeightsSampler : register(s2); 6 8 uniform float3 lightPos; 7 9 uniform float3 lightDir; 10 uniform float clusterCount; 8 11 9 12 struct vsInputComputeWeights … … 43 46 dist2 = SAMPLECUTDIST2; 44 47 diff = normalize(diff); 45 float cosa = - dot(lightDir, diff);46 float cosb = dot(dir, diff);48 float cosa = max(dot(lightDir, -diff), 0); 49 float cosb = max(dot(dir, diff), 0); 47 50 48 51 /* … … 57 60 float visibility = 1; 58 61 59 float ret; 60 if( visibility < 0.5 || cosa < 0 || cosb < 0) 61 ret = 0.0; 62 float4 ret = cosa * cosb; 63 64 //return float4(lightDir + ret.x * 0.00000000001, 1); 65 return ret; 66 //return ret.x*0.0000000001 + 0.5; 67 } 68 69 float4 psSumWeights(vsOutputComputeWeights input) : COLOR0 70 { 71 float halfPixel = 0.5 / clusterCount; 72 float iCluster = input.tex.x + halfPixel; 73 int entryPointCount = tex2D(entryPointCountSampler, float2(iCluster, 0.25)); 74 int currentEntryPoint = tex2D(entryPointCountSampler, float2(iCluster, 0.75)); 75 //sum entrypoint weights 76 float weight = 0; 77 float clusterRad = 0; 78 for(int i = 0; i < entryPointCount; i++) 79 { 80 float hp = float2(0.5 / (float) nRadionColumns, 0.5 / 4096.0); 81 float2 coord1 = float2((float)(currentEntryPoint % nRadionColumns) / (float) nRadionColumns, 82 currentEntryPoint / (float) nRadionColumns / 4096.0) + hp; 83 coord1.y = 1.0 - coord1.y; 84 float2 coord2 = coord1 + float2(hp.x / 2.0, 0); 85 float radrad = tex2Dlod(radionSampler, float4(coord2, 0, 0)).a; 86 //weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r * radrad; 87 weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r; 88 //clusterRad += radrad; 89 currentEntryPoint++; 90 } 91 /* 92 if(clusterRad >= 0) 93 weight /= clusterRad; 62 94 else 63 ret = pow(cosa, 9) * cosb / dist2; 64 65 if(ret < 0.000001) 66 ret = 0.0; 95 weight = 0;*/ 67 96 68 return 1 + ret * 0.0000000001; 69 return float4(ret, ret, ret, ret); 97 weight /= (float) entryPointCount; 98 99 return weight; 70 100 }
Note: See TracChangeset
for help on using the changeset viewer.