SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
High-Speed, Off-Screen Particle
             GPU gems 3




                  OZ
      http://ozlael.egloos.com/
Large particle system
●   mushroom cloud, smoke, fire, explosio
    n ...
●
    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 fr
    equencies
●   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 t
    he 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 fro
    m 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 sin
    gle 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

Weitere ähnliche Inhalte

Andere mochten auch (18)

latest slide
latest slidelatest slide
latest slide
 
Artificial intelligence prelims - answers
Artificial intelligence   prelims - answersArtificial intelligence   prelims - answers
Artificial intelligence prelims - answers
 
latest slide
latest slidelatest slide
latest slide
 
Semiología respiratoria imágenes
Semiología respiratoria imágenesSemiología respiratoria imágenes
Semiología respiratoria imágenes
 
Syllabus: 8th grade science
Syllabus: 8th grade scienceSyllabus: 8th grade science
Syllabus: 8th grade science
 
Youtube: ver, partilhar, carregar
Youtube: ver, partilhar, carregarYoutube: ver, partilhar, carregar
Youtube: ver, partilhar, carregar
 
Sw203 Lab4
Sw203 Lab4Sw203 Lab4
Sw203 Lab4
 
Krzyzanowski Photography - Food Portfolio
Krzyzanowski Photography - Food PortfolioKrzyzanowski Photography - Food Portfolio
Krzyzanowski Photography - Food Portfolio
 
Greenthan
GreenthanGreenthan
Greenthan
 
Enviroment Eco cars
Enviroment Eco carsEnviroment Eco cars
Enviroment Eco cars
 
Folio1
Folio1Folio1
Folio1
 
Rain Garden
Rain GardenRain Garden
Rain Garden
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
scout
scoutscout
scout
 
before upload
before uploadbefore upload
before upload
 
No Panic workshop
No Panic workshopNo Panic workshop
No Panic workshop
 
Instrumentos
InstrumentosInstrumentos
Instrumentos
 
first pitch
first pitchfirst pitch
first pitch
 

Ähnlich wie Offscreenparticle

Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
changehee lee
 
Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)
Tiago Sousa
 
Z Buffer Optimizations
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizations
pjcozzi
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
anku2266
 
NVIDIA effects GDC09
NVIDIA effects GDC09NVIDIA effects GDC09
NVIDIA effects GDC09
IGDA_London
 
Shaders in Unity by Zoel
Shaders in Unity by ZoelShaders in Unity by Zoel
Shaders in Unity by Zoel
Agate Studio
 

Ähnlich wie Offscreenparticle (20)

Real-time Shadowing Techniques: Shadow Volumes
Real-time Shadowing Techniques: Shadow VolumesReal-time Shadowing Techniques: Shadow Volumes
Real-time Shadowing Techniques: Shadow Volumes
 
Advancements in-tiled-rendering
Advancements in-tiled-renderingAdvancements in-tiled-rendering
Advancements in-tiled-rendering
 
GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11
 
Screen Space Reflections in The Surge
Screen Space Reflections in The SurgeScreen Space Reflections in The Surge
Screen Space Reflections in The Surge
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
 
Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
 
Checkerboard Rendering in Dark Souls: Remastered by QLOC
Checkerboard Rendering in Dark Souls: Remastered by QLOCCheckerboard Rendering in Dark Souls: Remastered by QLOC
Checkerboard Rendering in Dark Souls: Remastered by QLOC
 
Foveated Ray Tracing for VR on Multiple GPUs
Foveated Ray Tracing for VR on Multiple GPUsFoveated Ray Tracing for VR on Multiple GPUs
Foveated Ray Tracing for VR on Multiple GPUs
 
Rendering Tech of Space Marine
Rendering Tech of Space MarineRendering Tech of Space Marine
Rendering Tech of Space Marine
 
Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics Technology
 
iOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLiOS Visual F/X Using GLSL
iOS Visual F/X Using GLSL
 
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
 
Z Buffer Optimizations
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizations
 
Massive Point Light Soft Shadows
Massive Point Light Soft ShadowsMassive Point Light Soft Shadows
Massive Point Light Soft Shadows
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
[Unite Seoul 2020] Mobile Graphics Best Practices for Artists
[Unite Seoul 2020] Mobile Graphics Best Practices for Artists[Unite Seoul 2020] Mobile Graphics Best Practices for Artists
[Unite Seoul 2020] Mobile Graphics Best Practices for Artists
 
NVIDIA effects GDC09
NVIDIA effects GDC09NVIDIA effects GDC09
NVIDIA effects GDC09
 
