Offscreenparticle

  • 1,246 views
Uploaded on

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

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

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,246
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
11
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. High-Speed, Off-Screen Particle GPU gems 3 OZ http://ozlael.egloos.com/
  • 2. Large particle system ● mushroom cloud, smoke, fire, explosio n ... ● Many polygons ● Fill rate ● Frame rate
  • 3. Motivation ● Off-screen Render Target ● Fraction of the Frame Buffer size
  • 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. 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. Off-Screen Depth Testing ● Requires Depth buffer ● Occlude the particles against opaque ● Depth testing ● Off-screen RT size
  • 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. Off-Screen Depth Testing Show how the depth test creates a silhuette of the solid objects
  • 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. Acquiring Depth ● DirectX 10 - Directx access - Shader Resource View
  • 11. Our Engine ● Deferred Render System ● G-Buffer Depth
  • 12. Point Sampling Depth ● Depth test will occlude the particle ● Make halo Low Res. High Res.
  • 13. Point Sampling Depth
  • 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. 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. Depth Testing and Soft Particles ● Access to Depth, useful to Soft Particle ● saturate(( Z object - Z particle) * scale)
  • 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. Alpha Blending
  • 19. Alpha Blending ● Store everything except Frame-buffer d ● d term : multiplied by the inverse of every alpha value blended.
  • 20. Alpha Blending ● s term : If the target is initialized to zero, conventional alpha-blend equation
  • 21. Alpha Blending States ● AlphaBlendEnable = true; ● SrcBlend = SrcAlpha; ● DestBlend = InvSrcAlpha; ● SeparateAlphaBlendEnable = true; ● SrcBlendAlpha = Zero; ● DestBlendAlpha = InvSrcAlpha;
  • 22. Additive Blending ● Common to additively blend particles ● Not be possible to combine both in a sin gle Off-screen RT
  • 23. Mixed -Resolution Rendering ● Still blocky
  • 24. Blocky Problem ● Edges can be fixed with Edge detection. ● Standard Sobel filter
  • 25. Sobel Mask
  • 26. Composing with Stenciling ● Edge-detection selects pixels blocky ● Rendering the particles at the full Frame- buffer resolution only where edges occur.
  • 27. Avoid Stencil Writes, Creating a Mask
  • 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. Result
  • 30. Result Image from : technology.blurst.com/
  • 31. Result This Ignore blocky problem