1 CSC 830 Computer Graphics Lecture 5 Shading Course Note Credit: Some of slides are extracted from the course notes of prof. Mathieu Desburn (USC) and.

Slides:



Advertisements
Similar presentations
CSPC 352: Computer Graphics
Advertisements

Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 21: Radiometry Many slides courtesy Pat Hanrahan.
Physically Based Illumination Models
Advanced Computer Graphics (Spring 2013) CS 283, Lecture 8: Illumination and Reflection Many slides courtesy.
1 Computer Graphics By : Mohammed abu Lamdy ITGD3107 University of Palestine Supervision: Assistant Professor Dr. Sana’a Wafa Al-Sayegh.
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.
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
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading III Week.
Rendering (彩現 渲染).
IMGD 1001: Illumination by Mark Claypool
Lighting and Shading Wen-Chieh (Steve) Lin
Computer Graphics (Fall 2008) COMS 4160, Lecture 19: Illumination and Shading 2
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.
Computer Graphics (Fall 2004) COMS 4160, Lecture 16: Illumination and Shading 2 Lecture includes number of slides from.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Illumination and Shading
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
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
Computer Graphics Lighting.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
Shading and Illumination. OpenGL Shading Without ShadingWith Shading.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
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.
CSE 381 – Advanced Game Programming GLSL Lighting.
11/04/04© University of Wisconsin, CS559 Fall 2004 Last Time Visibility –Z-Buffer and transparency –A-buffer –Area subdivision –BSP Trees –Exact Cell-Portal.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Material Representation K. H. Ko School of Mechatronics Gwangju Institute.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
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.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
In the name of God Computer Graphics. Where We Stand So far we know how to: –Transform between spaces –Draw polygons Next –Deciding a pixel’s intensity.
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
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,
CS552: Computer Graphics Lecture 33: Illumination and Shading.
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.
1 Dr. Scott Schaefer Lighting. 2/49 Lighting/Illumination Color is a function of how light reflects from surfaces to the eye Global illumination accounts.
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
Illumination and Shading
Unit-7 Lighting and Shading
Illumination and Shading
Computer Graphics (Fall 2003)
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

1 CSC 830 Computer Graphics Lecture 5 Shading Course Note Credit: Some of slides are extracted from the course notes of prof. Mathieu Desburn (USC) and prof. Han-Wei Shen (Ohio State University).

2 Shading Determining the light traveling from a point in the scene to the viewer’s eye Images courtesy of Watt, Watt & Watt, and Foley & van Dam

3 Shading Light comes from many sources: scattering absorption reflection transmission emission

4 Local versus Global Illumination  Global Illumination  Considers indirect illumination  Reflection  Refraction  Shadows  Local Illumination  Only considers direct illumination  No reflection  No refraction  Shadows possible

5 Local versus Global Illumination Indirect Illumination Direct Illumination We will do local only for this lecture…

6 Local illumination Only consider the light, the observer position, and the object material properties

7 Local versus Global Illumination Images courtesy of Francois Sillion To understand shading properly, we need to review some basic notions of physics…

8 Basic Illumination Model Simple and fast method for calculating surface intensity at a given point Lighting calculation are based on: –The background lighting conditions –The light source specification: color, position –Optical properties of surfaces: Glossy OR matte Opaque OR transparent (control refection and absorption)

9 Radiance Radiance: Power per unit projected area perpendicular to the ray, per unit solid angle in the direction of the ray Think of it as a flux of photons leaving the surface…

10 Irradiance Irradiance: Radiant energy per unit area Think of it as a flux of photons bombarding the surface…

11 BRDF Bidirectional Reflection Distribution Function Determines the fraction of light from an incoming direction reflected to an outgoing direction Image courtesy of Watt, 3D Computer Graphics Relates reflected radiance to incoming irradiance…

