Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shading II CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.

Similar presentations


Presentation on theme: "Shading II CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel."— Presentation transcript:

1 Shading II CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel

2 Objectives Continue discussion of shading. Introduce modified Phong model. Consider computation of required vectors. CS4395: Computer Graphics 2

3 Recap: Ambient Light Ambient light is the result of interactions between (large) light sources and the environmental objects. Amount and color depend on the color of the light(s) and the material properties of the object. Add k a I a to diffuse and specular terms. CS4395: Computer Graphics 3 reflection coeff intensity of ambient light

4 Effect of Distance 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 +cd 2 ) to the diffuse and specular terms. The constant and linear terms soften the effect of the point source. CS4395: Computer Graphics 4

5 Recap: Light Sources Phong Model: add the results from each light source. Each light source has separate diffuse, specular, and ambient terms: provides flexibility even though it does not have a physical justification. Separate red, green and blue components. Hence, 9 coefficients for each point source: – I dr, I dg, I db, I sr, I sg, I sb, I ar, I ag, I ab CS4395: Computer Graphics 5

6 Recap: Material Properties Material properties match light source properties: – Nine absorbtion coefficients: k dr, k dg, k db, k sr, k sg, k sb, k ar, k ag, k ab – Shininess coefficient . CS4395: Computer Graphics 6

7 Adding up the Components For each light source and each color component, the Phong model can be written (without the distance terms) as: I = k d L d l · n + k s L s (v · r )  + k a L a For each color component we add contributions from all sources. CS4395: Computer Graphics 7

8 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. CS4395: Computer Graphics 8

9 The Halfway Vector h is normalized vector halfway between l and v: CS4395: Computer Graphics 9 h = ( l + v )/ | l + v |

10 Using the halfway vector Replace (v · r )  by (n · h )   is chosen to match shininess. 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. CS4395: Computer Graphics 10

11 Example Only differences in these teapots are the parameters in the modified Phong model. CS4395: Computer Graphics 11

12 Computation of Vectors l and v are specified by the application. Can compute r from l and n. Problem is determining n. Computation of n differs depending on underlying representation of surface. OpenGL leaves determination of normal to application: – Exception for GLU quadrics and Bezier surfaces (Chapter 11). CS4395: Computer Graphics 12

13 Plane Normals Equation of plane: ax+by+cz+d = 0 From Chapter 4 we know that plane is determined by three points p 0, p 2, p 3 or normal n and p 0 Normal can be obtained by: CS4395: Computer Graphics 13 n = (p 2 -p 0 ) × (p 1 -p 0 )

14 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 CS4395: Computer Graphics 14

15 Parametric Form For sphere: Tangent plane determined by vectors: Normal given by cross product: CS4395: Computer Graphics 15 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

16 General Case We can compute parametric normals for other simple cases: – Quadrics. – Parametric polynomial surfaces: Bezier surface patches (Chapter 11). CS4395: Computer Graphics 16


Download ppt "Shading II CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel."

Similar presentations


Ads by Google