Computer Graphics - Shading -

Slides:



Advertisements
Similar presentations
Computer Graphics Shading Lecture 13 John Shearer
Advertisements

Computer Graphics I, Fall 2010 Shading II.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
CS 480/680 Computer Graphics Shading 2 Dr. Frederick C Harris, Jr.
CSPC 352: Computer Graphics
Computer Graphics (Fall 2008) COMS 4160, Lecture 18: Illumination and Shading 1
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.
1 Computer Graphics By : Mohammed abu Lamdy ITGD3107 University of Palestine Supervision: Assistant Professor Dr. Sana’a Wafa Al-Sayegh.
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
Shading II CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
Lighting and Shading Wen-Chieh (Steve) Lin
Computer Graphics (Spring 2008) COMS 4160, Lecture 15: Illumination and Shading
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.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006 Shading II Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Lighting & Shading.
LIGHTING Part One - Theory based on Chapter 6. Lights in the real world Lights bounce off surfaces and reflect colors, scattering light in many directions.
Shading Surface can either (both) 1.Emit light. E.g. light bult 2.Reflect light. E.g. Mirror.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Illumination.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Shading I Shandong University Software College Instructor: Zhou Yuanfeng
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Chapter 6: Shading Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
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.
Illumination & Reflectance Dr. Amy Zhang. Outline 2  Illumination and Reflectance  The Phong Reflectance Model  Shading in OpenGL.
1 Chapter 6 Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Illumination.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Introduction to Computer Graphics with WebGL
Shading. For Further Reading Angel 7 th Ed: ­Chapter 6 2.
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
Local Illumination and Shading
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
Illumination and Shading Sang Il Park Sejong University.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Computer Graphics Lecture 25 Fasih ur Rehman. Last Class Shading.
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Computer Graphics: Illumination
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 55 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 55 Computer Graphics Three-Dimensional Graphics V.
Illumination : Hearn & Baker Ch. 10
Shading To determine the correct shades of color on the surface of graphical objects.
Shading II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Angel: Interactive Computer.
CSC461: Lecture 23 Shading Computation
CS5500 Computer Graphics April 10, 2006.
Isaac Gang University of Mary Hardin-Baylor
Computer Graphics (Fall 2003)
CS 480/680 Computer Graphics Shading.
CS 480/680 Computer Graphics Shading.
Shading II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Computer Graphics - Shading - Hanyang University Jong-Il Park

Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build a simple reflection model---the Phong model--- that can be used with real time graphics hardware Introduce modified Phong model Consider computation of required vectors

Why we need shading Suppose we build a model of a sphere using many polygons and color it with glColor. We get something like But we want

Shading Why does the image of a real sphere look like Light-material interactions cause each point to have a different color or shade Need to consider Light sources Material properties Location of viewer Surface orientation

Rendering: 1960s (visibility) Roberts (1963), Appel (1967) - hidden-line algorithms Warnock (1969), Watkins (1970) - hidden-surface Sutherland (1974) - visibility = sorting 1970s illustrations taken from FvDFH Images from FvDFH, Pixar’s Shutterbug Slide ideas for history of Rendering courtesy Marc Levoy

Rendering: 1970s (lighting) 1970s - raster graphics Gouraud (1971) - diffuse lighting, Phong (1974) - specular lighting Blinn (1974) - curved surfaces, texture Catmull (1974) - Z-buffer hidden-surface algorithm 1970s illustrations taken from FvDFH

Rendering (1980s, 90s: Global Illumination) early 1980s - global illumination Whitted (1980) - ray tracing Goral, Torrance et al. (1984) radiosity Kajiya (1986) - the rendering equation 1980s illustrations taken from Siggraph proceedings global illumination ray tracing = Monte Carlo evaluation of the rendering equation radiosity = finite element evaluation of the rendering equation

Scattering Light strikes A Some of scattered light strikes B Some scattered Some absorbed Some of scattered light strikes B Some of this scattered light strikes A and so on

Rendering Equation The infinite scattering and absorption of light can be described by the rendering equation Cannot be solved in general Ray tracing is a special case for perfectly reflecting surfaces Rendering equation is global and includes Shadows Multiple scattering from object to object

Global Effects shadow multiple reflection translucent surface

Local vs Global Rendering Correct shading requires a global calculation involving all objects and light sources Incompatible with pipeline model which shades each polygon independently (local rendering) However, in computer graphics, especially real time graphics, we are happy if things “look right” Exist many techniques for approximating global effects

Light-Material Interaction Light that strikes an object is partially absorbed and partially scattered (reflected) The amount reflected determines the color and brightness of the object A surface appears red under white light because the red component of the light is reflected and the rest is absorbed The reflected light is scattered in a manner that depends on the smoothness and orientation of the surface

Light Sources General light sources are difficult to work with because we must integrate light coming from all points on the source

Simple Light Sources Point source Spotlight Ambient light Model with position and color Distant source = infinite distance away (parallel) Spotlight Restrict light from ideal point source Ambient light Same amount of light everywhere in scene Can model contribution of many sources and reflecting surfaces

Surface Types The smoother a surface, the more reflected light is concentrated in the direction a perfect mirror would reflected the light A very rough surface scatters light in all directions rough surface smooth surface

Phong Model A simple model that can be computed rapidly Has three components Diffuse Specular Ambient Uses four vectors To source To viewer Normal Perfect reflector

