Changeset 2179 for GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic
- Timestamp:
- 03/01/07 18:04:37 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.material
r2040 r2179 115 115 } 116 116 } 117 118 material GTP/Basic/Distance_Normalized 119 { 120 technique 121 { 122 pass 123 { 124 cull_hardware clockwise 125 vertex_program_ref GTP/Basic/CPos_VS 126 { 127 param_named_auto WorldViewProj worldviewproj_matrix 128 param_named_auto WorldView worldview_matrix 129 } 130 fragment_program_ref GTP/Basic/CDistNorm_PS 131 { 132 param_named_auto farPlane far_clip_distance 133 } 134 } 135 } 136 } 137 138 material GTP/Basic/Distance_NormalizedCCW : GTP/Basic/Distance_Normalized 139 { 140 technique 0 141 { 142 pass 0 143 { 144 cull_hardware anticlockwise 145 } 146 } 147 } 148 149 material GTP/Basic/ShadowReciever/Depth 150 { 151 technique 152 { 153 pass 154 { 155 lighting off 156 IllumTechniques 157 { 158 RenderTechnique DepthShadowReciever 159 { 160 max_light_count 1 161 vertex_program_name GTP/Basic/LightVPos_VS 162 fragment_program_name GTP/Basic/SM/Depth_PS 163 set_light_view false 164 set_light_farplane false 165 } 166 } 167 } 168 } 169 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.program
r2054 r2179 119 119 } 120 120 121 fragment_program GTP/Basic/CDistNorm_PS hlsl 122 { 123 source GTPBasic_PS.hlsl 124 entry_point CDistNorm 125 target ps_2_0 126 } 127 121 128 fragment_program GTP/Basic/Plain_PS hlsl 122 129 { -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_PS.hlsl
r2024 r2179 28 28 { 29 29 float4 pos = IN.VPosition / IN.VPosition.w; 30 return float4(pos.z, pos.z * pos.z, 1, 1);30 return float4(pos.z, pos.z * pos.z, 0, pos.z); 31 31 } 32 32 … … 39 39 { 40 40 float dist = length(IN.CPos.xyz); 41 return float4(dist, dist * dist, 1, dist); 42 } 43 44 float4 CDistNorm(CPos_OUT IN, 45 uniform float farPlane) : COLOR 46 { 47 float dist = length(IN.CPos.xyz) / farPlane; 41 48 return float4(dist, dist * dist, 1, dist); 42 49 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_VS.hlsl
r2054 r2179 149 149 { 150 150 VPos_OUT OUT; 151 OUT.VPos = OUT. 151 OUT.VPos = OUT.VPosition = mul(WorldViewProj, position); 152 152 return OUT; 153 153 } … … 224 224 LightVPos_OUT LightVPos(float4 position : POSITION0, 225 225 uniform float4x4 WorldViewProj, 226 uniform float4x4 LightWorldViewProj) 226 uniform float4x4 LightViewProj, 227 uniform float4x4 World) 227 228 { 228 229 LightVPos_OUT OUT; 229 230 OUT.VPos = mul(WorldViewProj, position); 230 OUT.LightVPos = mul(LightWorldViewProj, position); 231 float4 WPos = mul(World, position); 232 OUT.LightVPos = mul(LightViewProj, WPos); 231 233 return OUT; 232 234 } … … 242 244 LightCPos_OUT LightCPos(float4 position : POSITION0, 243 245 uniform float4x4 WorldViewProj, 244 uniform float4x4 LightWorldViewProj, 245 uniform float4x4 LightWorldView) 246 uniform float4x4 World, 247 uniform float4x4 LightViewProj, 248 uniform float4x4 LightView) 246 249 { 247 250 LightCPos_OUT OUT; 248 251 OUT.VPos = mul(WorldViewProj, position); 249 OUT.LightVPos = mul(LightWorldViewProj, position); 250 OUT.LightCPos = mul(LightWorldView, position); 251 return OUT; 252 } 252 float4 WPos = mul(World, position); 253 OUT.LightVPos = mul(LightViewProj, WPos); 254 OUT.LightCPos = mul(LightView, WPos); 255 return OUT; 256 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPShadowMap_PS.hlsl
r2024 r2179 15 15 #define DEPTH_BIAS_VSM 0.001 16 16 #define DEPTH_EPSILON 0.001 17 #define DIST_BIAS 0. 00117 #define DIST_BIAS 0.1 18 18 #define DIST_BIAS_VSM 0.001 19 19 #define DIST_EPSILON 0.001 20 20 21 const float4 shadowColor = float4(0.85,0.85,0.85,1); 21 #define shadowColor float4(0.85,0.85,0.85,1) 22 22 23 23 float4 shadowMapDepth(LightVPos_OUT IN, … … 25 25 { 26 26 float4 light = shadowColor; 27 float4 pos = (IN.LightVPos / IN.LightVPos.w); 28 if( pos.z > 0.0) 27 if( IN.LightVPos.z > 0.0) 29 28 { 30 pos.xy = (pos.xy + 1.0) / 2.0; 29 float4 pos = (IN.LightVPos / IN.LightVPos.w); 30 pos.xy = (pos.xy + 1.0) / 2.0; 31 31 pos.y = 1.0 - pos.y; 32 32 float storedDepth = tex2D(shadowMap, pos.xy).r; 33 34 if(pos.z - DEPTH_BIAS <= storedDepth.r) 35 light = 1; 33 pos.z -= DIST_BIAS; 34 light = max(pos.z <= storedDepth.r, shadowColor); 36 35 } 37 38 36 return light; 39 37 } … … 74 72 } 75 73 76 float4 shadowMapDist(LightCPos_OUT IN, 77 uniform sampler2D shadowMap) : COLOR 74 float4 shadowMapDist(LightCPos_OUT IN, 75 //uniform float lightFarPlane, 76 uniform sampler2D shadowMap) : COLOR 78 77 { 79 float4 light = shadowColor; 80 float4 pos = (IN.LightVPos / IN.LightVPos.w); 78 float4 light = shadowColor; 81 79 82 if( pos.z > 0.0)80 if( IN.LightVPos.z > 0.0) 83 81 { 84 //float d = length(pos.xy); 82 float4 pos = (IN.LightVPos / IN.LightVPos.w); 83 //float d = length(pos.xy); 85 84 //light = saturate((1.0 - d)/0.05); 86 85 //if(d <= 1.0) 87 { 88 float dist = length(IN.LightCPos.xyz); 89 pos.xy = (pos.xy + 1.0) / 2.0; 90 pos.y = 1.0 - pos.y; 91 float storedDist = tex2D(shadowMap, pos.xy).r; 92 dist -= DIST_BIAS; 93 94 if(dist <= storedDist); 95 light = 1; 96 } 97 } 98 86 //{ 87 float dist = length(IN.LightCPos.xyz) ; 88 pos.xy = (pos.xy + 1.0) / 2.0; 89 pos.y = 1.0 - pos.y; 90 float4 storedDist = tex2D(shadowMap, pos.xy); 91 dist -= DIST_BIAS; 92 light = max(dist <= storedDist.r, shadowColor); 93 //} 94 } 95 99 96 return light; 100 97 } … … 105 102 { 106 103 float4 light = float4(1,1,1,1); 107 108 float4 pos = (IN.LightVPos / IN.LightVPos.w);109 104 110 if( pos.z > 0.0)105 if( IN.LightVPos.z > 0.0) 111 106 { 112 //float d = length(pos.xy); 113 //light = saturate((1.0 - d)/0.05); 114 //if(d <= 1.0) 107 float4 pos = (IN.LightVPos / IN.LightVPos.w); 108 float d = length(pos.xy); 109 light = saturate((1.0 - d)/0.05); 110 if(d <= 1.0) 115 111 { 116 float dist = length(IN.LightCPos.xyz) / lightFarPlane;117 pos.xy = (pos.xy + 1.0) / 2.0;118 pos.y = 1.0 - pos.y;119 float4 storedDist = tex2D(shadowMap, pos.xy);120 dist -= DIST_BIAS_VSM;121 float lit_factor = light * (dist <= storedDist.r);112 float dist = length(IN.LightCPos.xyz) / lightFarPlane; 113 pos.xy = (pos.xy + 1.0) / 2.0; 114 pos.y = 1.0 - pos.y; 115 float4 storedDist = tex2D(shadowMap, pos.xy); 116 dist -= DIST_BIAS_VSM; 117 float lit_factor = light * (dist <= storedDist.r); 122 118 123 float M1 = storedDist.r;124 float M2 = storedDist.g;125 float v2 = min(max(M2 - M1 * M1, 0.0) + DIST_EPSILON, 1.0);126 float m_d = M1 - dist;119 float M1 = storedDist.r; 120 float M2 = storedDist.g; 121 float v2 = min(max(M2 - M1 * M1, 0.0) + DIST_EPSILON, 1.0); 122 float m_d = M1 - dist; 127 123 float pmax = v2 / (v2 + m_d * m_d); 128 124 129 125 // Adjust the light color based on the shadow attenuation 130 light = max(lit_factor, pmax); 131 132 } 126 light = max(lit_factor, pmax); 127 } 133 128 } 134 129 else
Note: See TracChangeset
for help on using the changeset viewer.