12 Properties of the BRDF Reciprocity In photography and holography, reciprocity refers to the relationshipphotographyholography between the intensity of the light and duration of the exposure that result in identical exposure. Within the normal range for intensity and time for theexposure film, the reciprocity law states that exposure = intensity × time. Outside the normal range the reciprocity law breaks down, which is known as reciprocity failure.

13 Properties of the BRDF Anisotropy Anisotropy (the opposite of isotropy) is the property of being directionallyisotropy dependent. In the field of computer graphics, an anisotropic surface will change incomputer graphics appearance as it is rotated about its geometric normal, as is the case withnormal velvetvelvet. Anisotropic scaling occurs when something is scaled by different amounts in different directions.

14 Reflectance Equation BRDF allows us to calculate outgoing light, given incoming light Image courtesy of Watt, 3D Computer Graphics

15 Splitting the BRDF In practice, BRDF can be really funky… To simplify, we divide the BRDF into 3 components:

16 Reflectance 3 forms Slide Courtesy of Dutre et. al on SIGGRAPH 2001

17 Ideal Specular Reflection Reflection is only in the mirror direction

18 Ideal Diffuse Reflection Reflection is equal in all directions

19 Directional Diffuse Reflection Reflection is concentrated around the mirror direction

20 Ambient Light If a surface is visible from the eye, but not a light, it will be rendered black (if indirect light is not considered). Ambient light is an approximation to indirect light  Difficult to compute  Approximate this as a constant  Or a light source at the eye

21 Phong Reflection Assume point lights and direct illumination only

22 Diffuse Light The illumination that a surface receives from a light source and reflects equally in all directions This type of reflection is called Lambertian Reflection (thus, Lambertian surfaces) The brightness of the surface is indepenent of the observer position (since the light is reflected in all direction equally)

23 Lambert’s Law How much light the surface receives from a light source depends on the angle between its angle and the vector from the surface point to the light (light vector) Lambert’s law: the radiant energy ’I d ’ from a small surface d a for a given light source is: I d = I L * cos  ) I L : the intensity of the light source  is the angle between the surface normal (N) and light vector (L)

24 Phong Diffuse Component Diffuse component depends only on incident angle. Image courtesy of Watt, 3D Computer Graphics Note: L and N are unit…

25 Examples Sphere diffusely lighted from various angles !

26 Specular Light  These are the bright spots on objects (such as polished metal, apple...)  Light reflected from the surface unequally to all directions.  The result of near total reflection of the incident light in a concentrated region around the specular reflection angle

27 Specular Highlights Shiny surfaces change appearance when viewpoint is changed Specularities are caused by microscopically smooth surfaces. A mirror is a perfect specular reflector

28 Phong Specular Component Phong combines directional diffuse & ideal specular Image courtesy of Watt, 3D Computer Graphics

29 Half Vector An alternative way of computing phong lighting is: Is = ks * Is * (N*H) n H (halfway vector): halfway between V and L: (V+L)/2 Fuzzier highlight Check dex.php?ogldir2 dex.php?ogldir2 L N H V

30 Phong Illumination Moving Light Change n

31 Phong Ambient Component Treat it as a constant: Where is the ambient light in the scene.

32 Adding Color

33 Adding Lights

34 Phong Reflection Image courtesy of Watt, 3D Computer Graphics

35 Aluminium

36 Bronze

37 Chrome

38 Stainless Steel

39 OpenGL Materials GLfloat white8[] = {.8,.8,.8, 1.}, white2 = {.2,.2,.2,1.},black={0.,0.,0.}; GLfloat mat_shininess[] = {50.}; /* Phong exponent */ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, black); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, white8); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white2); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);

40 OpenGL Lighting GLfloat white[] = {1., 1., 1., 1.}; GLfloat light0_position[] = {1., 1., 5., 0.}; /* directional light (w=0) */ glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, white); glLightfv(GL_LIGHT0, GL_SPECULAR, white); glEnable(GL_LIGHT0); glEnable(GL_NORMALIZE); /* normalize normal vectors */ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);/* two-sided lighting*/ glEnable(GL_LIGHTING);