Ideal Reflector Normal is determined by local orientation Angle of incidence = angle of reflection The three vectors must be coplanar r = 2 (l · n ) n - l

Lambertian Surface Perfectly diffuse reflector Light scattered equally in all directions Amount of light reflected is proportional to the vertical component of incoming light reflected light ~cos qi cos qi = l · n if vectors normalized There are also three coefficients, kr, kb, kg that show how much of each color component is reflected

Specular Surfaces Most surfaces are neither ideal diffusers nor perfectly specular (ideal reflectors) Smooth surfaces show specular highlights due to incoming light being reflected in directions concentrated close to the direction of a perfect reflection specular highlight

Modeling Specular Relections Phong proposed using a term that dropped off as the angle between the viewer and the ideal reflection increased Ir ~ ks I cosaf f shininess coef reflected intensity incoming intensity absorption coef

The Shininess Coefficient Values of a between 100 and 200 correspond to metals Values between 5 and 10 give surface that look like plastic cosa f -90 f 90

Ambient Light Ambient light is the result of multiple interactions between (large) light sources and the objects in the environment Amount and color depend on both the color of the light(s) and the material properties of the object Add ka Ia to diffuse and specular terms reflection coef intensity of ambient light

Distance Terms The light from a point source that reaches a surface is inversely proportional to the square of the distance between them We can add a factor of the form 1/(a + bd +cd2) to the diffuse and specular terms The constant and linear terms soften the effect of the point source

Light Sources In the Phong Model, we add the results from each light source Each light source has separate diffuse, specular, and ambient terms to allow for maximum flexibility even though this form does not have a physical justification Separate red, green and blue components Hence, 9 coefficients for each point source Idr, Idg, Idb, Isr, Isg, Isb, Iar, Iag, Iab

Material Properties Material properties match light source properties Nine absorption coefficients kdr, kdg, kdb, ksr, ksg, ksb, kar, kag, kab Shininess coefficient a Roughness

Adding up the Components For each light source and each color component, the Phong model can be written (without the distance terms) as I =kd Id l · n + ks Is (v · r )a + ka Ia For each color component we add contributions from all sources

Modified Phong Model The specular term in the Phong model is problematic because it requires the calculation of a new reflection vector and view vector for each vertex Blinn suggested an approximation using the halfway vector that is more efficient

The Halfway Vector h = ( l + v )/ | l + v | h is normalized vector halfway between l and v h = ( l + v )/ | l + v |

Using the halfway vector Replace (v · r )a with (n · h )b b is chosen to match shininess Note that halfway angle is half of angle between r and v if vectors are coplanar Resulting model is known as the modified Phong or Blinn lighting model Specified in OpenGL standard

Example Only differences in these teapots are the parameters in the modified Phong model

Computation of Vectors l and v are specified by the application Can compute r from l and n Problem is determining n For simple surfaces n can be determined but how we determine n differs depending on underlying representation of surface OpenGL leaves determination of normal to application Exception for GLU quadrics and Bezier surfaces (Chapter 11)

Plane Normals n = (p2-p0) × (p1-p0) Equation of plane: ax+by+cz+d = 0 From Chapter 4 we know that plane is determined by three points p0, p2, p3 or normal n and p0 Normal can be obtained by n = (p2-p0) × (p1-p0)

Normal to Sphere Implicit function f(x,y.z)=0 Normal given by gradient Sphere f(p)=p·p - 1 n = [∂f/∂x, ∂f/∂y, ∂f/∂z]T=p

Parametric Form For sphere Tangent plane determined by vectors Normal given by cross product x=x(u,v)=cos u sin v y=y(u,v)=cos u cos v z= z(u,v)=sin u ∂p/∂u = [∂x/∂u, ∂y/∂u, ∂z/∂u]T ∂p/∂v = [∂x/∂v, ∂y/∂v, ∂z/∂v]T n = ∂p/∂u × ∂p/∂v

General Case We can compute parametric normals for other simple cases Quadrics Parametric polynomial surfaces Bezier surface patches (Chapter 11)

Mesh Shading For polygonal models, Gouraud proposed we use the average of the normals around a mesh vertex n = (n1+n2+n3+n4)/ |n1+n2+n3+n4|

Gouraud Shading – Details Scan line Actual implementation efficient: difference equations while scan converting

Gouraud and Errors I1 = 0 because (n dot v) is negative. I2 = 0 because (n dot l) is negative. Any interpolation of I1 and I2 will be 0. I1 = 0 I2 = 0 area of desired highlight v l n1 n2

2 Phongs make a Highlight Besides the Phong Reflectance model (cosn), there is a Phong Shading model. Phong Shading: Instead of interpolating the intensities between vertices, interpolate the normals. The entire lighting calculation is performed for each pixel, based on the interpolated normal. (OpenGL doesn’t do this, but you can with programmable shaders) I1 = 0 I2 = 0

Gouraud vs. Phong Shading Gouraud Shading Find average normal at each vertex (vertex normals) Apply modified Phong model at each vertex Interpolate vertex shades across each polygon Phong shading Find vertex normals Interpolate vertex normals across edges Interpolate edge normals across polygon Apply modified Phong model at each fragment

Comparison If the polygon mesh approximates surfaces with a high curvatures, Phong shading may look smooth while Gouraud shading may show edges Phong shading requires much more work than Gouraud shading Until recently not available in real time systems Now can be done using fragment shaders (see Chapter 9) Both need data structures to represent meshes so we can obtain vertex normals