Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Offscreenparticle

1,971 views

Published on

GPU Gems 3 - Chapter 23. High-Speed, Off-Screen Particles

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Offscreenparticle

  1. 1. High-Speed, Off-Screen Particle GPU gems 3 OZ http://ozlael.egloos.com/
  2. 2. Large particle system ● mushroom cloud, smoke, fire, explosio n ... ● Many polygons ● Fill rate ● Frame rate
  3. 3. Motivation ● Off-screen Render Target ● Fraction of the Frame Buffer size
  4. 4. Low-Resolution ● Image of smoke and fog have only low fr equencies ● Small number of samples without loss of visual quality ● Bad to high frequencies
  5. 5. Off-Screen Rendering ● Particles are rendered to an Off-Screen. ● Not require a same size of Frame Buffer. ● Not require a particular ratio of size. ● Trade-off
  6. 6. Off-Screen Depth Testing ● Requires Depth buffer ● Occlude the particles against opaque ● Depth testing ● Off-screen RT size
  7. 7. Off-Screen Depth Testing ● 1. Render all solid objects(a) ● 2. Downsample the resulting Depth Buffer ● 3. Render the particles to Off-screen RT, testing against the small depth buffer(b) ● 4. Composite the particle RT back onto t he main Frame Buffer(c)
  8. 8. Off-Screen Depth Testing Show how the depth test creates a silhuette of the solid objects
  9. 9. Acquiring Depth ● MRT - All targets must have equal bit depths - not compatible with MSAA ● Single RT in a separate pass ● Alpha channel of an RGBA target - Use RGBA16 cause precision problem - Memory footprint - Can’t MSAA on GeForce 7
  10. 10. Acquiring Depth ● DirectX 10 - Directx access - Shader Resource View
  11. 11. Our Engine ● Deferred Render System ● G-Buffer Depth
  12. 12. Point Sampling Depth ● Depth test will occlude the particle ● Make halo Low Res. High Res.
  13. 13. Point Sampling Depth
  14. 14. Maximum of Depth Samples ● Sample a spread of four depth values fro m the full-resolution depth ● Take the maximum one. ● Four samples fully cover the high-res. ● Shrinking the object silhouettes
  15. 15. Depth Testing and Soft Particles ● The Depth Test Implemented in the PS float4 particlePS(VS_OUT vIn): COLOR { float myDepth = vIn.depth; float sceneDepth = tex2D(depthSampler, vIn.screenUV).x; if (myDepth > sceneDepth) discard; // Compute color, etc. ... }
  16. 16. Depth Testing and Soft Particles ● Access to Depth, useful to Soft Particle ● saturate(( Z object - Z particle) * scale)
  17. 17. Depth Testing and Soft Particles ● Soft Particles Are better than float4 particlePS(VS_OUT vIn): COLOR { float myDepth = vIn.depth; float sceneDepth = tex2D(depthSampler, vIn.screenUV).x; float zFade = saturate(scale * (myDepth - sceneDepth)); // Compute (r,g,b,a), etc. ... return float4(r,g,b, a * zFade); }
  18. 18. Alpha Blending
  19. 19. Alpha Blending ● Store everything except Frame-buffer d ● d term : multiplied by the inverse of every alpha value blended.
  20. 20. Alpha Blending ● s term : If the target is initialized to zero, conventional alpha-blend equation
  21. 21. Alpha Blending States ● AlphaBlendEnable = true; ● SrcBlend = SrcAlpha; ● DestBlend = InvSrcAlpha; ● SeparateAlphaBlendEnable = true; ● SrcBlendAlpha = Zero; ● DestBlendAlpha = InvSrcAlpha;
  22. 22. Additive Blending ● Common to additively blend particles ● Not be possible to combine both in a sin gle Off-screen RT
  23. 23. Mixed -Resolution Rendering ● Still blocky
  24. 24. Blocky Problem ● Edges can be fixed with Edge detection. ● Standard Sobel filter
  25. 25. Sobel Mask
  26. 26. Composing with Stenciling ● Edge-detection selects pixels blocky ● Rendering the particles at the full Frame- buffer resolution only where edges occur.
  27. 27. Avoid Stencil Writes, Creating a Mask
  28. 28. Avoid Stencil Writes, Creating a Mask ● Stencil buffer mask areas of FrameBuffer float4 composePS(VS_OUT2 vIn): COLOR { float4 edge = tex2D(edgesSampler, vIn.UV0.xy); if (edge.r == 0.0) { float4 col = tex2D(particlesRTSampler, vIn.UV1.xy); return rgba; } else { // Where we have an edge, abort to cause no stencil write. discard; } }
  29. 29. Result
  30. 30. Result Image from : technology.blurst.com/
  31. 31. Result This Ignore blocky problem

×