Shaders in Unity by Zoel
Shaders in Unity by ZoelShaders in Unity by Zoel
Shaders in Unity by Zoel
 
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next Generation
 

Mehr von ozlael ozlael

Introduce coco2dx with cookingstar
Introduce coco2dx with cookingstarIntroduce coco2dx with cookingstar
Introduce coco2dx with cookingstar
ozlael ozlael
 
Deferred rendering case study
Deferred rendering case studyDeferred rendering case study
Deferred rendering case study
ozlael ozlael
 
Kgc make stereo game on pc
Kgc make stereo game on pcKgc make stereo game on pc
Kgc make stereo game on pc
ozlael ozlael
 
Hable uncharted2(siggraph%202010%20 advanced%20realtime%20rendering%20course)
Hable uncharted2(siggraph%202010%20 advanced%20realtime%20rendering%20course)Hable uncharted2(siggraph%202010%20 advanced%20realtime%20rendering%20course)
Hable uncharted2(siggraph%202010%20 advanced%20realtime%20rendering%20course)
ozlael ozlael
 

Mehr von ozlael ozlael (20)

Unity & VR (Unity Roadshow 2016)
Unity & VR (Unity Roadshow 2016)Unity & VR (Unity Roadshow 2016)
Unity & VR (Unity Roadshow 2016)
 
뭣이 중헌디? 성능 프로파일링도 모름서 - 유니티 성능 프로파일링 가이드 (IGC16)
뭣이 중헌디? 성능 프로파일링도 모름서 - 유니티 성능 프로파일링 가이드 (IGC16)뭣이 중헌디? 성능 프로파일링도 모름서 - 유니티 성능 프로파일링 가이드 (IGC16)
뭣이 중헌디? 성능 프로파일링도 모름서 - 유니티 성능 프로파일링 가이드 (IGC16)
 
Optimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark HarknessOptimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark Harkness
 
그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...
그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...
그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...
 
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver.
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver.유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver.
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver.
 
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) NDC15 Ver.
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) NDC15 Ver.유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) NDC15 Ver.
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) NDC15 Ver.
 
Infinity Blade and beyond
Infinity Blade and beyondInfinity Blade and beyond
Infinity Blade and beyond
 
스티브잡스처럼 프레젠테이션하기
스티브잡스처럼 프레젠테이션하기스티브잡스처럼 프레젠테이션하기
스티브잡스처럼 프레젠테이션하기
 
유니티의 라이팅이 안 이쁘다구요? (A to Z of Lighting)
유니티의 라이팅이 안 이쁘다구요? (A to Z of Lighting)유니티의 라이팅이 안 이쁘다구요? (A to Z of Lighting)
유니티의 라이팅이 안 이쁘다구요? (A to Z of Lighting)
 
Introduce coco2dx with cookingstar
Introduce coco2dx with cookingstarIntroduce coco2dx with cookingstar
Introduce coco2dx with cookingstar
 
Deferred rendering case study
Deferred rendering case studyDeferred rendering case study
Deferred rendering case study
 
Kgc make stereo game on pc
Kgc make stereo game on pcKgc make stereo game on pc
Kgc make stereo game on pc
 
mssao presentation
mssao presentationmssao presentation
mssao presentation
 
Modern gpu optimize blog
Modern gpu optimize blogModern gpu optimize blog
Modern gpu optimize blog
 
Modern gpu optimize
Modern gpu optimizeModern gpu optimize
Modern gpu optimize
 
Bickerstaff benson making3d games on the playstation3
Bickerstaff benson making3d games on the playstation3Bickerstaff benson making3d games on the playstation3
Bickerstaff benson making3d games on the playstation3
 
DOF Depth of Field
DOF Depth of FieldDOF Depth of Field
DOF Depth of Field
 
Hable uncharted2(siggraph%202010%20 advanced%20realtime%20rendering%20course)
Hable uncharted2(siggraph%202010%20 advanced%20realtime%20rendering%20course)Hable uncharted2(siggraph%202010%20 advanced%20realtime%20rendering%20course)
Hable uncharted2(siggraph%202010%20 advanced%20realtime%20rendering%20course)
 
Deferred rendering in_leadwerks_engine[1]
Deferred rendering in_leadwerks_engine[1]Deferred rendering in_leadwerks_engine[1]
Deferred rendering in_leadwerks_engine[1]
 
Deferred shading
Deferred shadingDeferred shading
Deferred shading
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Offscreenparticle

  • 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.
  • 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); }
  • 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
  • 24. Blocky Problem ● Edges can be fixed with Edge detection. ● Standard Sobel filter
  • 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; } }
  • 30. Result Image from : technology.blurst.com/