Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

SI23 Introduction to Computer Graphics
7.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 7 Polygon Shading Techniques.
CSPC 352: Computer Graphics
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Illumination and Shading
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.
Illumination Model & Surface-rendering Method 박 경 와.
Computer Graphics - Class 10
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading III Week.
Rendering (彩現 渲染).
IMGD 1001: Illumination by Mark Claypool
(conventional Cartesian reference system)
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.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
©Larry F. Hodges (modified by Amos Johnson) 1 Shading Models.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Illumination and Shading
Course Website: Computer Graphics 16: Illumination.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
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.
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.:
CS 445 / 645: Introductory Computer Graphics
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
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.
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
08 |Lighting and Shading Eriq Muhammad Adams J |
Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Illumination and Shading How to shade surfaces based on the position,orientation,characteristics of the surfaces and the light sources illuminating them.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading.
Illumination and Shading
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Local Illumination and Shading
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
Lighting and Shading Part 2. Global Ambient Light There are at least 8 OpenGL lights and 1 Global Ambient Setting the Global Ambient globalAmbient[] =
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Illumination and Shading Sang Il Park Sejong University.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
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: Illumination
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Computer Graphics Lecture 26 Mathematics of Lighting and Shading Part II Taqdees A. Siddiqi
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
Illumination : Hearn & Baker Ch. 10
Shading To determine the correct shades of color on the surface of graphical objects.
Illumination and Shading
Unit-7 Lighting and Shading
Chapter 14 Shading Models.
Lighting.
CSE 470 Introduction to Computer Graphics Arizona State University
Illumination and Shading
Fundamentals of Computer Graphics Part 6 Shading
Isaac Gang University of Mary Hardin-Baylor
Illumination and Shading
Computer Graphics Material Colours and Lighting
Chapter 14 Shading Models.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
CS 480/680 Computer Graphics Shading.
Lighting Calculations
Presentation transcript:

Illumination and Shading

Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL computes illumination at vertices illumination

Shading Apply the lighting model at a set of points across the entire surface Shading

Illumination Model The governing principles for computing the illumination A illumination model usually considers : Light attributes (light intensity, color, position, direction, shape) Object surface attributes (color, reflectivity, transparency, etc) Interaction among lights and objects (object orientation) Interaction between objects and eye (viewing dir.)

Illumination Calculation Local illumination: only consider the light, the observer position, and the object material properties Example: OpenGL 

Illumination Models Global illumination: take into account the interaction of light from all the surfaces in the scene Example: Ray Tracing (CIS681) object 1 object 2 object 3 object 4

Basic Light Sources Point lightDirectional light Spot light Light intensity can be independent or dependent of the distance between object and the light source sun

Calculating Reflection Vector The scalar projection of Lon N is a scalar equal to

Simple local illumination Consider three types of light contribution to compute the final illumination of an object Ambient Diffuse Specular Final illumination of a point (vertex) = ambient + diffuse + specular

Ambient light contribution Ambient light (background light): the light that is scattered by the environment A very simple approximation of global illumination Independent of the light position,object orientation, observer’s position or orientation – ambient light has no direction (Radiosity is the calculation of ambient light) object 1 object 2 object 3 object 4

Ambient lighting example

Ambient light calculation Each light source has an ambient light contribution (I a ) Different objects can reflect different amounts of ambient (different ambient reflection coefficient Ka, 0 <= K a <= 1 ) So the amount of ambient light that can be seen from an object is: Ambient = I a * K a

Diffuse light contribution Diffuse light: The illumination that a surface receives from a light source and reflects equally in all direction It does not matter where the eye is

Diffuse lighting example

Diffuse light calculation Need to decide how much light the object point receive from the light source – based on Lambert’s Law Receive more light Receive less light

Diffuse light calculation (2) Lambert’s law: the radiant energy D that a small surface patch receives from a light source is: D = I * cos (  ) I: light intensity  : angle between the light vector and the surface normal N : surface normal light vector (vector from object to light) 

