Changeset 1629 for GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs
- Timestamp:
- 10/17/06 09:25:48 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_DepthShadow.hlsl
r1131 r1629 21 21 float4 DepthPS(VS_OUT IN ):COLOR 22 22 { 23 //return 1; 23 24 float4 pos = (IN.Position / IN.Position.w); 24 pos = (pos +1.0 ) / 2.0;25 //pos = (pos +1.0 ) / 2.0; 25 26 return float4(pos.z, pos.z * pos.z, 1, 1); 26 27 } … … 48 49 } 49 50 50 51 /* 51 52 float4 depthShadowPS(VS_OUT_SHADOW IN, 52 53 uniform float4x4 lightViewProj, … … 54 55 ):COLOR 55 56 { 56 float bias = 0. 1;57 float bias = 0.0001; 57 58 float4 light = float4(1,1,1,1); 58 float4 shadow = float4(0. 3,0.3,0.3,1);59 float4 shadow = float4(0.6,0.6,0.6,1); 59 60 60 61 float4 pos = (IN.lPosition / IN.lPosition.w); … … 63 64 float4 storedDepth = tex2D(depthShadowMap, pos.xy); 64 65 65 if(storedDepth.r + bias >pos.z)66 if(storedDepth.r + bias < pos.z) 66 67 { 67 68 float M1 = storedDepth.r; … … 76 77 return light; 77 78 } 79 */ 78 80 81 82 float4 depthShadowPS(VS_OUT_SHADOW IN, 83 uniform float4x4 lightViewProj, 84 uniform sampler2D depthShadowMap : register(s0) 85 ):COLOR 86 { 87 float bias = 0.0001; 88 float4 light = float4(1,1,1,1); 89 float4 shadow = float4(0.65,0.65,0.65,1); 90 //float4 shadow = float4(0,0,0,1); 91 92 if(IN.lPosition.z > 0.0) 93 { 94 float4 pos = (IN.lPosition / IN.lPosition.w); 95 pos.xy = (pos.xy + 1.0) / 2.0; 96 97 98 pos.y = 1.0 - pos.y; 99 float4 storedDepth = tex2D(depthShadowMap, pos.xy); 100 101 if(storedDepth.r + bias < pos.z) 102 { 103 light = shadow; 104 } 105 //if(length(pos.xy)>1) 106 // light = shadow; 107 } 108 109 110 return light; 111 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Phong.hlsl
r1611 r1629 60 60 float3 pos = IN.wPos; 61 61 62 float M = 1;62 float M = 4; 63 63 64 64 float3 lightpositions[8]; … … 92 92 L = normalize(L); 93 93 float3 H = normalize(L + V); 94 float lightscale = 1.0;94 float lightscale = 3.0; 95 95 float4 spec = specular * lightcolors[i] * pow(dot(H, N), shininess) * lightscale; 96 96 float4 diff = diffuse * lightcolors[i] * abs(dot(L, N)) * lightscale; … … 103 103 104 104 } 105 106 vertOUT PhongViewSpaceVS(float4 position : POSITION, 107 float3 normal : NORMAL, 108 half3 tangent : TEXCOORD1, 109 float2 texCoord : TEXCOORD0, 110 uniform float4x4 worldViewProj, 111 uniform float4x4 worldView, 112 uniform float4x4 worldViewIT) 113 { 114 vertOUT OUT; 115 OUT.hPos = OUT.hPosition = mul(worldViewProj, position); 116 OUT.wPos = mul(worldView, position).xyz; 117 OUT.mNormal = mul(worldViewIT, normal).xyz; 118 //OUT.mNormal = normal; 119 OUT.texCoord = texCoord; 120 return OUT; 121 } 122 123 float4 PhongTexturedPS( vertOUT IN, 124 uniform float3 cameraPos, 125 uniform float4 lightpos1, 126 uniform float4 lightpos2, 127 uniform float4 lightpos3, 128 uniform float4 lightpos4, 129 uniform float4 lightpos5, 130 uniform float4 lightpos6, 131 uniform float4 lightpos7, 132 uniform float4 lightpos8, 133 uniform float4 lightdir1, 134 uniform float4 lightdir2, 135 uniform float4 lightdir3, 136 uniform float4 lightdir4, 137 uniform float4 lightdir5, 138 uniform float4 lightdir6, 139 uniform float4 lightdir7, 140 uniform float4 lightdir8, 141 uniform float lightscale1, 142 uniform float lightscale2, 143 uniform float lightscale3, 144 uniform float lightscale4, 145 uniform float lightscale5, 146 uniform float lightscale6, 147 uniform float lightscale7, 148 uniform float lightscale8, 149 uniform float4 lightcol1, 150 uniform float4 lightcol2, 151 uniform float4 lightcol3, 152 uniform float4 lightcol4, 153 uniform float4 lightcol5, 154 uniform float4 lightcol6, 155 uniform float4 lightcol7, 156 uniform float4 lightcol8, 157 uniform float4 ambientLight, 158 uniform float shininess, 159 uniform float4 specular, 160 uniform float4 diffuse, 161 uniform float4 ambient, 162 uniform sampler2D colorTexture, 163 uniform float4x4 worldViewIT 164 165 ) : COLOR0 166 { 167 168 169 float3 N = IN.mNormal; 170 //float3 N = mul(worldViewIT, IN.mNormal); 171 N = normalize( N ); 172 float3 pos = IN.wPos; 173 174 float M = 3; 175 176 float4 lightpositions[8]; 177 float4 lightdirs[8]; 178 float4 lightcolors[8]; 179 180 lightpositions[0] = lightpos1; 181 lightpositions[1] = lightpos2; 182 lightpositions[2] = lightpos3; 183 lightpositions[3] = lightpos4; 184 lightpositions[4] = lightpos5; 185 lightpositions[5] = lightpos6; 186 lightpositions[6] = lightpos7; 187 lightpositions[7] = lightpos8; 188 189 lightdirs[0] = lightdir1; 190 lightdirs[1] = lightdir2; 191 lightdirs[2] = lightdir3; 192 lightdirs[3] = lightdir4; 193 lightdirs[4] = lightdir5; 194 lightdirs[5] = lightdir6; 195 lightdirs[6] = lightdir7; 196 lightdirs[7] = lightdir8; 197 198 lightcolors[0] = lightcol1 * lightscale1; 199 lightcolors[1] = lightcol2 * lightscale2; 200 lightcolors[2] = lightcol3 * lightscale3; 201 lightcolors[3] = lightcol4 * lightscale4; 202 lightcolors[4] = lightcol5 * lightscale5; 203 lightcolors[5] = lightcol6 * lightscale6; 204 lightcolors[6] = lightcol7 * lightscale7; 205 lightcolors[7] = lightcol8 * lightscale8; 206 207 float4 texColor = tex2D(colorTexture, IN.texCoord); 208 if(length(texColor)==0)texColor = 1; 209 float4 I = 0; 210 I = texColor * ambientLight * ambient; 211 float maxlightangle = 3.14 / 2.0; 212 for(int i=0; i< M; i++) 213 { 214 float3 V = normalize(cameraPos - pos); 215 float3 L = lightpositions[i].xyz - pos * lightpositions[i].w; 216 float d = length(L); 217 L = normalize(L); 218 float3 H = normalize(L + V); 219 220 float spotscale = 1.0; 221 if( lightdirs[i].w && lightpositions[i].w)//spotlight 222 { 223 float lightangle; 224 lightangle = acos(dot(-L, normalize(lightdirs[i].xyz))); 225 spotscale = 1 - saturate(lightangle / maxlightangle); 226 //spotscale *= spotscale; 227 } 228 229 float4 spec = spotscale * specular * lightcolors[i] * pow(dot(H, N), shininess); 230 float4 diff = spotscale * texColor * diffuse * lightcolors[i] * dot(L, N); 231 I += 1.0 / d / d * (spec + diff); 232 //I+= spotscale; 233 } 234 235 //return texColor; 236 //return float4(N,1); 237 return I; 238 239 } 240 105 241 106 242
Note: See TracChangeset
for help on using the changeset viewer.