41 Vertex Normals vs. Face Normals What are the normals to the surface? Each polygonal face has a normal. We call these face normals. a c b N = (b - a) x (c - b)

42 Flat Shading Assume a constant color across the polygon Uses face normals Equivalent to single point sampling… a c b Polygon mesh is only an approximation. Can we do better?

43 Vertex Normals vs. Face Normals Should use the actual surface’s normals Usually stored at the vertices of the object Can calculate as averages of face normals

44 Mach Band ?

45 Mach Band ?

46 Shading Models for Polygons  Constant Shading (flat shading)  Compute illumination at any one point on the surface. Use face or one normal from a pair of edges. Good for far away light and viewer or if facets approximate surface well.  Per-Pixel Shading  Compute illumination at every point on the surface.  Interpolated Shading  Compute illumination at vertices and interpolate color

47 Interpolation  Gouraud Interpolation  Phong Interpolation Given vertex normals, how to color the interior:

48 Un-lit

49 Flat Shading

50 Gouraud Interpolation – Interpolated Shading

51 Phong Interpolation – Per pixel Shading

52 Gouraud Interpolation Calculate the color at each vertex Interpolate the colors C(a) C(c) C(b) C(a) C(c) C(b) C = t C(b) + (1 – t) C(c)

53 Gouraud Interpolation Problems Misses some highlights light Shading is not linear shading will be constant!

54 Phong Interpolation Interpolate the normals, then compute the colors light Interpolation is usually done component-wise

55 Phong Shading Model  Gouraud shading does not properly handle specular highlights, specially when the n parameter is large (small highlight).  Reason: colors are interpolated.  Solution: (Phong Shading Model)  1. Compute averaged normal at vertices.  2. Interpolate normals along edges and scan-lines. (component by component)  3. Compute per-pixel illumination.

56

57 Interpolation Image courtesy of Watt & Watt, Advanced Animation and Rendering Techniques

58 Interpolated Shading - Problems  Problems at shared vertices – shared by right polygons and not by one on left and hence discontinuity  Incorrect Vertex normals – no variation in shade

59 Shade Trees dot N L N H * IlIl * IlIl pow n + Phong Shade Tree: IaIa * ka kd ks

60 Shading Language A language for implementing shading models State is passed to/from the shader by global variables Ci – Outgoing ray color Oi – Outgoing ray opacity Cs – Surface color Os – Surface opacity P – Surface point N - Surface normal I - Direction of viewing (eye ray) L - Direction to the light source I N L

61 Shading Language surface plastic(float Ks =.5, float Kd =.5, float Ka = 1, float roughness =.1, color specularColor = 1) { point Nf = faceforward(N,I); Oi = Os; Ci = Os*(Cs*(Ka*ambient()+Kd*diffuse(Nf) + specularColor*Ks*specular(Nf,-I,roughness); } Phong Surface Shader:

62 Light Sources Point light source Directional light source: e.g. sun light Spot light

63 Spot Light To restrict a light’s effects to a limited area of the scene Flap: confine the effects of the light to a designed range in x, y, and z world coordinate Cone: restrict the effects of the light using a cone with a generating angle 

64 Light Source Attenuation Takes into account the distance of the light from the surface I’ L = I L * fatt (d) I’ L : the received light after attenuation I L : the original light strength fatt: the attenuation factor d: the distance between the light source and the surface point fatt = max ( 1/(c1 + c2*d + c3*d 2 ), 1) C1, C2, C3 are user defined constants associated with each light source

65 Hints for HW4 Shading can be done in easily in view space or in world space where all light, view, & surface normal vectors are described in same coordinate space. – how can you achieve this effect? For normal transformation, use only 3x3 rotation matrix out of the 4x4 transformation & inverse transpose of it – remember normal transformation from the lecture 2? For Phong shading, interpolate normal & compute shading for each pixel. For Gouraud shading, compute shading at only vertex and interpolate the color.