Changeset 1118 for GTP/trunk/App/Demos/Illum/Ogre/Media/materials
- Timestamp:
- 07/11/06 15:47:50 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_DepthShadow.hlsl
r1102 r1118 3 3 { 4 4 float4 hPosition : POSITION; 5 float4 Position : TEXCOORD0;5 float4 Position : TEXCOORD0; 6 6 }; 7 7 8 VS_OUT hDepthVS(float4 position : POSITION, 9 uniform float4x4 worldView, 10 uniform float4x4 worldViewProj) 8 VS_OUT DepthVS(float4 position : POSITION, 9 uniform float4x4 worldViewProj, 10 uniform float4x4 viewProj, 11 uniform float4x4 cameraMatrix) 11 12 { 12 13 13 14 VS_OUT OUT; 15 14 16 OUT.hPosition = mul(worldViewProj, position); 15 OUT.Position = mul( worldView, position);16 OUT.Position.z *= -1.0;17 OUT.Position = mul(viewProj, position); 18 17 19 return OUT; 18 20 } 19 21 20 21 22 //for directional light 22 23 float4 DepthPS(VS_OUT IN ):COLOR 23 24 { 24 float dist = length(IN.Position.xyz);25 return float4(dist, dist, dist, 1);26 //return 1;25 float4 pos = (IN.Position / IN.Position.w); 26 pos = (pos +1.0 ) / 2.0; 27 return pos.z; 27 28 } 28 29 … … 33 34 float4 hPosition : POSITION; 34 35 float4 Position : TEXCOORD0; 35 float4 cPosition : TEXCOORD1;36 float4 lPosition : TEXCOORD1; 36 37 }; 37 38 38 39 VS_OUT_SHADOW depthShadowVS(float4 position : POSITION, 39 uniform float4x4 world, 40 uniform float4x4 worldView, 41 uniform float4x4 worldViewProj) 40 uniform float4x4 worldViewProj, 41 uniform float4x4 lightViewProj) 42 42 { 43 43 VS_OUT_SHADOW OUT; 44 44 OUT.hPosition = mul(worldViewProj, position); 45 OUT. Position = mul(world, position);46 OUT. cPosition = mul(worldView, position);45 OUT.lPosition = mul(lightViewProj, position); 46 OUT.Position = position; 47 47 return OUT; 48 48 } … … 50 50 51 51 float4 depthShadowPS(VS_OUT_SHADOW IN, 52 uniform float4x4 lightView,53 52 uniform float4x4 lightViewProj, 54 uniform float4x4 lightView2, 55 uniform float4x4 lightViewProj2, 56 uniform sampler2D depthShadowMap : register(s0), 57 uniform sampler2D depthShadowMap2 : register(s1)):COLOR 58 { 59 float bias = 0.06; 60 float4 shadowColor = float4(0.6, 0.6, 0.6, 1.0); 61 62 float4 light1 = float4(1,1,1,1); 53 uniform sampler2D depthShadowMap : register(s0) 54 ):COLOR 55 { 56 float bias = 0.001; 57 float4 light = float4(1,1,1,1); 58 float4 shadow = float4(0.3,0.3,0.3,1); 63 59 64 float4 lightCamPos1 = mul(lightView, IN.Position); 65 float d1 = length(lightCamPos1.xyz); 66 float4 lightScreenPos1 = mul(lightViewProj, IN.Position); 67 lightScreenPos1 = lightScreenPos1 / lightScreenPos1.w ; 68 lightScreenPos1 = ( lightScreenPos1 + 1.0 ) / 2.0; 69 lightScreenPos1.y = 1.0 - lightScreenPos1.y; 70 float4 storedDepth1 = tex2D(depthShadowMap, lightScreenPos1.xy); 71 if(storedDepth1.r + bias < d1) 72 light1 = shadowColor; 73 74 75 return light1; 60 float4 pos = (IN.lPosition / IN.lPosition.w); 61 pos = (pos +1.0 ) / 2.0; 62 pos.y = 1.0 - pos.y; 63 float4 storedDepth = tex2D(depthShadowMap, pos.xy); 64 if(storedDepth.r + bias < pos.z) 65 light = shadow; 66 //return abs( pos.z - storedDepth.z ); 67 return light; 76 68 } 77 69 -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.material
r1102 r1118 170 170 pass 171 171 { 172 cull_hardware anticlockwise172 //cull_hardware anticlockwise 173 173 174 174 vertex_program_ref GameTools/ShadowMap/DepthVS 175 175 { 176 param_named_auto worldView worldview_matrix 177 param_named_auto worldViewProj worldviewproj_matrix 178 176 param_named_auto viewProj viewproj_matrix 177 param_named_auto worldViewProj worldviewproj_matrix 179 178 } 180 179 fragment_program_ref GameTools/ShadowMap/DepthPS -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.program
r1102 r1118 228 228 { 229 229 source GameTools_DepthShadow.hlsl 230 entry_point hDepthVS231 target vs_ 1_1230 entry_point DepthVS 231 target vs_3_0 232 232 } 233 233 … … 236 236 source GameTools_DepthShadow.hlsl 237 237 entry_point DepthPS 238 target ps_ 2_0238 target ps_3_0 239 239 240 240 }
Note: See TracChangeset
for help on using the changeset viewer.