Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
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.
POST-PROCESSING SET09115 Intro Graphics Programming.
Addition 1’s to 20.
Transformations Ed Angel Professor Emeritus of Computer Science
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
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 Fragment Operations
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
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.
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
Objectives Introduce OpenGL buffers and read/write Introduce OpenGL buffers and read/write Introduce texture mapping Introduce texture mapping Introduce.
Chapter 6. More on Color and Material Presented by Garrett Yeh.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1Notes. 2Atop  The simplest (useful) and most common form of compositing: put one image “atop” another  Image 1 (RGB) on top of image 2 (RGB)  For.
7/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 4: Visual Appearance.
02/14/02(c) University of Wisconsin 2002, CS 559 Last Time Filtering Image size reduction –Take the pixel you need in the output –Map it to the input –Place.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Tools for Raster Displays CVGLab Goals of the Chapter To describe pixmaps and useful operations on them. To develop tools for copying, scaling, and rotating.
Filtering and Color To filter a color image, simply filter each of R,G and B separately Re-scaling and truncating are more difficult to implement: –Adjusting.
Visible-Surface Detection Jehee Lee Seoul National University.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
1 Texture Mapping. 2 Texture Aliasing MIPmaps Environment Mapping Bump Mapping Displacement Mapping Shadow Maps Solid Textures Antialiasing.
Real-Time rendering Chapter 4.Visual Appearance 4.4. Aliasing and antialiasing 4.5. Transparency,alpha,and compositing 4.6. Fog 4.7. Gamma correction
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
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
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics Blending CO2409 Computer Graphics Week 14.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
UniS CS297 Graphics with Java and OpenGL Blending.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Chapter 6. Blending, Antialiasing, Fog, and Polygon Offset Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Hank Childs, University of Oregon
Buffers Ed Angel Professor Emeritus of Computer Science
Discrete Techniques.
Week 7 - Monday CS361.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 4: Color and Attributes
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Introduction to Computer Graphics with WebGL
Implementation II Ed Angel Professor Emeritus of Computer Science
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Buffers Ed Angel Professor Emeritus of Computer Science
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 4: Color and Attributes
Implementation I Ed Angel Professor Emeritus of Computer Science
Implementation II Ed Angel Professor Emeritus of Computer Science
Computer Graphics Image processing 紀明德
Presentation transcript:

Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

2 Objectives Learn to use the A component in RGBA color for ­Blending for translucent surfaces ­Compositing images ­Antialiasing

3 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Opacity and Transparency Opaque surfaces permit no light to pass through Transparent surfaces permit all light to pass Translucent surfaces pass some light translucency = 1 – opacity (  ) opaque surface  =1

4 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Physical Models Dealing with translucency in a physically correct manner is difficult due to ­the complexity of the internal interactions of light and matter ­Using a pipeline renderer

5 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Writing Model Use A component of RGBA (or RGB  ) color to store opacity During rendering we can expand our writing model to use RGBA values Color Buffer destination component blend destination blending factor source blending factor source component

6 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Blending Equation We can define source and destination blending factors for each RGBA component s = [s r, s g, s b, s  ] d = [d r, d g, d b, d  ] Suppose that the source and destination colors are b = [b r, b g, b b, b  ] c = [c r, c g, c b, c  ] Blend as c’ = [b r s r + c r d r, b g s g + c g d g, b b s b + c b d b, b  s  + c  d  ]

7 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 OpenGL Blending and Compositing Must enable blending and pick source and destination factors glEnable(GL_BLEND) glBlendFunc(source_factor, destination_factor) Only certain factors supported ­GL_ZERO, GL_ONE ­GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ­GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA ­See Redbook for complete list

8 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Example Suppose that we start with the opaque background color (R 0,G 0,B 0,1) ­This color becomes the initial destination color We now want to blend in a translucent polygon with color (R 1,G 1,B 1,  1 ) Select GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA as the source and destination blending factors R ’ 1 =  1 R 1 +(1-  1 ) R 0, …… Note this formula is correct if polygon is either opaque or transparent

9 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Clamping and Accuracy All the components (RGBA) are clamped and stay in the range (0,1) However, in a typical system, RGBA values are only stored to 8 bits ­Can easily loose accuracy if we add many components together ­Example: add together n images Divide all color components by n to avoid clamping Blend with source factor = 1, destination factor = 1 But division by n loses bits

10 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Order Dependency Is this image correct? ­Probably not ­Polygons are rendered in the order they pass down the pipeline ­Blending functions are order dependent

11 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Opaque and Translucent Polygons Suppose that we have a group of polygons some of which are opaque and some translucent How do we use hidden-surface removal? Opaque polygons block all polygons behind them and affect the depth buffer Translucent polygons should not affect depth buffer ­Render with glDepthMask(GL_FALSE) which makes depth buffer read-only Sort polygons first to remove order dependency

12 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Fog We can composite with a fixed color and have the blending factors depend on depth ­Simulates a fog effect Blend source color C s and fog color C f by C s ’=f C s + (1-f) C f f is the fog factor ­Exponential ­Gaussian ­Linear (depth cueing) Deprecated but can recreate

13 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Fog Functions

14 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Line Aliasing Ideal raster line is one pixel wide All line segments, other than vertical and horizontal segments, partially cover pixels Simple algorithms color only whole pixels Lead to the “jaggies” or aliasing Similar issue for polygons

15 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Antialiasing Can try to color a pixel by adding a fraction of its color to the frame buffer ­Fraction depends on percentage of pixel covered by fragment ­Fraction depends on whether there is overlap no overlapoverlap

16 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Area Averaging Use average area  1 +  2 -  1  2 as blending factor

17 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 OpenGL Antialiasing Can enable separately for points, lines, or polygons glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

18 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Accumulation Techniques Compositing and blending are limited by resolution of the frame buffer ­Typically 8 bits per color component The accumulation buffer was a high resolution buffer (16 or more bits per component) that avoided this problem Could write into it or read from it with a scale factor Slower than direct compositing into the frame buffer Now deprecated but can do techniques with floating point frame buffers

19 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Applications Compositing Image Filtering (convolution) Whole scene antialiasing Depth of Field Motion effects