blending - CAP4730: Computational Structures in Computer...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CAP4730: Computational Structures in Computer Graphics Blending Blending Outline Outline Why do we want to blend? s What is blending? s Math behind blending s Blending in OpenGL s Why do we want to blend? Why do we want to blend? s s s s 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 Blend Let’s recall what happens per pixel We would like to combine the We would like to combine the two colors Fragment or source ­ incoming color s Destination ­ existing color s How should we combine them? s We use the alpha channel to describe the combination of the source and destination. s ColorFinal = A*ColorSource + B*ColorDestination s s Most APIs let you specify A and B Combining Colors Combining Colors s s s s s s 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! Order Matters with Alpha! Order Matters with Alpha! OpenGL OpenGL s s s s s s s s s s 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); HUDs HUDs Decals/Other Blending Uses Decals/Other Blending Uses s Example from http://fly.srk.fer.hr/~u nreal/theredbook/ch apter07.html ...
View Full Document

This note was uploaded on 11/30/2011 for the course CIS 4930 taught by Professor Staff during the Fall '08 term at University of Florida.

Ask a homework question - tutors are online