7/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 4: Visual Appearance.

Slides:



Advertisements
Similar presentations
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
Advertisements

16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
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.
Hank Childs, University of Oregon Nov. 25th, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 15: animation, transparency.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object.
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.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of New Mexico
Computer Graphics - Class 10
Rendering (彩現 渲染).
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
7M836 Animation & Rendering
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Lighting & Shading.
CSE (Notre Dame) Computer Graphics Lecture 16 A Simple Draw Image Example More Texture Mapping Simple OpenGL Image Library (SOIL) Transparency &
SET09115 Intro Graphics Programming
Fundamentals of Computer Graphics Part 6 Shading prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.:
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
Lecture 12 Blending, Anti-aliasing, Fog, Display Lists.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Illumination and Shading
Compositing and Blending
Computer Graphics Blending CO2409 Computer Graphics Week 14.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
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.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
CDS 301 Fall, 2008 From Graphics to Visualization Chap. 2 Sep. 3, 2009 Jie Zhang Copyright ©
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Lecture 25 Fasih ur Rehman. Last Class Shading.
Compositing and Blending Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Computer Graphics I, Fall 2008 Compositing and Blending.
Computer Graphics: Illumination
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Week 7 - Monday CS361.
Shading To determine the correct shades of color on the surface of graphical objects.
Introduction to Computer Graphics with WebGL
Visual Appearance Chapter 4
I = a I + ( ) 1 – a I BLENDING, ANTIALIASING, AND FOG l l 1 l 2 Earth
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
blending blending textures reflection fog
Fundamentals of Computer Graphics Part 6 Shading
Computer Graphics Material Colours and Lighting
CS 480/680 Computer Graphics Shading.
blending blending textures reflection fog
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
Lighting Calculations
Presentation transcript:

7/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 4: Visual Appearance Patrick Olivier 2 nd floor in the Devonshire Building

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)2 Objectives  Refresher on simple lighting models  Blending for translucent surfaces  Compositing images  Fog  Gamma correction

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)3 Lighting model (1)  How compute lighting?  We could set colors per vertex manually  For a little more realism, compute lighting from: Light sources Material properties Geometrical relationships light blue red green Rasterizer Geometry

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)4 Diffuse component: i diff  i = i amb + i diff + i spec  Diffuse is Lambert’s law  Photons cattered equally in all directions

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)5 Specular component: i spec  Diffuse is dull (left)  Specular: simulates a highlight  Models: Phong specular highlight model Blinn’s highlight formula (variation on Phong)

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)6 Specular component: Phong n l r -l-l

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)7 Ambient component: i amb  Ad-hoc – tries to account for light coming from other surfaces  Just add a constant color:  Sum all components: i = i amb + i diff + i spec  This is just a hack!  It has almost nothing to do with reality! ++=

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)8 Additions to the lighting equation  Depends on distance: 1/(a+bt+ct 2 )  Can have more lights: just sum their respective contributions  Different light types: directional point spot

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)9 What’s lighting and what’s shading?  Lighting: interaction between light & matter  Shading: determine pixel colors from vertex lighting  Three types of shading: Flat (per polygon) Gouraud (per vertex) Phong (per pixel)

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)10  Surfaces: Opaque: permit no light to pass through Transparent: permit all light to pass Translucent: pass some light translucency = 1 – opacity(  )  Translucency in physically correct manner is difficult: complexity of interactions of light & matter using a pipeline renderer Opacity and Transparency

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)11 Writing model  Use “A” component RGBA (or RGB  ) to store opacity  Can expand our model to use RGBA values color buffer destination component blend Destination blending factor source blending factor source component

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)12 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 source & destination colours 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  ]

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)13 OpenGL Blending and Compositing  Must enable blending and pick source and destination factors: g lEnable(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…

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)14 Example…  Suppose that we start with the opaque background colour (R 0,G 0,B 0,1) This color becomes the initial destination color  We now want to blend in a translucent polygon with colour (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

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)15 Clamping  All the components (RGBA) are clamped and stay in the range (0,1)  However, in a typical (old) 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

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)16 Order Dependency  Is this image correct? Probably not… Polygons are rendered in the order they pass down the pipeline Blending functions are order dependent

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)17 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

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)18 Fog  Simple atmospheric effect A little better realism Help in determining distances  Color of fog: color of surface:  How to compute f ? 3 ways: linear, exponential, exponential-squared  Linear:

6/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)19 Fog example  Often just a matter of: Choosing fog color Choosing fog model Turning it on GLfloat fcolor[4] = {……}: glEnable(GL_FOG); glFogf(GL_FOG_MODE, GL_EXP); glFogf(GL_FOG_DENSITY, 0.5); glFOgv(GL_FOG, fcolor);