Changeset 2425 for GTP/trunk/App/Demos
- Timestamp:
- 06/08/07 01:15:25 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_HPS.hlsl
r2328 r2425 165 165 uniform sampler2D illumVolume : register(s2), 166 166 uniform float farplane, 167 uniform float nearplane 167 uniform float nearplane, 168 uniform float4 color 168 169 ) : COLOR 169 170 { 170 float4 Color = 0;171 float4 Color = IN.Color * color; 171 172 float4 impostor = tex2D(Texture, IN.texCoord); 172 173 float f = 1.0 - impostor.g; … … 192 193 193 194 ///final color 194 Color = float4(1, 1, 1, alpha) * IN.Color; 195 Color.a *= alpha; 196 195 197 return Color; 196 198 -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.material
r2328 r2425 55 55 param_named_auto farplane far_clip_distance 56 56 param_named_auto nearplane near_clip_distance 57 param_named color float4 1 1 1 157 param_named color float4 1 1 1 0.1 58 58 } 59 59 texture_unit … … 70 70 { 71 71 texture planck.tga 72 } 73 } 74 } 75 } 76 77 material GTP/SBB/Illum 78 { 79 technique 80 { 81 pass 82 { 83 IllumTechniques 84 { 85 RenderTechnique SphericalBillboard 86 { 87 texture_unit_id 1 88 } 89 RenderTechnique IllumVolume 90 { 91 material GTP/HPS/Smoke_IllumVolume 92 update_interval 1 93 texture_unit_id 2 94 resolution 128 95 lightmatrix_param_name lightViewProj 96 } 97 } 98 //scene_blend src_alpha one 99 scene_blend src_alpha one_minus_src_alpha 100 depth_write off 101 depth_check off 102 vertex_program_ref GTP/Particles/SBB_Illum_VS 103 { 104 param_named_auto worldView worldview_matrix 105 param_named_auto worldViewInv inverse_worldview_matrix 106 param_named_auto Proj projection_matrix 107 param_named_auto width viewport_width 108 param_named_auto height viewport_height 109 } 110 fragment_program_ref GTP/Particles/SBB_Illum_PS 111 { 112 param_named_auto farplane far_clip_distance 113 param_named_auto nearplane near_clip_distance 114 param_named color float4 1 1 1 0.5 115 } 116 texture_unit 117 { 118 anim_texture smokealpha.tga 32 2.0 119 //texture flare.png 120 } 121 //scene depth texture 122 texture_unit 123 { 124 filtering none 125 } 126 texture_unit 127 { 128 72 129 } 73 130 } … … 168 225 { 169 226 param_named_auto farplane far_clip_distance 170 param_named_auto nearplane near_clip_distance 227 param_named_auto nearplane near_clip_distance 228 param_named color float4 1 1 1 0.5 171 229 } 172 230 //impostor texture -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.particle
r2294 r2425 43 43 44 44 material GTP/HPS/Smoke_L_Depth_Illum 45 // material GTP/HPS/Smoke_L_Depth 46 45 47 particle_width 1.6 46 48 particle_height 1.6 … … 59 61 angle 30 60 62 emission_rate 3 63 time_to_live 10 64 direction 0 1 0 65 velocity 20 66 width 70 67 height 70 68 depth 70 69 } 70 // Make em float upwards 71 // affector LinearForce 72 // { 73 // force_vector 0 40 0 74 // force_application add 75 // } 76 77 affector ColourFader2 78 { 79 alpha1 +0.5 80 alpha2 -0.5 81 state_change 3 82 } 83 } 84 85 GTP/Smoke_Large 86 { 87 renderer sprite 88 89 //material GTP/SBB/Basic 90 material GTP/SBB/Illum 91 92 particle_width 72 93 particle_height 72 94 cull_each false 95 quota 6000 96 sorted true 97 //billboard_type point 98 99 // Area emitter 100 emitter Box 101 { 102 colour 1 1 1 0 103 //colour_range_start 1 1 1 0 104 //colour_range_end 1 1 1 0 105 106 angle 30 107 emission_rate 60 61 108 time_to_live 10 62 109 direction 0 1 0 -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.program
r2328 r2425 28 28 entry_point SBB_Sprite_PS 29 29 target ps_2_0 30 } 31 32 ///spherical billboard sprite programs 33 vertex_program GTP/Particles/SBB_Illum_VS hlsl 34 { 35 source GTP_Sprite.hlsl 36 entry_point SBB_Sprite_Illum_VS 37 target vs_2_0 38 } 39 40 fragment_program GTP/Particles/SBB_Illum_PS hlsl 41 { 42 source GTP_Sprite.hlsl 43 entry_point SBB_Sprite_Illum_PS 44 target ps_3_0 30 45 } 31 46 -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Sprite.hlsl
r2310 r2425 136 136 Color.a *= alpha; 137 137 /// address a color map (colors of fire eg.) with the alpha 138 Color.rgb = tex2D( PlanckMap, Color.aa).rgb;138 //Color.rgb = tex2D( PlanckMap, Color.aa).rgb; 139 139 140 140 return Color * color; 141 141 } 142 142 143 143 struct SBB_ILLUM_VS_OUT 144 { 145 float4 hPosition : POSITION; 146 float4 texCoord : TEXCOORD0; 147 float3 P : TEXCOORD1; 148 float3 Q : TEXCOORD2; 149 float r : TEXCOORD3; 150 float2 screenCoord : TEXCOORD4; 151 float4 lightCoord : TEXCOORD5; 152 float4 color : COLOR0; 153 }; 154 155 SBB_ILLUM_VS_OUT SBB_Sprite_Illum_VS (float4 position : POSITION, 156 float4 texCoord : TEXCOORD0, 157 float4 color : COLOR, 158 uniform float width, 159 uniform float height, 160 uniform float4x4 worldView, 161 uniform float4x4 Proj, 162 uniform float4x4 worldViewInv, 163 uniform float4x4 lightViewProj) 164 { 165 SBB_ILLUM_VS_OUT OUT; 166 ///transform to camera space and create a sprite with vertex offset 167 float2 offset = texCoord.zw; 168 float4 cPosition; 169 float4 wPosition = position; 170 cPosition = mul(worldView, wPosition); 171 /// P is the particle sphere center 172 OUT.P = cPosition.xyz; 173 OUT.P.z = - 1 * OUT.P.z; 174 cPosition.xy += offset; 175 /// Q is the shaded point (it is moved backwards to avoid unwanted frontplane clipping) 176 OUT.Q = cPosition.xyz; 177 OUT.Q.z = OUT.P.z; 178 OUT.r = abs(texCoord.z); 179 /// calculate screen space position 180 OUT.hPosition = mul( Proj, cPosition ); 181 OUT.screenCoord = (OUT.hPosition.xy / OUT.hPosition.w + 1.0) / 2.0; 182 OUT.screenCoord.y = 1.0 - OUT.screenCoord.y; 183 OUT.screenCoord += float2(0.5/width, 0.5/height); 184 185 OUT.texCoord = texCoord; 186 OUT.color = color; 187 188 wPosition = mul(worldViewInv, cPosition); 189 OUT.lightCoord = mul(lightViewProj, wPosition); 190 191 return OUT; 192 } 193 194 195 float4 SBB_Sprite_Illum_PS(SBB_ILLUM_VS_OUT IN , 196 // in screenCoord : VPOS, 197 uniform float nearplane, 198 uniform float farplane, 199 uniform float4 color, 200 uniform sampler2D colorTexture : register(s0), 201 uniform sampler2D DepthMap : register(s1), 202 uniform sampler2D illumVolume : register(s2) 203 ) : COLOR 204 { 205 ///identify light volume slices and interpolation 206 float2 lightCoord; 207 lightCoord = (IN.lightCoord.xy + float2(1.0, 1.0)) / 2.0; 208 lightCoord.y = 1.0 - lightCoord.y; 209 float z = IN.lightCoord.z / IN.lightCoord.w; 210 211 float4 extintion = tex2D(illumVolume, lightCoord); 212 213 float intensities[5]; 214 intensities[0] = 1.0; 215 intensities[1] = extintion.r; 216 intensities[2] = extintion.g; 217 intensities[3] = extintion.b; 218 intensities[4] = extintion.a; 219 220 float3 start; 221 float3 end; 222 float3 temp = 1.0; 223 float t; 224 225 float4 planes = float4(0.33, 0.5, 0.66, 1); 226 if(z < planes.x) 227 { 228 start = intensities[0]; 229 end = intensities[1]; 230 t = z / planes.x; 231 temp = lerp(start, end, t); 232 } 233 if(z > planes.x && z < planes.y) 234 { 235 start = intensities[1]; 236 end = intensities[2]; 237 t = (z - planes.x) / (planes.y - planes.x); 238 temp = lerp(start, end, t); 239 } 240 if(z > planes.y && z < planes.z) 241 { 242 start = intensities[2]; 243 end = intensities[3]; 244 t = (z - planes.y) / (planes.z - planes.y); 245 temp = lerp(start, end, t); 246 } 247 if(z > planes.z) 248 { 249 start = intensities[3]; 250 end = intensities[4]; 251 t = (z - planes.z) / (planes.a - planes.z); 252 temp = lerp(start, end, t); 253 } 254 IN.color.rgb *= temp; 255 /////////////// 256 float4 Color = IN.color; 257 float alpha = 0; 258 259 /// get the depth values from the depthMap and calculate ray length in sphere 260 float d = length( IN.Q - IN.P ); 261 float Zs; 262 if( d < IN.r ) 263 { 264 265 float w = sqrt( IN.r * IN.r - d * d ); 266 alpha = w / IN.r; 267 alpha *= pow( (IN.r-d) / IN.r , 2); 268 269 float F = IN.Q.z - w; 270 float B = IN.Q.z + w; 271 272 273 Zs = tex2D( DepthMap, IN.screenCoord ).r; 274 if(Zs == 0) Zs = farplane; 275 float ds = min( Zs, B ) - max( nearplane, F ); 276 // float ds = min( Zs, B ) - F; 277 alpha *= ds / w * 0.5; 278 279 280 } 281 /// fetch opacity from a texture 282 Color.a *= tex2D( colorTexture, IN.texCoord.xy).r ; 283 //Color.a *= IN.color.a; 284 Color.a *= alpha; 285 /// address a color map (colors of fire eg.) with the alpha 286 //Color.rgb = tex2D( PlanckMap, Color.aa).rgb; 287 288 return Color * color; 289 } 290 291
Note: See TracChangeset
for help on using the changeset viewer.