- Timestamp:
- 07/02/07 04:04:08 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.hlsl
r2337 r2471 443 443 return kd * I; 444 444 } 445 446 float4 Glossy_Disc2Point_PS(Shaded_OUT IN, 447 uniform float3 lastCenter, 448 uniform float3 cameraPos, 449 uniform samplerCUBE SmallEnvMapSampler : register(s0), 450 uniform samplerCUBE DistanceEnvMapSampler : register(s1) 451 ) : COLOR0 452 { 453 float M = REDUCED_CUBEMAP_SIZE; 454 455 float3 N = IN.wNormal.xyz; 456 N = normalize( N ); 457 float3 V = normalize(IN.wPos.xyz - cameraPos); 458 float3 pos = IN.wPos.xyz - lastCenter; 459 float3 R = reflect( V, N ); 460 461 float rr = max( max(abs(R.x), abs(R.y)), abs(R.z) ); // select the largest component 462 R /= rr; // scale the largest component to value +/-1 463 464 float3 offset1 = float3(1,0,0); 465 float3 offset2 = float3(0,1,0); 466 if (abs(R.x) > abs(R.y) && abs(R.x) > abs(R.z)) 467 offset1 = float3(0,0,1); 468 if (abs(R.y) > abs(R.x) && abs(R.y) > abs(R.z)) 469 offset2 = float3(0,0,1); 470 471 472 float4 I = 0; 473 float3 L; 474 float width = 2.0 / M; 475 476 L = R; 477 I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 478 479 L = R + offset1 * width; 480 I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 481 482 L = R - offset1 * width; 483 I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 484 485 L = R + offset2 * width; 486 I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 487 488 L = R - offset2 * width; 489 I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 490 491 492 float kd = 1.0; 493 //return readCubeMap(SmallEnvMapSampler, pos) + lastCenter.x*0.0000000001; 494 return kd * I * 2 * M; 495 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.material
r2445 r2471 138 138 material GTP/Diffuse/Disc2Point 139 139 { 140 technique 141 { 142 pass 143 { 144 145 IllumTechniques 146 { 147 148 RenderTechnique DistanceCubeMap 149 { 150 update_interval 0 151 update_all_face true 152 distance_calc false 153 face_angle_calc false 154 resolution 128 155 } 156 RenderTechnique ReducedColorCubeMap 157 { 158 update_interval 1 159 reduced_resolution 4 160 resolution 128 161 distance_calc false 162 face_angle_calc false 163 update_all_face true 164 } 165 } 166 167 vertex_program_ref GTP/Basic/Shaded_VS 168 { 169 param_named_auto WorldViewProj worldviewproj_matrix 170 param_named_auto WorldInv inverse_world_matrix 171 param_named_auto World world_matrix 172 173 } 174 fragment_program_ref GTP/Diffuse/Disc2Point_PS 175 { 176 param_named_auto cameraPos camera_position 177 param_named lastCenter float3 0 0 0 178 } 179 //Cube map for reflections and refractions 180 texture_unit 181 { 182 183 } 184 //Cube map of distances 185 texture_unit 186 { 187 188 } 189 } 190 } 191 } 192 193 material GTP/Glossy/Disc2Point 194 { 140 195 technique 141 196 { … … 148 203 RenderTechnique DistanceCubeMap 149 204 { 150 update_interval 1151 update_all_face false152 distance_calc false 153 face_angle_calc false 154 resolution 128 155 } 156 RenderTechnique ReducedColorCubeMap 157 { 158 update_interval 1 159 reduced_resolution 4 160 resolution 128 161 distance_calc false 162 face_angle_calc false 163 update_all_face false164 } 165 } 166 167 vertex_program_ref GTP/Basic/Shaded_VS 168 { 169 param_named_auto WorldViewProj worldviewproj_matrix 170 param_named_auto WorldInv inverse_world_matrix 171 param_named_auto World world_matrix 172 173 } 174 fragment_program_ref GTP/ Diffuse/Disc2Point_PS205 update_interval 0 206 update_all_face true 207 distance_calc false 208 face_angle_calc false 209 resolution 128 210 } 211 RenderTechnique ReducedColorCubeMap 212 { 213 update_interval 1 214 reduced_resolution 4 215 resolution 128 216 distance_calc false 217 face_angle_calc false 218 update_all_face true 219 } 220 } 221 222 vertex_program_ref GTP/Basic/Shaded_VS 223 { 224 param_named_auto WorldViewProj worldviewproj_matrix 225 param_named_auto WorldInv inverse_world_matrix 226 param_named_auto World world_matrix 227 228 } 229 fragment_program_ref GTP/Glossy/Disc2Point_PS 175 230 { 176 231 param_named_auto cameraPos camera_position -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.program
r2337 r2471 23 23 } 24 24 25 fragment_program GTP/Glossy/Disc2Point_PS hlsl 26 { 27 source GTPDiffuse.hlsl 28 entry_point Glossy_Disc2Point_PS 29 target ps_3_0 30 //flow_control prefer 31 } 32 25 33 fragment_program GTP/Diffuse/ReduceCubeMap_PS hlsl 26 34 { -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.hlsl
r2368 r2471 62 62 63 63 float3 R = refract(V, wNormal, refIndex); 64 64 if(dot(R,R) == 0) 65 R = reflect(V, wNormal); 66 65 67 dir = R; 66 68 dir = Hit(cubeMapPos, R, DistanceMap); … … 140 142 IN.color = CausticColor; 141 143 float intens = tex2D(intensityTex, IN.texCoord).r; 142 IN.color.a *= intens; 144 //IN.color.a *= intens; 145 IN.color *= IN.color.a * intens; 146 IN.color.a = IN.dist; 143 147 return IN.color; 144 148 } … … 149 153 { 150 154 float4 hPosition : POSITION; 151 float4 color : COLOR0; 155 float4 color : COLOR0; 156 float dist : TEXCOORD0; 152 157 }; 153 158 … … 231 236 OUT.color = float4(1,1,1,1); 232 237 } 233 238 239 OUT.dist = length(pos.xyz); 234 240 return OUT; 235 241 } … … 238 244 uniform float4 CausticColor ):COLOR 239 245 { 240 return IN.color * CausticColor; 246 247 return float4(IN.color.rgb * CausticColor.rgb * IN.color.a, IN.dist); 241 248 } 242 249 -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.material
r2368 r2471 33 33 { 34 34 cull_hardware none 35 scene_blend src_alpha one 35 scene_blend one one 36 scene_blend_alpha one zero 36 37 depth_check off 37 38 point_sprites on … … 65 66 { 66 67 cull_hardware none 67 scene_blend src_alpha one 68 scene_blend one one 69 scene_blend_alpha one zero 68 70 depth_write off 69 71 vertex_program_ref GTP/Caustic/CauCube_Triangles_VS -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPEnvMap/GTPEnvMap.hlsl
r2409 r2471 13 13 } 14 14 15 #define SECANT_ITERATIONCOUNT 2 15 #define SECANT_ITERATIONCOUNT 20 16 16 17 17 float3 Hit( float3 x, float3 R, samplerCUBE mp ) … … 91 91 uniform float sRefraction ) :COLOR0 92 92 { 93 float4 Color = 0; 93 94 float3 N = normalize(IN.wNormal.xyz); 94 95 float3 RR, TT; … … 97 98 float3 R = reflect( V, N); 98 99 float3 T = refract(V, N, sRefraction); 99 100 101 100 102 RR = R; TT = T; 101 103 RR = Hit(cubePos, R, DistanceMap); 102 TT = Hit(cubePos, T, DistanceMap);104 float4 reflectcolor = readCubeMap(CubeMap, RR ); 103 105 104 float4 reflectcolor = readCubeMap(CubeMap, RR ); 105 float4 refractcolor = readCubeMap(CubeMap, TT ); 106 if(dot(T,T)!=0) 107 { 108 TT = Hit(cubePos, T, DistanceMap); 109 float4 refractcolor = readCubeMap(CubeMap, TT ); 106 110 107 float cos_theta = -dot(V, N); 108 float F = (sFresnel + pow(1 - cos_theta, 5.0f) * (1 - sFresnel)); 109 110 return (F * reflectcolor + (1 - F) * refractcolor); 111 float cos_theta = -dot(V, N); 112 float F = (sFresnel + pow(1 - cos_theta, 5.0f) * (1 - sFresnel)); 113 F = saturate(F); 114 Color = (F * reflectcolor + (1 - F) * refractcolor); 115 } 116 else 117 { 118 Color = reflectcolor; 119 } 120 return Color; 111 121 } 112 122
Note: See TracChangeset
for help on using the changeset viewer.