I = a I + ( ) 1 – a I BLENDING, ANTIALIASING, AND FOG l l 1 l 2 Earth

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
Hank Childs, University of Oregon Nov. 25th, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 15: animation, transparency.
OpenGL Fragment Operations
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
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,
COMP Advanced Graphics Advanced Graphics - Part 6 The big picture: –Still working on advanced polygonal techniques with a special focus on OpenGL.
Image Compositing Angel 8.11 Angel: Interactive Computer Graphics5E © Addison-Wesley
CHAPTER 10 Alpha Blending and Fog © 2008 Cengage Learning EMEA.
Objectives Introduce OpenGL buffers and read/write Introduce OpenGL buffers and read/write Introduce texture mapping Introduce texture mapping Introduce.
OpenGL Son of the Survival Guide. Last Time on OpenGL Windowing … glut Rendering Primatives Transformations Projections State Management.
Chapter 6. More on Color and Material Presented by Garrett Yeh.
CH7 Buffers and Blending. Blending Example 1/6 #include #include "glut.h" GLfloat alpha = 0.0; GLfloat pos[4] = {0, 10, 10, 0}; GLfloat dif_l[4] = {1.0,
7/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 4: Visual Appearance.
Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007
CSE (Notre Dame) Computer Graphics Lecture 16 A Simple Draw Image Example More Texture Mapping Simple OpenGL Image Library (SOIL) Transparency &
MAE152 Computer Graphics for Scientists and Engineers Antialiasing Fall 2003.
Informationsteknologi Monday, November 26, 2007Computer Graphics - Class 121 Today’s class Drawing lines Bresenham’s algorithm Compositing Polygon filling.
Lecture 12 Blending, Anti-aliasing, Fog, Display Lists.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
OpenGL Blending Akbar Ali
1 Chapter 6 Blending, Antialiasing, Fog, and Polygon Offset Guihua Yang Jan 14, 2004.
Demetriou/Loizidou – ACSC 345 – Chapter 7 Discrete Techniques Dr. Giorgos A. Demetriou Dr. Stephania Loizidou Himona Computer Science Frederick Institute.
DREAM PLAN IDEA IMPLEMENTATION Introduction to Computer Graphics Dr. Kourosh Kiani
Chapter 8: Discrete Techniques Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 Chapter 7 Discrete Techniques. 2 Buffer Define a buffer by its spatial resolution (n x m) and its depth k, the number of bits/pixel pixel.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Introduction to OpenGL (part 2)
CS559: Computer Graphics Lecture 27: Texture Mapping Li Zhang Spring 2008 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys, UVA and Rosalee.
1 3D API OPENGL ES v1.0 Owned by Silicon Graphics (SGL) Control was then transferred to Khronos Group Introduction.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Compositing and Blending
CH7 Buffers and Blending. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
UniS CS297 Graphics with Java and OpenGL Blending.
OpenGL Special Effects Jian-Liang Lin 2002 Blending: Alpha Channel Alpha value can be specify by glColor* When blending is enabled, the alpha value is.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
Buffers, Compositing and Blending Week 8 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New.
Chapter 4 -- Color1 Color Open GL Chapter 4. Chapter 4 -- Color2 n The goal of almost all OpenGL applications is to draw color pictures in a window on.
Chapter 13 Special Visual Techniques. Blending ◦ Without blending, a source fragment’s color values are supposed to overwrite those of its destination.
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.
Chapter 6. Blending, Antialiasing, Fog, and Polygon Offset Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Week 7 - Monday CS361.
Draw a Simple Object.
Introduction to Computer Graphics with WebGL
Discrete Techniques Chapter 8.
Advanced Graphics Algorithms Ying Zhu Georgia State University
OpenGL Buffers and Tests
Discrete Techniques Chapter 8.
Lecture 16 and 17 Rasterization and Per-Fragment Operations
CSc4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Fog and Transparency.
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Geb Thomas Adapted from the OpenGL Programming Guide
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
blending blending textures reflection fog
Computer Graphics Buffers
3D Game Programming Texture Mapping
Three-Dimensional Graphics VI
Computer Graphics Practical Lesson 7
Computer Graphics 4Practical Lesson
Chapter X Output Merger.
Geometric Objects and Transformations (I)
3D Game Programming Texture Mapping
blending blending textures reflection fog
Presentation transcript:

