Changeset 2217 for GTP/trunk/App/Demos/Illum/Ogre
- Timestamp:
- 03/09/07 10:31:48 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PRMDemo.material
r2207 r2217 11 11 entry_point psWalk 12 12 target ps_3_0 13 flow_control avoid13 flow_control prefer 14 14 } 15 15 … … 22 22 IllumTechniques 23 23 { 24 RenderTechnique PathMap24 RenderTechnique DepthShadowReciever 25 25 { 26 max_light_count 2 27 vertex_program_name GTP/Basic/LightCPos_VS 28 fragment_program_name GTP/Basic/SM/Dist_VSM_PS 29 set_light_view true 30 set_light_farplane true 31 light_viewproj_param_name LightViewProj 32 light_view_param_name LightView 33 light_farplane_param_name lightFarPlane 34 world_view_proj_param_name WorldViewProj 35 world_param_name World 36 } 37 RenderTechnique PathMap 38 { 26 39 27 40 } … … 30 43 { 31 44 colour_op replace 32 } 33 } 34 45 } 46 } 35 47 } 36 48 } … … 119 131 source PathMapWeightCompute.hlsl 120 132 entry_point psComputeWeights 121 target ps_ 2_0133 target ps_3_0 122 134 } 123 135 … … 141 153 filtering off 142 154 } 155 texture_unit shadow_map //stores distances 156 { 157 158 } 143 159 } 144 160 … … 173 189 texture_unit //entrypoint texture 174 190 { 175 filtering off191 filtering none 176 192 } 177 193 texture_unit //entrypoint weight texture 178 194 { 179 filtering off195 filtering none 180 196 } 181 197 texture_unit //cluster length 182 198 { 183 filtering off199 filtering none 184 200 } 185 201 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMap.hlsl
r2213 r2217 2 2 uniform float4 prmAtlasTilesHalfPixel; 3 3 uniform sampler2D filteredAtlasSampler : register(s0); 4 uniform sampler 1D clusterWeightIndexSampler : register(s1);4 uniform sampler2D clusterWeightIndexSampler : register(s1); 5 5 uniform sampler2D clusterWeightSampler : register(s2); 6 6 uniform float allClusterCount; 7 uniform float clusterCount; //clustercount / 4 8 //uniform float weights[32]; 7 uniform float clusterCount; 9 8 10 9 struct vsInputWalk … … 38 37 39 38 float3 col = 0; 40 for(int iCluster =0; iCluster<16; iCluster++)39 for(int iCluster = 0; iCluster < 32; iCluster++) 41 40 { 42 41 float2 prmTexPos = float2( … … 44 43 1.0 - (input.texAtlas.y + (iCluster / prmAtlasTiles.x)) / prmAtlasTiles.y) + atlasHalfPixel; 45 44 46 //float4 weight = 0.065; 47 //weight = float4(weights[iCluster/4], weights[iCluster/4 + 1],weights[iCluster/4 + 2], weights[iCluster/4 + 3]); 48 //float4 weight = weights[iCluster/4]; 49 float4 weightIndex = tex1D(clusterWeightIndexSampler, ((float)iCluster/4) / clusterCount).r / allClusterCount; 50 float weight1 = tex2D(clusterWeightSampler, float2(weightIndex.r, 0.5)).r; 51 float weight2 = tex2D(clusterWeightSampler, float2(weightIndex.g, 0.5)).r; 52 float weight3 = tex2D(clusterWeightSampler, float2(weightIndex.b, 0.5)).r; 53 float weight4 = tex2D(clusterWeightSampler, float2(weightIndex.a, 0.5)).r; 54 float4 weight = float4(weight1, weight2, weight3, weight4); 55 56 float3 val = tex2D(filteredAtlasSampler, prmTexPos); 57 col += val.xyz * weight.x; 58 iCluster++; 59 60 prmTexPos.x += 1.0 / prmAtlasTiles.x; 61 val = tex2D(filteredAtlasSampler, prmTexPos); 62 col += val.xyz * weight.y; 63 iCluster++; 64 65 prmTexPos.x += 1.0 / prmAtlasTiles.x; 66 val = tex2D(filteredAtlasSampler, prmTexPos); 67 col += val.xyz * weight.z; 68 iCluster++; 69 70 prmTexPos.x += 1.0 / prmAtlasTiles.x; 71 val = tex2D(filteredAtlasSampler, prmTexPos); 72 col += val.xyz * weight.w; 45 float weightIndex = tex2D(clusterWeightIndexSampler, float2(((float)iCluster + 0.5) / clusterCount, 0.5)).r; 46 float weight = tex2D(clusterWeightSampler, float2((weightIndex + 0.5)/allClusterCount, 0.5)).r; 47 //weight = 0.0002 + 0.000000000001 * weight; 48 float3 val = tex2D(filteredAtlasSampler, prmTexPos).xyz; 49 col += val.xyz * weight; 73 50 } 74 51 75 //return col.xxxx *0.00001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x /32.0f, 1.0 - input.texAtlas.y)); 76 //return float4(1,0,0,1)+col.xxxx*0.0000000001; 77 //return prmAtlasTilesHalfPixel.x*allClusterCount*clusterCount*0.000000000001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x /32.0f, 1.0 - input.texAtlas.y)).r; 78 return float4(col * 200, 1); 52 return float4(col * 300, 1); 79 53 } 80 54 -
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 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPShadowMap_PS.hlsl
r2186 r2217 15 15 #define DEPTH_BIAS_VSM 0.001 16 16 #define DEPTH_EPSILON 0.00005 17 #define DIST_BIAS 0. 118 #define DIST_BIAS_VSM 0.00 117 #define DIST_BIAS 0.005 18 #define DIST_BIAS_VSM 0.005 19 19 #define DIST_EPSILON 0.001 20 20 21 #define shadowColor float4(0. 2,0.2,0.2,1)21 #define shadowColor float4(0.5,0.5,0.5,1) 22 22 23 23 float4 shadowMapDepth(LightVPos_OUT IN, … … 78 78 { 79 79 float4 pos = (IN.LightVPos / IN.LightVPos.w); 80 //float d = length(pos.xy);81 //light = saturate((1.0 - d)/0.05);82 //if(d <= 1.0)83 //{80 float d = length(pos.xy); 81 light = saturate((1.0 - d)/0.05); 82 if(d <= 1.0) 83 { 84 84 float dist = length(IN.LightCPos.xyz) / lightFarPlane; 85 85 pos.xy = (pos.xy + 1.0) / 2.0; … … 88 88 dist -= DIST_BIAS; 89 89 light = max(dist <= storedDist.r, shadowColor); 90 //}90 } 91 91 } 92 92
Note: See TracChangeset
for help on using the changeset viewer.