Advertisement
Advertisement

More Related Content

Slideshows for you(20)

Advertisement
Advertisement

Recently uploaded(20)

CS 354 Blending, Compositing, Anti-aliasing

  1. CS 354 Blending, Compositing, Anti-aliasing Mark Kilgard University of Texas February 14, 2012
  2. A Simplified Graphics Pipeline Application Vertex batching & assembly Triangle assembly Triangle clipping Triangle rasterization Fragment shading Depth testing Color update/blending Application- OpenGL API boundary Framebuffer NDC to window space Depth buffer Re-examine framebuffer color update…
  3. A few more steps expanded Application Vertex batching & assembly Lighting View frustum clipping Triangle rasterization Fragment shading Depth testing Color update/blending Application- OpenGL API boundary Framebuffer NDC to window space Depth buffer Vertex transformation User defined clipping Back face culling Perspective divide Triangle assembly Texture coordinate generation
  4. Blending Enabled vs. Disabled pixel color fragment color blend operation pixel color fragment color glDisable ( GL_BLEND ) glEnable ( GL_BLEND )
  5. Why blending? compositing window systems volumetric effects; explosions medical imaging compositing complex art work
  6. Conventional Blend Operation source color destination factor destination color source factor × × + clamp [0,1] pixel color fragment color
  7. Conventional Blend Operation source color destination factor destination color source factor × × + clamp [0,1] pixel color fragment color × × × + + + × × × clamp [0,1] clamp [0,1] clamp [0,1] modulate, add, and clamp operations are vector on RGBA components
  8. Conventional Blend Operation source color destination factor destination color source factor × × + clamp [0,1] pixel color fragment color glBlendFunc ( srcFunc , dstFunc )
  9. Blend Function Parameters where s = min(A s ,1-A d ) (s,s,s,s) GL_SRC_ALPHA_SATURATE (1-A c ,1-A c ,1-A c ,1-A c ) GL_ONE_MINUS_CONSTANT_ALPHA (A c ,A c ,A c ,A c ) GL_CONSTANT_ALPHA (1-R c ,1-G c ,1-B c ,1-A c ) GL_ONE_MINUS_CONSTANT_COLOR (R c ,G c ,B c ,A c ) GL_CONSTANT_COLOR (1-A d ,1-A d ,1-A d ,1-A d ) GL_ONE_MINUS_DST_ALPHA (A d ,A d ,A d ,A d ) GL_DST_ALPHA (1-A s ,1-A s ,1-A s ,1-A s ) GL_ONE_MINUS_SRC_ALPHA (A s ,A s ,A s ,A s ) GL_SRC_ALPHA (1-R d ,1-G d ,1-B d ,1-A d ) GL_ONE_MINUS_DST_COLOR (R d ,G d ,B d ,A d ) GL_DST_COLOR (1-R s ,1-G s ,1-B s ,1-A s ) GL_ONE_MINUS_SRC_COLOR (R s ,G s ,B s ,A s ) GL_SRC_COLOR (1,1,1,1) GL_ONE (0,0,0,0) GL_ZERO ( f r , f g , f b , f a ) Parameter
  10. Blend Color for Factors source color destination factor destination color source factor × × + clamp [0,1] pixel color fragment color glBlendColor (r,g,b,a) blend color
  11. Min/Max Blend Operation source color destination color min or max clamp [0,1] pixel color fragment color glBlendEquation ( GL_MIN ) glBlendEquation ( GL_MAX )
  12. Properly Ordered Compositing vs. Incorrectly Ordered
  13. Properly Ordered Compositing vs. Incorrectly Ordered
  14. Porter-Duff Composite Operators
  15. Porter & Duff Modes Porter & Duff blend modes 1 1 0 0 1 1 0 1 1 0 1 0 Y 0 0 0 Clear 1 0 0 Xor 0 1 Bc Dst-atop 1 1 Ac Src-atop 1 0 0 Dst-out 0 0 0 Src-out 0 0 Bc Dst-In 0 1 Ac Src-In 1 1 Bc Dst-Over 1 1 Ac Src-Over 1 1 Bc Dst 0 1 Ac Src Z X f(Ac,Bc) Operation
  16. Porter & Duff Modes Expanded Uncorrelated blend mode expansion of Porter & Duff blend modes 1 0 1 1 0 0 0 1 1 1 0 0 Z 1 1 0 0 1 1 0 1 1 0 1 0 Y 0 0 0 Clear Aca×(1-Ba)+(1-Aa)×Bca 0 0 Xor (1-Ba)×Aca+Aa×Bca 1 Bc Dst-atop Aca×Ba+(1-Aa)×Bca 1 Ac Src-atop (1-Aa)×Bca 0 0 Dst-out (1-Ba)×Aca 0 0 Src-out Bca×Aa 0 Bc Dst-In Aca×Ba 1 Ac Src-In Bca+(1-Ba)×Aca 1 Bc Dst-Over Aca+(1-Aa)×Bca 1 Ac Src-Over Bca 1 Bc Dst Aca 1 Ac Src Blend mode X f(Ac,Bc) Operation
  17. Porter & Duff for glBlendFunc GL_ONE_MINS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_DST_ALPHA GL_ZERO GL_ONE_MINUS_DST_ALPHA GL_ZERO GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_ONE GL_ZERO GL_ONE GL_ZERO srcFactor Aca×(1-Ba)+(1-Aa)×Bca (1-Ba)×Aca+Aa×Bca Aca×Ba+(1-Aa)×Bca (1-Aa)×Bca (1-Ba)×Aca Bca×Aa Aca×Ba Bca+(1-Ba)×Aca Aca+(1-Aa)×Bca Bca Aca 0 Blend mode GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ZERO GL_SRC_ALPHA GL_ZERO GL_ONE GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ZERO GL_ZERO dstFactor Clear Xor Dst-atop Src-atop Dst-out Src-out Dst-In Src-In Dst-Over Src-Over Dst Src Operation
  18. Aliased Jagged artifacts
  19. Multi-sample 8x Smoother appearance
  20. Multi-sample Coverage Positions 4x jittered 1x (aliased) 8x jittered 4x orthogonal
Advertisement