offscreenparticle
Post on 17-May-2015
1.343 Views
Preview:
DESCRIPTION
TRANSCRIPT
Large particle system
● mushroom cloud, smoke, fire, explosion ...
● Many polygons
● Fill rate
● Frame rate
Motivation
● Off-screen Render Target
● Fraction of the Frame Buffer size
Low-Resolution
● Image of smoke and fog have only low frequencies
● Small number of samples without loss of visual quality
● Bad to high frequencies
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
Off-Screen Depth Testing
● Requires Depth buffer
● Occlude the particles against opaque
● Depth testing
● Off-screen RT size
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 the main Frame Buffer(c)
Off-Screen Depth Testing
Show how the depth test creates a silhuette of the solid objects
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
Acquiring Depth
● DirectX 10
- Directx access
- Shader Resource View
Our Engine
● Deferred Render System
● G-Buffer Depth
Point Sampling Depth
● Depth test will occlude the particle
● Make halo
Low Res.
High Res.
Point Sampling Depth
Maximum of Depth Samples
● Sample a spread of four depth values from the full-resolution depth
● Take the maximum one.
● Four samples fully cover the high-res.
● Shrinking the object silhouettes
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. . . . }
Depth Testing and Soft Particles
● Access to Depth, useful to Soft Particle
● saturate(( Z object - Z particle) * scale)
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); }
Alpha Blending
Alpha Blending
● Store everything except Frame-buffer d
● d term : multiplied by the inverse of every alpha value blended.
Alpha Blending
● s term : If the target is initialized to zero,
conventional alpha-blend equation
Alpha Blending States
● AlphaBlendEnable = true;
● SrcBlend = SrcAlpha;
● DestBlend = InvSrcAlpha;
● SeparateAlphaBlendEnable = true;
● SrcBlendAlpha = Zero;
● DestBlendAlpha = InvSrcAlpha;
Additive Blending
● Common to additively blend particles
● Not be possible to combine both in a single Off-screen RT
Mixed -Resolution Rendering
● Still blocky
Blocky Problem
● Edges can be fixed with Edge detection.
● Standard Sobel filter
Sobel Mask
Composing with Stenciling
● Edge-detection selects pixels blocky
● Rendering the particles at the full Frame-buffer resolution only where edges occur.
Avoid Stencil Writes, Creating a Mask
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; }}
Result
Result
Image from : technology.blurst.com/
Result
This Ignore blocky problem
top related