1 / 10

Blending

CAP4730: Computational Structures in Computer Graphics. Blending. Outline. Why do we want to blend? What is blending? Math behind blending Blending in OpenGL. Why do we want to blend?. We use triangles to describe surfaces We always assumed opaque surfaces

tylerd
Télécharger la présentation

Blending

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CAP4730: Computational Structures in Computer Graphics Blending

  2. Outline • Why do we want to blend? • What is blending? • Math behind blending • Blending in OpenGL

  3. Why do we want to blend? • We use triangles to describe surfaces • We always assumed opaque surfaces • How would we do transparent surfaces? • What are some types of transparent surfaces? • Windows • Saran Wrap • Plastic (like my cup) • Stained Glass • Water

  4. Blend Let’s recall what happens per pixel

  5. We would like to combine the two colors • Fragment or source - incoming color • Destination - existing color • How should we combine them? • We use the alpha channel to describe the combination of the source and destination. • ColorFinal = A*ColorSource + B*ColorDestination • Most APIs let you specify A and B • What does A and B mean qualitatively?

  6. Combining Colors • Usually we take the source alpha as a “percentage” of the incoming fragment. • Thus the equation becomes: • ColorFinal=AlphaSource*ColorSource+(1- AlphaSource)*ColorDestination • What is the “default” alpha values for no blending? • What does this mean about the order of objects? • Order DOES MATTER when you have alpha objects!

  7. Order Matters with Alpha!

  8. OpenGL • glColor4f(1,0,0,0.5); • You must have a framebuffer with alpha: • glutInitDisplayMode(GLUT_RGBA); • Assign colors at the vertices to be a certain alpha. • Other suggestions for combining colors: • Let’s write out the equation • A = 1, B = 1 • A = 1-AlphaSource , B = AlphaSource • A = AlphaSource , B = 1 • glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); • glBlendFunc(GL_ONE, GL_ZERO);

  9. HUDs

  10. Decals/Other Blending Uses • Example from http://fly.srk.fer.hr/~unreal/theredbook/chapter07.html

More Related