CS559: Computer Graphics Lecture 15: Hierarchical Modeling and Shading Li Zhang Spring 2008.

Slides:



Advertisements
Similar presentations
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
Advertisements

2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Physically Based Illumination Models
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.
Computer Graphics - Class 10
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
Computer Graphics (Spring 2008) COMS 4160, Lecture 20: Illumination and Shading 2
Lighting and Shading Wen-Chieh (Steve) Lin
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.
Graphical Objects and Scene Graphs CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Hierarchical Transformations Hierarchical Models Scene Graphs
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
COMP 175: Computer Graphics March 10, 2015
Objectives Review some advanced topics, including Review some advanced topics, including Chapter 8: Implementation Chapter 8: Implementation Chapter 9:
Shading / Light Thanks to Srinivas Narasimhan, Langer-Zucker, Henrik Wann Jensen, Ravi Ramamoorthi, Hanrahan, Preetham.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
CS 445: Introduction to Computer Graphics David Luebke University of Virginia Visibility Calculations and Occlusion Culling.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Week 4 Lecture 1: Hierarchical Modeling Part 1 Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E ©
Hierarchical Modeling. Instance Transformation Start with a prototype object (a symbol) Each appearance of the object in the model is an instance – Must.
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.
111/16/ :14 UML Instance Transformation x y z x y z x y z x y z SRT Model Coordinates.
Diffuse Reflections from Rough Surfaces Lecture #5
Announcements Office hours today 2:30-3:30 Graded midterms will be returned at the end of the class.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
Transformations Tutorial
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Computer Graphics (Spring 2003) COMS 4160, Lecture 18: Shading 2 Ravi Ramamoorthi Guest Lecturer: Aner Benartzi.
David Luebke1/10/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Shading.
Local Illumination and Shading
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Hierarchical Modeling.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
COMPUTER GRAPHICS CS 482 – FALL 2015 OCTOBER 27, 2015 SCATTERING LIGHT SCATTERING PHYSICALLY BASED SCATTERING SUBSURFACE SCATTERING AMBIENT OCCLUSION.
CDS 301 Fall, 2008 From Graphics to Visualization Chap. 2 Sep. 3, 2009 Jie Zhang Copyright ©
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Computer Graphics Lecture 25 Fasih ur Rehman. Last Class Shading.
Computer Graphics Lecture 30 Mathematics of Lighting and Shading - IV Taqdees A. Siddiqi
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
Computer Graphics: Illumination
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
Computer Graphics (fall,2010) School of Computer Science University of Seoul Minho Kim.
© University of Wisconsin, CS559 Spring 2004
CSCE 441: Computer Graphics: Hierarchical Models
Chapter IX Lighting.
Computer Graphics (Fall 2003)
CS 480/680 Computer Graphics Shading.
Hierarchical Modeling
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

CS559: Computer Graphics Lecture 15: Hierarchical Modeling and Shading Li Zhang Spring 2008

Today Finish transformation in OpenGL Lighting Reading – Shirley, Ch 9.1, 9.2

Connecting primitives glLoadIdentity(); draw_block_A(); glTranslate(0, h, 0); Draw_block_B(); glLoadIdentity(); draw_block_A(); glTranslate(0, h, 0); Draw_block_B(); glLoadIdentity(); draw_block_A(); glTranslate(0, h, 0); glRotate(-90, 0, 0, 1); Draw_block_B(); glLoadIdentity(); draw_block_A(); glTranslate(0, h, 0); glRotate(-90, 0, 0, 1); Draw_block_B(); A B

3D Example: A robot arm Consider this robot arm with 3 degrees of freedom: – Base rotates about its vertical axis by  – Upper arm rotates in its xy-plane by  – Lower arm rotates in its xy-plane by  h1h1 h2h2 h3h3 Base Upper arm Lower arm Q: What matrix do we use to transform the base to the world? R_y(  ) Q: What matrix for the upper arm to the base? T(0,h1,0)R_z(  ) Q: What matrix for the lower arm to the upper arm? T(0,h2,0)R_z(  ) z x y x y x

Robot arm implementation The robot arm can be displayed by keeping a global matrix and computing it at each step: Matrix M_model; display(){... robot_arm();... } robot_arm() { M_model = R_y(theta); base(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi); upper_arm(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi)*T(0,h2,0)*R_z(psi); lower_arm(); } Matrix M_model; display(){... robot_arm();... } robot_arm() { M_model = R_y(theta); base(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi); upper_arm(); M_model = R_y(theta)*T(0,h1,0)*R_z(phi)*T(0,h2,0)*R_z(psi); lower_arm(); } Do the matrix computations seem wasteful? How to translate the whole robot? Q: What matrix do we use to transform the base to the world? R_y(  ) Q: What matrix for the upper arm to the base? T(0,h1,0)R_z(  ) Q: What matrix for the lower arm to the upper arm? T(0,h2,0)R_z(  ) Q: What matrix do we use to transform the base to the world? R_y(  ) Q: What matrix for the upper arm to the base? T(0,h1,0)R_z(  ) Q: What matrix for the lower arm to the upper arm? T(0,h2,0)R_z(  )

Instead of recalculating the global matrix each time, we can just update it in place by concatenating matrices on the right: Robot arm implementation, better Matrix M_model; display(){... M_model = identity; robot_arm();... } robot_arm() { M_model *= R_y(theta); base(); M_model *= T(0,h1,0)*R_z(phi); upper_arm(); M_model *= T(0,h2,0)*R_z(psi); lower_arm(); } Matrix M_model; display(){... M_model = identity; robot_arm();... } robot_arm() { M_model *= R_y(theta); base(); M_model *= T(0,h1,0)*R_z(phi); upper_arm(); M_model *= T(0,h2,0)*R_z(psi); lower_arm(); }

