1 / 10

100 likes | 116 Vues

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

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

**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 • How would we do transparent surfaces? • What are some types of transparent surfaces? • Windows • Saran Wrap • Plastic (like my cup) • Stained Glass • Water**Blend**Let’s recall what happens per pixel**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?**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!**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);**Decals/Other Blending Uses**• Example from http://fly.srk.fer.hr/~unreal/theredbook/chapter07.html

More Related