Shading II. CITS3003 Graphics & Animation

Similar documents
Objectives. Shading II. Distance Terms. The Phong Reflection Model

Objectives. Continue discussion of shading 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.

Shading. Why we need shading. Scattering. Shading. Objectives

Shading II. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Comp 410/510 Computer Graphics. Spring Shading

Objectives. Introduce Phong model Introduce modified Phong model Consider computation of required vectors Discuss polygonal shading.

Introduction to Computer Graphics 7. Shading

Illumination & Shading

Overview. Shading. Shading. Why we need shading. Shading Light-material interactions Phong model Shading polygons Shading in OpenGL

CS 4600 Fall Utah School of Computing

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Computer Graphics. Shading. Based on slides by Dianna Xu, Bryn Mawr College

Lessons Learned from HW4. Shading. Objectives. Why we need shading. Shading. Scattering

Lighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics V. Guoying Zhao 1 / 65

Why we need shading?

Shading I Computer Graphics I, Fall 2008

CS452/552; EE465/505. Lighting & Shading

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

Illumination in Computer Graphics

CS452/552; EE465/505. Intro to Lighting

Lecture 9: Transformations. CITS3003 Graphics & Animation

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

CS 432 Interactive Computer Graphics

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Illumination and Shading

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Introduction to Computer Graphics with WebGL

Today we will start to look at illumination models in computer graphics

CS Illumination and Shading. Slide 1

Computer Graphics. Illumination Models and Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

Introduction to Computer Graphics. Farhana Bandukwala, PhD Lecture 14: Light Interacting with Surfaces

Graphics for VEs. Ruth Aylett

Reflection and Shading

Illumination & Shading I

Lighting. Figure 10.1

Chapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

CS230 : Computer Graphics Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

CHAPTER5. We have learned to build three-dimensional graphical models and to LIGHTING AND SHADING

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Graphics for VEs. Ruth Aylett

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Texture Mapping. Michael Kazhdan ( /467) HB Ch. 14.8,14.9 FvDFH Ch. 16.3, , 16.6

-=Bui Tuong Phong's Lighting=- University of Utah, but with shaders. Anton Gerdelan Trinity College Dublin

3D Modelling: Animation Fundamentals & Unit Quaternions

Rendering Light Reflection Models

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Shading. Brian Curless CSE 557 Autumn 2017

Specular Reflection. Lecture 19. Robb T. Koether. Hampden-Sydney College. Wed, Oct 4, 2017

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Graphics and Visualization

Virtual Reality for Human Computer Interaction

Supplement to Lecture 16

Simple Lighting/Illumination Models

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

Shading Intro. Shading & Lighting. Light and Matter. Light and Matter

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

CSE 681 Illumination and Phong Shading

Computer Graphics. Illumination and Shading

Shading. Brian Curless CSE 457 Spring 2017

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Lab 9 - Metal and Glass

CS5620 Intro to Computer Graphics

CSE 167: Lecture #7: Color and Shading. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Global Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Shading 1: basics Christian Miller CS Fall 2011

Illumination Models & Shading

Raytracing. COSC 4328/5327 Scott A. King

w Foley, Section16.1 Reading

Illumination and Shading

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

CHAPTER 1 Graphics Systems and Models 3

Ligh%ng in OpenGL. The Phong Illumina%on Model. Vector Background

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

Illumination & Shading: Part 1

Visualisatie BMT. Rendering. Arjan Kok

OpenGL Lighting Computer Graphics Spring Frank Palermo

Complex Shading Algorithms

Reading. Shading. An abundance of photons. Introduction. Required: Angel , 6.5, Optional: Angel 6.4 OpenGL red book, chapter 5.

CGT520 Lighting. Lighting. T-vertices. Normal vector. Color of an object can be specified 1) Explicitly as a color buffer

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

recruitment Logo Typography Colourways Mechanism Usage Pip Recruitment Brand Toolkit

CS 418: Interactive Computer Graphics. Basic Shading in WebGL. Eric Shaffer

Introduction to Visualization and Computer Graphics

CPSC 314 LIGHTING AND SHADING

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

Blue colour text questions Black colour text sample answers Red colour text further explanation or references for the sample answers

Color and Light. CSCI 4229/5229 Computer Graphics Summer 2008

CS770/870 Spring 2017 Color and Shading

Lighting and Shading

Transcription:

Shading II CITS3003 Graphics & Animation

Objectives Introduce distance terms to the shading model. More details about the Phong model (lightmaterial interaction). Introduce the Blinn lighting model (also known as the modified Phong model). Consider computation of the normal vectors of some simple surfaces. 2

Distance Terms Most shading calculations require the direction from the point on the surface to the light source position. As we move across a surface, calculating the intensity at each point, we should re-compute this vector repeatedly. However, if the light source is far from the surface, the vector does not change much as we move from point to point. The calculations for distant light sources are similar to the calculations for parallel projections; they replace the location of the light source with the direction of the light source. Point Source PP 0 = xx yy zz 1, Distant Source PP 0 = xx yy zz 0 3

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/(aa + bbbb + cccc 2 ) to the diffuse and specular terms for both point sources and spotlights The constant (aa) and linear (bbbb) terms soften the effect of the point source Note: the distance term should not be applied to the ambient term. 4

The Phong Reflection Model Recall that the Phong Model: Is a simple model that can be computed rapidly Has three terms - Diffuse term - Specular term - Ambient term Uses the four vectors below to calculate a colour for an arbitrary point pp on a surface: - Vector ll (to light source) - Vector vv (to viewer or camera) - Vector nn (Normal vector at p) - Vector rr (Perfect reflector of ll with respect to nn) 5