OpenGL maintains the model-view matrix, as a global state variable which is updated by concatenating matrices on the right. display() {... glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); robot_arm();... } robot_arm() { glRotatef( theta, 0.0, 1.0, 0.0 ); base(); glTranslatef( 0.0, h1, 0.0 ); glRotatef( phi, 0.0, 0.0, 1.0 ); lower_arm(); glTranslatef( 0.0, h2, 0.0 ); glRotatef( psi, 0.0, 0.0, 1.0 ); upper_arm(); } display() {... glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); robot_arm();... } robot_arm() { glRotatef( theta, 0.0, 1.0, 0.0 ); base(); glTranslatef( 0.0, h1, 0.0 ); glRotatef( phi, 0.0, 0.0, 1.0 ); lower_arm(); glTranslatef( 0.0, h2, 0.0 ); glRotatef( psi, 0.0, 0.0, 1.0 ); upper_arm(); } Robot arm implementation, OpenGL

Hierarchical modeling Hierarchical models can be composed of instances using trees: – edges contain geometric transformations – nodes contain geometry (and possibly drawing attributes) How might we draw the tree for the robot arm?

A complex example: human figure Q: What’s the most sensible way to traverse this tree?

Human figure implementation, OpenGL figure() { torso(); glPushMatrix(); glTranslate(... ); glRotate(... ); head(); glPopMatrix(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_upper_arm(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_lower_arm(); glPopMatrix();... } figure() { torso(); glPushMatrix(); glTranslate(... ); glRotate(... ); head(); glPopMatrix(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_upper_arm(); glPushMatrix(); glTranslate(... ); glRotate(... ); left_lower_arm(); glPopMatrix();... }

So far… We’ve talked exclusively about geometry. – What is the shape of an object? glBegin() … glEnd() – How do I place it in a virtual 3D space? glMatrixMode() … – How to change viewpoints gluLookAt() – How do I know which pixels it covers? Rasterization – How do I know which of the pixels I should actually draw? Z-buffer, BSP

So far glColor(…); Apply_transforms(); Draw_objects(); glColor(…); Apply_transforms(); Draw_objects(); Lit surface Flat shaded

Next… Once we know geometry, we have to ask one more important question: – To what value do I set each pixel? Answering this question is the job of the shading model. Other names: – Lighting model – Light reflection model – Local illumination model – Reflectance model – BRDF

An abundance of photons Properly determining the right color is really hard. Particle Scattering

An abundance of photons Properly determining the right color is really hard. Translucency

An abundance of photons Properly determining the right color is really hard. Refraction

An abundance of photons Properly determining the right color is really hard. Global Effect

Our problem We’re going to build up to an approximation of reality called the Phong illumination model. It has the following characteristics: – not physically based – gives a “first-order” approximation to physical light reflection – very fast – widely used In addition, we will assume local illumination, i.e., light goes: light source -> surface -> viewer. No interreflections, no shadows.

Setup… Given: – a point P on a surface visible through pixel p – The normal N at P – The lighting direction, L, and intensity, L ,at P – The viewing direction, V, at P – The shading coefficients at P Compute the color, I, of pixel p. Assume that the direction vectors are normalized:

“Iteration zero” The simplest thing you can do is… Assign each polygon a single color: where – I is the resulting intensity – k e is the emissivity or intrinsic shade associated with the object This has some special-purpose uses, but not really good for drawing a scene.

“Iteration one” Let’s make the color at least dependent on the overall quantity of light available in the scene: – k a is the ambient reflection coefficient. really the reflectance of ambient light “ambient” light is assumed to be equal in all directions – L a is the ambient light intensity. Physically, what is “ambient” light?

Ambient Term Hack to simulate multiple bounces, scattering of light Assume light equally from all directions Slide from Ravi Ramamoorthi

Wavelength dependence Really, k e, k a, and L a are functions over all wavelengths. Ideally, we would do the calculation on these functions. For the ambient shading equation, we would start with: then we would find good RGB values to represent the spectrum I( ). Traditionally, though, k a and I a are represented as RGB triples, and the computation is performed on each color channel separately:

Diffuse reflection So far, objects are uniformly lit. – not the way things really appear – in reality, light sources are localized in position or direction Diffuse, or Lambertian reflection will allow reflected intensity to vary with the direction of the light.

Diffuse reflectors Diffuse reflection occurs from dull, matte surfaces, like latex paint, or chalk. These diffuse or Lambertian reflectors reradiate light equally in all directions.

Diffuse reflectors Diffuse reflection occurs from dull, matte surfaces, like latex paint, or chalk. These diffuse or Lambertian reflectors reradiate light equally in all directions. Picture a rough surface with lots of tiny microfacets.

Diffuse reflectors …or picture a surface with little pigment particles embedded beneath the surface (neglect reflection at the surface for the moment): The microfacets and pigments distribute light rays in all directions. Embedded pigments are responsible for the coloration of diffusely reflected light in plastics and paints. Note: the figures above are intuitive, but not strictly (physically) correct.

Diffuse reflectors, cont. The reflected intensity from a diffuse surface does not depend on the direction of the viewer. The incoming light, though, does depend on the direction of the light source:

“Iteration two” The incoming energy is proportional to cos , giving the diffuse reflection equations: where: – k d is the diffuse reflection coefficient – L d is the intensity of the light source – N is the normal to the surface (unit vector) – L is the direction to the light source (unit vector)