Diffuse light calculation (3) Like the ambient light case, different objects can reflect different amount of diffuse light (different diffuse reflection coefficient K d, 0 <= K d <= 1 )) So, the amount of diffuse light that can be seen is: Diffuse = K d * I * cos (  )   N L cos(  ) = N.L

Specular light contribution The bright spot on the object The result of total reflection of the incident light in a concentrate region See nothing!

Specular light example

Specular light calculation How much reflection you can see depends on where you are The only position the eye can see specular from P if the object has an ideal reflection surface But for a non-perfect surface you will still see specular highlight when you move a little bit away from the idea reflection direction When  is small, you see more specular highlight  ? p 

Specular light calculation (2) Phong lighting model specular = K s * I * cos n (  ) K s : specular reflection coefficient N: surface normal at P I: light intensity  : angle between V and R cos(  ): the larger is n, the smaller is the cos value cos(  ) = R.V  p  V R N L n

Specular light calculation (3) The effect of ‘n’ in the phong model n = 10 n = 30 n = 90 n = 270

Put it all together Illumination from a light: Illum = ambient + diffuse + specular = K a * I + K d * I * (N.L) + K s * I * (R.V) n If there are N lights Total illumination for a point P =  (Illum) Some more terms to be added (in OpenGL): Self emission Global ambient Light distance attenuation and spot light effect (N.H) or

Polygon shading model Flat shading – compute lighting once and assign the color to the whole polygon

Flat shading Only use one vertex (usually the first one) normal and material property to compute the color for the polygon Benefit: fast to compute It is used when: The polygon is small enough The light source is far away (why?) The eye is very far away (why?) OpenGL command: glShadeModel(GL_FLAT)

Mach Band Effect Flat shading suffers from “mach band effect” Mach band effect – human eyes accentuate the discontinuity at the boundary Side view of a polygonal surface perceived intensity

Smooth shading Reduce the mach band effect – remove value discontinuity Compute lighting for more points on each face Flat shading smooth shading

Gouraud Shading Gouraud shading attempts to smooth out the shading across the polygon facets Begin by calculating the normal at each vertex N

Gouraud Shading averaging A feasible way to do this is by averaging the normals from surrounding facets intensities Then apply the reflection model to calculate intensities at each vertex N

Gouraud Shading linear interpolation We use linear interpolation to calculate intensity at edge intersection P I P RED = (1-  I P1 RED +  I P2 RED where P divides P1P2 in the ratio  Similarly for Q P4 P2 P1 P3 P Q

Gouraud Shading Then we do further linear interpolation to calculate colour of pixels on scanline PQ P2 P1 P3 P Q

Gouraud Shading

Gouraud Shading Limitations - Specular Highlights Gouraud shading gives intensities within a polygon which are a weighted average of the intensities at vertices a specular highlight at a vertex tends to be smoothed out over a larger area than it should cover a specular highlight in the middle of a polygon will never be shown

Gouraud Shading Limitations - Mach Bands The rate of change of pixel intensity is even across any polygon, but changes as boundaries are crossed Mach banding This ‘discontinuity’ is accentuated by the human visual system, so that we see either light or dark lines at the polygon edges - known as Mach banding

Phong Shading Phong shading has a similar first step, in that vertex normals are calculated - typically as average of normals of surrounding faces N

Phong Shading However rather than calculate intensity at vertices and then interpolate intensities as we do in Gouraud shading... In Phong shading we interpolate normals at each pixel... P4 P2 P1 P3 P Q N2 N1 N

Phong Shading... and apply the reflection model at each pixel to calculate the intensity - I RED, I GREEN, I BLUE P4 P2 P1 P3 P Q N2 N1 N

Phong Shading

Phong versus Gouraud Shading A major advantage of Phong shading over Gouraud is that specular highlights tend to be much more accurate vertex highlight is much sharper a highlight can occur within a polygon Also Mach banding greatly reduced The cost is a substantial increase in processing time because reflection model applied per pixel But there are limitations to both Gouraud and Phong

Gouraud versus Phong