I = a I + ( ) 1 – a I BLENDING, ANTIALIASING, AND FOG l l 1 l 2 Earth ( ) 1 – a I l l 1 l 2 Earth 1 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu OPENGL BLENDING I = B I + B I l 1 l 1 2 l 2 Let the source and destination blending factors be (S , S , S , S ) and (D , D , D , D ) r g b a r g b a The RGBA values of the source and destination is indicated with a subscript of s or d . The final, blended RGBA values are given by (R S +R D , G S +G D , B S +B D , A S +A D ) s r d r s g d g s b d b s a d a 2 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu = B I + B I l 1 l 1 2 l 2 (R S +R D , G S +G D , B S +B D , A S +A D ) s r d r s g d g s b d b s a d a 1) Each component is eventually clamped to [0,1]; glEnable(GL_BLEND); 2) void glBlendFunc(GLenum sfactor, GLenum dfactor); 3) Color values in the fragment (the source) are alpha.c combined with those already stored in the framebuffer (the destination). 4) sfactor indicates how to compute a source blending factor; dfactor indicates how to compute a destination blending factor GL_SRC_ALPHA s. or d. (As,As,As,As) GL_ONE_MINUS_SRC_ALPHA s. or d. (1,1,1,1)-(As,As,As,As) 3 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu Constant Relevant Factor Computed Blend Factor GL_ZERO source or destination (0, 0, 0, 0) GL_ONE s. or d. (1, 1, 1, 1) GL_DST_COLOR source (Rd,Gd,Bd,Ad) GL_SRC_COLOR destination (Rs,Gs,Bs,As) GL_ONE_MINUS_DST_COLOR source (1,1,1,1)-(Rd,Gd,Bd,Ad) GL_ONE_MINUS_SRC_COLOR destination (1,1,1,1)-(Rs,Gs,Bs,As) GL_SRC_ALPHA s. or d. (As,As,As,As) GL_ONE_MINUS_SRC_ALPHA s. or d. (1,1,1,1)-(As,As,As,As) GL_DST_ALPHA s. or d. (Ad,Ad,Ad,Ad) GL_ONE_MINUS_DST_ALPHA s. or d. (1,1,1,1)-(Ad,Ad,Ad,Ad) GL_SRC_ALPHA_SATURATE source (f, f, f, 1); f=min(As,1-Ad) 4 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu alpha3D Blending with the Depth Buffer If an opaque object hides any object, you want the depth buffer If the translucent object is closer, however, you Earth want to blend it with the opaque object. draw opaque objects first with normal depth-buffer operation; then draw translucent object with the depth buffer read-only glDepthMask(GL_FALSE ); the buffer becomes read-only, whereas GL_TRUE restores the normal, writable operation. 5 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu ANTIALIASING OpenGL calculates a coverage value for each fragment based on the pixel square In RGBA mode, OpenGL multiplies the fragment’s alpha by its coverage. You can then use the alpha to blend the fragment with the pixel already in the framebuffer. 6 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu In color-index mode, OpenGL sets the least significant 4 bits of the color index based on the fragment’s coverage (0000 for no coverage and 1111 for complete coverage). void glHint(GLenum target, GLenum hint); The target parameter indicates which behavior is to be controlled: GL_POINT_SMOOTH_HINT, GL_LINE_SMOOTH_HINT, GL_POLYGON_SMOOTH_HINT, GL_FOG_HINT, GL_PERSPECTIVE_CORRECTION_HINT The hint parameter can be GL_FASTEST to indicate that the most efficient option should be chosen, GL_NICEST to indicate the highest-quality option, or GL_DONT_CARE. The interpretation of hints is implementation-dependent 7 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu Line: aargb In RGBA mode, we need to enable blending. The blending factors you most likely want to use are GL_SRC_ALPHA (source) and GL_ONE_MINUS_SRC_ALPHA (destination). For points, lines, and polygons: glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); For polygons, we need to turn off depth buffer and sort the polygons according to the depth, which is quite cumbersome (a good topic to study) 8 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu FOG Fog Lab Fog in RGBA Mode In RGBA mode, the fog factor f is used as follows to calculate the final fogged color: Il = f*Il1 + (1-f)Ilf Where Il1 represents the incoming fragment’s RGBA values and Ilf the fog-color values assigned with GL_FOG_COLOR. 9 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu Enable fog: glEnable(GL_FOG ); Choose color & equation that controls fog density: void glFog{if}{v}(GLenum pname, TYPE param); In RGBA mode, pname can be GL_FOG_COLOR. The corresponding value for pname in color-index mode is GL_FOG_INDEX. If pname is GL_FOG_MODE, then param is either GL_EXP (the default), GL_EXP2, or GL_LINEAR. If pname is GL_FOG_DENSITY, GL_FOG_START, or GL_FOG_END, then param is a value for density, start, or end in the equations. 1010 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu

Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu Fog Lab 11 Copyright @ 2002 by Jim X. Chen: jchen@cs.gmu.edu