- Timestamp:
- 03/09/07 10:31:48 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMapWeightCompute.hlsl
r2213 r2217 1 1 #define SAMPLECUTDIST2 0.01 2 #define WEIGHTCUTOFF 0.01 2 #define WEIGHTCUTOFF 0.01 3 #define DIST_BIAS 0.005 3 4 4 5 uniform int nRadionColumns; 5 uniform sampler2D radionSampler : register(s0);6 uniform sampler2D entryPointCountSampler : register(s1);7 uniform sampler2D allWeightsSampler : register(s2);8 6 uniform float3 lightPos; 9 7 uniform float3 lightDir; 10 8 uniform float clusterCount; 9 uniform float4x4 lightViewProj; 10 uniform float lightFarPlane; 11 11 12 12 struct vsInputComputeWeights … … 28 28 output.pos = input.pos; 29 29 output.tex = (input.pos + 1.0) / 2.0; 30 //output.tex = input.tex; 30 31 output.tex.y = 1.0 - output.tex.y; 32 31 33 return output; 32 34 } 33 35 34 float4 psComputeWeights(vsOutputComputeWeights input) : COLOR0 36 float4 psComputeWeights(vsOutputComputeWeights input, 37 uniform sampler2D radionSampler : register(s0), 38 uniform sampler2D shadowMap : register(s1)) : COLOR0 35 39 { 36 40 float dataColumnWidth = 1.0 / (float)nRadionColumns; … … 49 53 float cosb = max(dot(dir, diff), 0); 50 54 51 /* 52 float4 occProjPos = mul(float4(pos, 1), occWorldToProjMatrix); 53 occProjPos /= occProjPos.w; 54 float2 occTexPos = mul( occProjPos.xyw, occProjToTexMatrix); 55 float visibility = tex2Dproj(depthMapSampler, float4(occTexPos, occProjPos.z - 0.1, 1) ); 55 56 float4 lightVPos = mul(lightViewProj, float4(pos,1)); 57 float dist = sqrt(dist2) / lightFarPlane; 58 lightVPos /= lightVPos.w; 59 lightVPos.xy = (lightVPos.xy + 1.0) / 2.0; 60 lightVPos.y = 1.0 - lightVPos.y; 61 float storedDist = tex2D(shadowMap, lightVPos.xy).r; 62 dist -= DIST_BIAS; 63 float visibility = (dist <= storedDist); 56 64 57 float3 lightToPos = pos - lightPos; 58 float actualDepth = length(lightToPos); 59 */ 60 float visibility = 1; 65 //float visibility = 1; 66 //visibility = visibility * 0.00001 + 1.0; 61 67 62 float4 ret = pow(cosa, 9) * cosb / dist2; 63 64 //float ize = 0; 65 //if(pos.y > 0) ize = 1; 66 //return float4(lightDir + ret.x * 0.00000000001, 1); 67 //return ret; 68 float4 ret = visibility * pow(cosa, 9) * cosb / dist2; 68 69 return ret; 69 70 } 70 71 71 float4 psSumWeights(vsOutputComputeWeights input) : COLOR0 72 float4 psSumWeights(vsOutputComputeWeights input, 73 uniform sampler2D radionSampler : register(s0), 74 uniform sampler2D entryPointCountSampler : register(s1), 75 uniform sampler2D allWeightsSampler : register(s2)) : COLOR0 72 76 { 73 77 float halfPixel = 0.5 / clusterCount; … … 80 84 for(int i = 0; i < entryPointCount; i++) 81 85 { 82 float hp = float2(0.5 / (float) nRadionColumns, 0.5 / 4096.0); 83 float2 coord1 = float2((float)(currentEntryPoint % nRadionColumns) / (float) nRadionColumns, 84 currentEntryPoint / (float) nRadionColumns / 4096.0) + hp; 85 float2 coord2 = coord1 + float2(hp.x / 2.0, 0); 86 float radrad = tex2Dlod(radionSampler, float4(coord2, 0, 0)).a; 87 //weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r * radrad; 88 weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r; 86 87 float dataColumnWidth = 1.0 / (float)nRadionColumns; 88 int werx = currentEntryPoint % nRadionColumns; 89 int wery = currentEntryPoint / nRadionColumns; 90 float2 coord1 = float2((werx + 0.5) * dataColumnWidth, (wery + 0.5) / 4096.0); 91 float2 coord2 = coord1 + float2(0.25 * dataColumnWidth, 0); 92 float w = tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r; 93 float radrad = tex2Dlod(radionSampler, float4(coord1, 0, 0)).a; 94 weight += w * radrad; 89 95 clusterRad += radrad; 90 96 currentEntryPoint++; 91 97 } 92 98 93 /*if(clusterRad >= 0)99 if(clusterRad >= 0) 94 100 weight /= clusterRad; 95 101 else 96 weight = 0;*/ 97 98 weight /= (float) entryPointCount; 99 102 weight = 0; 103 100 104 return weight; 101 105 }
Note: See TracChangeset
for help on using the changeset viewer.