Blending CSCI 440 textbook section 7.10

Slides:



Advertisements
Similar presentations
Presented by: Stacy C. Lovell. How do we perceive color? Our eyes contain only 3 types of photosentitive cells tuned to three frequencies Red, Green,
Advertisements

15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
2IV60 Computer graphics set 8: Illumination Models and Surface-Rendering Methods Jack van Wijk TU/e.
Hank Childs, University of Oregon Nov. 25th, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 15: animation, transparency.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
OpenGL Buffers and Tests Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, February 8, 2002.
OpenGL Fragment Operations
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
GAM531 DPS931 – Week 11 Render State. The Render State Render State BuffersShadersSamplers Rasterizer State Blend State.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
1. 2 Blending: tells you how to specify a blending function that combines color values from a source and a destination. The final effect is that parts.
03/12/02 (c) 2002 University of Wisconsin, CS559 Last Time Some Visibility (Hidden Surface Removal) algorithms –Painter’s Draw in some order Things drawn.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Transparent objects allow you to see clearly through them
Compositing and Blending Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Blending MAE152 Computer Graphics for Engineers and Scientists Fall 03.
Compositing and Blending - Chapter 8 modified by Ray Wisman Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Image Compositing Angel 8.11 Angel: Interactive Computer Graphics5E © Addison-Wesley
CHAPTER 10 Alpha Blending and Fog © 2008 Cengage Learning EMEA.
Visible Light and Color
Chapter 6. More on Color and Material Presented by Garrett Yeh.
Skin Rendering GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from David Gosselin’s Power Point and article, Real-time skin rendering,
1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.
OpenGL and WebGL Drawing Functions CSCI 440 Day Five.
7/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 4: Visual Appearance.
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Basic Graphics Concepts Day One CSCI 440. Terminology object - the thing being modeled image - view of object(s) on the screen frame buffer - memory that.
CS324e - Elements of Graphics and Visualization Compositing.
Chapter 2 Getting Started: Drawing Figures. The Framebuffer Lecture 2 Fri, Aug 29, 2003.
 When light strikes an object it is:. 1) Reflected.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
3.2. G RAPHICS I Alpha blending within games. An exploration of the use of alpha blending within games.
DREAM PLAN IDEA IMPLEMENTATION Introduction to Computer Graphics Dr. Kourosh Kiani
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS559: Computer Graphics Lecture 27: Texture Mapping Li Zhang Spring 2008 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys, UVA and Rosalee.
OpenGL Architecture Display List Polynomial Evaluator Per Vertex Operations & Primitive Assembly Rasterization Per Fragment Operations Frame Buffer Texture.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Compositing and Blending
Computer Graphics Blending CO2409 Computer Graphics Week 14.
1 Graphics CSCI 343, Fall 2015 Lecture 5 Color in WebGL.
UniS CS297 Graphics with Java and OpenGL Blending.
Chapter 13 Special Visual Techniques. Blending ◦ Without blending, a source fragment’s color values are supposed to overwrite those of its destination.
1 Computer Graphics Week11 : Hidden Surface Removal.
Compositing and Blending Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Computer Graphics I, Fall 2008 Compositing and Blending.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 5 Examples 1.
What you can see Reflected and Transmitted Light.
CS 4722 Made by Dr. Jeffrey Chastine Modified by Dr. Chao Mei
Hank Childs, University of Oregon
Textures, Sprites, and Fonts
Draw a Simple Object.
Introduction to Computer Graphics with WebGL
ICG Syllabus 1. Introduction 2. Viewing in 3D and Graphics Programming
Hidden Surface Removal
Introduction to Computer Graphics with WebGL
Making the Applications Interesting
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Alpha blending within games
blending blending textures reflection fog
UMBC Graphics for Games
Texture and Shadow Mapping
Introduction to Computer Graphics with WebGL
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Chapter X Output Merger.
The Framebuffer 1 Lecture 37 Fri, Nov 30, 2007.
blending blending textures reflection fog
Presentation transcript:

Blending CSCI 440 textbook section 7.10 http://fc07.deviantart.net/fs71/f/2011/263/3/1/transparent_gradient_triangles_by_10binary-d4agiq1.png

Transparency and Blending There is no such thing as a transparent surface in WebGL/OpenGL. But, we can fake it with Blending. Blending is part of the pipelined hardware. So, we do not program blending in the shaders. But we must configure the blending algorithm via JavaScript function calls.

WebGL's Blending Algorithm Redresult = Redsource*SrcFactor + Reddestination*DestFactor Greenresult = Greensource*SrcFactor + Greendestination*DestFactor Blueresult = Bluesource*SrcFactor + Bluedestination*DestFactor Alpharesult = Alphasource*SrcFactor + Alphadestination*DestFactor source = incoming pixel destination = pixel that was already drawn Src and Dest Factors: ONE SRC_ALPHA ONE_MINUS_SRC_ALPHA DST_ALPHA ONE_MINUS_DST_ALPHA many more

WebGL Code gl.enable ( gl.BLEND ); gl.disable ( gl.BLEND ); gl.blendFunc ( srcFactor, dstFactor );

Example One Conditions source pixel = [ 0, 0, 1, 0.3 ] semi-clear blue destination pixel = [ 1, 0, 0, 1 ] solid red source factor = SRC_ALPHA destination factor = ONE_MINUS_SRC_ALPHA Red = 0*0.3 + 1*0.7 = 0.7 Green = 0*0.3 + 0*0.7 = 0.0 Blue = 1*0.3 + 0*0.7 = 0.3 Alpha = .3*.3 + 1*0.7 = 0.79

Example Two Conditions destination pixel = [ 0, 0, 1, 0.3 ] semi-clear blue source pixel = [ 1, 0, 0, 1 ] solid red source factor = SRC_ALPHA destination factor = ONE_MINUS_SRC_ALPHA Red = 1 * 1 + 0 * 0 = 1.0 Green = 0 * 1 + 0 * 0 = 0.0 Blue = 0 * 1 + 1 * 0 = 0.0 Alpha = 1 * 1 + .3 * 0 = 1.0

Example Three Conditions destination pixel = [ .5, .5, .5, 1 ] solid grey source pixel = [ 1, 0, 0, 1 ] solid red source factor = SRC_ALPHA destination factor = ONE Red = 1 * 1 + .5 * 1 = 1.5 = 1.0 Green = 0 * 1 + .5 * 1 = 0.5 = 0.5 Blue = 0 * 1 + .5 * 1 = 0.5 = 0.5 Alpha = 1 * 1 + 1 * 1 = 2.0 = 1.0

A B The Blending Problem Suppose A and B are solid, and B is behind A. What do we do with the overlapping area? What happens when A is semi-clear? When only B is semi-clear? A B

The Blending Problem draw opaque A draw semi-translucent B in front A loses depth test to B, overlap is blended draw opaque C in back C loses depth test to A, overlap is discarded C also loses depth test to B, but is blended What is the depth of the pixels where A and B overlap?

Blending in OpenGL/WebGL A C B Turn on depth test Render all solids in any order Turn on Blending Set depth buffer to Read-Only Draw transparent objects back to front