Shading the Light Source Part In the Phong Model, we add the shading results from all the light sources together. 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. Each term has its own red, green and blue components. Hence, there are 9 coefficients for each point source: LL dr, LL dg, LL db, LL sr, LL sg, LL sb, LL ar, LL ag, LL ab 6

Shading the Light Source Part We can place these nine coefficients in a 3 3 illumination matrix for the i th light source:. In practice, we will use constructs such as vec3 light_i_ambient, light_i_diffuse, light_i_specular; Or vec4 light_i_ambient, light_i_diffuse, light_i_specular; 7

Shading the Reflection Part We construct the model by assuming that we can compute how much of each of the incident lights is reflected at the point of interest. For example, for the red diffuse term from source i, L ird, we can compute a reflection term R ird, and the latter s contribution to the intensity at p is R ird L ird. 8

Shading Material Properties Surfaces of objects have their material properties to compute with the light source properties, i.e., - There are nine absorption coefficients kk dr, kk dg, kk db, kk sr, kk sg, kk sb, kk ar, kk ag, kk ab - and a shininess coefficient α 9

Ambient Term The intensity of ambient light I a is the same at every point on the surface. Some of this light is absorbed and some is reflected. The amount reflected is given by the ambient reflection coefficient, R a = k a. 0 < k a < 1 Thus, I a = k a L a 10

Diffuse Term A perfectly diffuse reflector scatters the light that it reflects equally in all directions. Such a surface appears the same to all viewers. However, the amount of light reflected depends both on the material and on the position of the light source relative to the surface. R d cos θ cos θ = ll. nn I d = L d R d = LL dd (ll. nn)kk dd 11

Specular Term Whereas a diffuse surface is rough, a specular surface is smooth. The smoother the surface is, the more it resembles a mirror. Phong proposed an approximate model that can be computed with only a slight increase over the work done for diffuse surfaces. I s = LL ss R s = kk ss LL ss cos αα φφ I s = kk ss LL ss (r. v) αα φφ 12

Shading Adding up the Components For each light source and each color component, the Phong model can be written (without the distance terms) as II = kk d LL d ll nn + kk s LL s vv rr αα + kk a LL a For each colour component we add contributions from all light sources There are 3 such equations: one for red, one for green, and one for blue. 13

The Phong Shading Model Computing the perfect reflector rr To compute the shading value II on the previous slide, we need to know those vectors in the model. The normal vector nn is determined by the local orientation at point pp. Vector ll and vv are specified by the application. We can compute rr from ll and nn - We want: Angle of incidence θθ i = angle of reflection θθ r. - The three vectors ll, nn, and rr must be coplanar. - It is easy to verify that rr = 2 (ll nn ) nn ll Letter l, not 1. 14

The Modified Phong Model or Blinn Lighting Model The specular term in the Phong model is problematic because it requires the calculation of a new reflection vector rr for each vertex and then the dot product with vv. Blinn suggested an approximation using the halfway vector that is more efficient This is referred to as the modified Phong reflection model or the Blinn-Phong shading model (the terminology varies in many textbooks, the term lighting is also used instead of reflection and shading ). 15

The Blinn-Phong Model the Halfway Vector Instead of computing rr, the hh vector which is a normalized vector halfway between ll and vv is used: 16

The Blinn-Phong Model using the halfway vector Having got the halfway vector hh, we replace vv rr αα by (nn hh ) ββ where ββ is chosen to match the shininess of the material Note that halfway angle is half of angle between rr and vv if vectors are coplanar The resulting model is known as the modified Phong or Blinn lighting model. The model can be written as (without the distance term): II = kk d LL d ll nn + kk s LL s nn h ββ + kk a LL a The Blinn lighting model is the default shading model in OpenGL 17

Examples Colour plate 17 from the book: Array of Utah teapots with different material properties. 18

NORMAL VECTOR 19

20

21

22

Computation of Normal Vector nn Whether we use the Phong model or the Blinn model, we need to also determine the normal vector nn at each point pp. But how do we determine nn in general? For simple surfaces like spheres there are formulas, but how we determine nn differs depending on underlying representation of surface. OpenGL leaves the determination of normals to the application. 23

Computing the Normal Vector nn for a Plane Equation of plane: aaaa + bbbb + cccc + dd = 0 From Chapter 3 we know that a plane is determined by o three points pp 0, pp 1, pp 2 or by o a normal nn and pp 0 The normal vector can be obtained by: nn = (pp 2 pp 0 ) (pp 1 pp 0 ) We then normalize nn to a unit vector. p 0 n p p 2 p 1 24

Computing the Normal Vector nn for a Sphere If we have an implicit representation of a sphere (with unit radius and centre at the origin): ff xx, yy, zz = 0 xx 2 + yy 2 + zz 2 1 = 0 The normal vector nn at a point pp is given by gradient of ff at pp, i.e., T nn =,, xx yy zz =[2x,2y,2z] T = 2p 25

Computing the Normal Vector nn for a Sphere If we have a parametric representation of a sphere: xx = xx(uu, vv) = cos uu sin vv yy = yy(uu, vv) = cos uu cos vv zz = zz(uu, vv) = sin uu The tangent plane is determined by the vectors pp/ = [ /, /, / ] T pp/ = [ /, /, / ] T The normal vector is given by the cross product nn = pp/ pp/ 26

Computing the Normal Vector nn the General Case We can also compute the normal vectors of for other simple surfaces: - Quadrics - Parametric polynomial surfaces E.g., Bezier surface patches (Chapter 10) In general, the 3D surface data generated by most 3D scanners contain both vertex coordinates and vertex normals. 27

References Interactive Computer Graphics A Top-Down Approach with Shader-Based OpenGL by Edward Angel and Dave Shreiner, 6 th Ed, 2012 Sec. 5.3. The Phong Reflection Model Sec. 5.4. Computation of Vectors 28