Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 457 Spring Required: Angel chapter 5.

Similar documents
Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 457 Spring 2017

Shading. Brian Curless CSE 457 Spring 2015

Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 557 Fall Required: Shirley, Chapter 10

Shading. CSE 457 Winter 2015

Shading. Brian Curless CSE 457 Spring 2017

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

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

Shading. Brian Curless CSE 557 Autumn 2017

Projections and Hardware Rendering. Brian Curless CSE 557 Fall 2014

Introduction. Lighting model Light reflection model Local illumination model Reflectance model BRDF

w Foley, Section16.1 Reading

Lighting and Shading

INF3320 Computer Graphics and Discrete Geometry

CEng 477 Introduction to Computer Graphics Fall

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

Shading and Illumination

Ambient reflection. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 407

Illumination & Shading: Part 1

Illumination and Shading

Why we need shading?

Illumination and Shading ECE 567

Computer Graphics. Illumination and Shading

Light Sources. Spotlight model

CS5620 Intro to Computer Graphics

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

Sung-Eui Yoon ( 윤성의 )

Shading , Fall 2004 Nancy Pollard Mark Tomczak

Illumination and Shading

CS Surface Rendering

Illumination Models & Shading

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010)

Virtual Reality for Human Computer Interaction

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

CPSC 314 LIGHTING AND SHADING

Lighting/Shading III. Week 7, Wed Mar 3

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

Lighting. CSC 7443: Scientific Information Visualization

Illumination. Illumination CMSC 435/634

University of British Columbia CPSC 314 Computer Graphics Sep-Dec Tamara Munzner (guest lecturing) Lighting/Shading

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

CSE 167: Lecture #8: Lighting. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Illumination & Shading

Complex Shading Algorithms

Light Transport Baoquan Chen 2017

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

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

Universität Augsburg. Institut für Informatik. Approximating Optimal Visual Sensor Placement. E. Hörster, R. Lienhart.

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

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

Illumination Model. The governing principles for computing the. Apply the lighting model at a set of points across the entire surface.

Illumination and Shading

Lecture 4 Advanced Computer Graphics (CS & SE )

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

Illumination & Shading

Ligh%ng and Shading. Ligh%ng and Shading. q Is this a plate or a ball? q What color should I set for each pixel?

Comp 410/510 Computer Graphics. Spring Shading

Illumination and Shading

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

CS 5625 Lec 2: Shading Models

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

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

Homework #2. Shading, Ray Tracing, and Texture Mapping

Representations and Transformations. Objectives

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Pipeline Operations. CS 4620 Lecture 10

Virtual Reality for Human Computer Interaction

LIGHTING AND SHADING

Computer Graphics. Illumination and Shading

OpenGL Lighting Computer Graphics Spring Frank Palermo

CPSC / Illumination and Shading

CS 4731: Computer Graphics Lecture 16: Phong Illumination and Shading. Emmanuel Agu

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

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

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

Gray-level histogram. Intensity (grey-level) transformation, or mapping. Use of intensity transformations:

Shading in OpenGL. Outline. Defining and Maintaining Normals. Normalization. Enabling Lighting and Lights. Outline

Simple Lighting/Illumination Models

Graphics and Visualization

Mid-term review ECE 161C Electrical and Computer Engineering University of California San Diego

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

5.2 Shading in OpenGL

CS452/552; EE465/505. Intro to Lighting

Shading 1: basics Christian Miller CS Fall 2011

surface: reflectance transparency, opacity, translucency orientation illumination: location intensity wavelength point-source, diffuse source

CS 148, Summer 2012 Introduction to Computer Graphics and Imaging

CS 4600 Fall Utah School of Computing

Introduction to Computer Graphics 7. Shading

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

Computer Vision Systems. Viewing Systems Projections Illuminations Rendering Culling and Clipping Implementations

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Pipeline Operations. CS 4620 Lecture 14

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Introduction to Visualization and Computer Graphics

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

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

Transcription:

Reading Required: Angel chapter 5. Shading Optional: OpenGL red book, chapter 5. Brian Curle CSE 457 Spring 2015 1 2 Baic 3D graphic With affine matrice, we can now tranform virtual 3D object in their local coordinate ytem into a global (world) coordinate ytem: Pinhole camera To create an image of a virtual cene, we need to define a camera, and we need to model lighting and hading. For the camera, we ue a pinhole camera. M 1 M 2 [Angel, 2011] The image i rendered onto an image plane (uually in front of the camera). To yntheize an image of the cene, we alo need to add light ource and a viewer/camera: Viewing ray emanate from the center of projection (COP) at the center of the pinhole. 3 The image of an object point P i at the interection of the viewing ray through P and the image plane. But i P viible? Thi the problem of hidden urface removal (a.k.a., viible urface determination). We ll conider thi problem later. 4

Shading An abundance of photon Next, we ll need a model to decribe how light interact with urface. Such a model i called a hading model. Other name: Lighting model Light reflection model Local illumination model Reflectance model BRDF Given the camera and hading model, properly determining the right color at each pixel i extremely hard. Look around the room. Each light ource ha different characteritic. Trillion of photon are pouring out every econd. Thee photon can: interact with molecule and particle in the air ( participating media ) trike a urface and be aborbed be reflected (cattered) caue fluorecence or phophorecence. interact in a wavelength-dependent manner generally bounce around and around 5 6 Our problem Setup We re going to build up to a approximation of reality called the Phong and Blinn-Phong illumination model. They have the following characteritic: not phyically correct give a firt-order approximation to phyical light reflection very fat widely ued In addition, we will aume local illumination, i.e., light goe: light ource -> urface -> viewer. No interreflection, no hadow. Given: a point P on a urface viible through pixel p The normal N at P The lighting direction, L, and (color) intenity, I L, at P The viewing direction, V, at P The hading coefficient at P Compute the color, I, of pixel p. Aume that the direction vector are normalized: N L V 1 7 8

Iteration zero Iteration one The implet thing you can do i Aign each polygon a ingle color: I=k e where I i the reulting intenity k e i the emiivity or intrinic hade aociated with the object Thi ha ome pecial-purpoe ue, but not really good for drawing a cene. Let make the color at leat dependent on the overall quantity of light available in the cene: I k k I k a i the ambient reflection coefficient. really the reflectance of ambient light ambient light i aumed to be equal in all direction I La i the ambient light intenity. Phyically, what i ambient light? e a La [Note: k e i omitted in Angel.] 9 [Note: Angel ue L a intead of I La.] 10 Wavelength dependence Diffue reflection Really, k e, k a, and I La are function over all wavelength. Ideally, we would do the calculation on thee function. For the ambient hading equation, we would tart with: I ( ) =k ( ) I ( ) a La Let examine the ambient hading model: object have different color we can control the overall light intenity what happen when we turn off the light? what happen a the light intenity increae? what happen if we change the color of the light? then we would find good RGB value to repreent the pectrum I (). Traditionally, though, k a and I La are repreented a RGB triple, and the computation i performed on each color channel eparately: I =k I I I =k I R R R a La G G G =k a ILa B B B a La So far, object are uniformly lit. not the way thing really appear in reality, light ource are localized in poition or direction Diffue, or Lambertian reflection will allow reflected intenity to vary with the direction of the light. 11 12

Diffue reflector Diffue reflector Diffue reflection occur from dull, matte urface, like latex paint, or chalk. Thee diffue or Lambertian reflector reradiate light equally in all direction. or picture a urface with little pigment particle embedded beneath the urface (neglect reflection at the urface for the moment): Picture a rough urface with lot of tiny microfacet. The microfacet and pigment ditribute light ray in all direction. Embedded pigment are reponible for the coloration of diffuely reflected light in platic and paint. Note: the figure above are intuitive, but not trictly (phyically) correct. 13 14 Diffue reflector, cont. Iteration two The reflected intenity from a diffue urface doe not depend on the direction of the viewer. The incoming light, though, doe depend on the direction of the light ource: The incoming energy i proportional to the diffue reflection equation: I=k +k I e a La d L +k I B, giving =k +k I +k I B( ) e a La d L where: k d i the diffue reflection coefficient I L i the (color) intenity of the light ource N i the normal to the urface (unit vector) L i the direction to the light ource (unit vector) B prevent contribution of light from below the urface: 1 if NL 0 B= 0 if NL 0 [Note: Angel ue L d intead of I L and f intead of B.] 15 16

Specular reflection Specular reflection derivation Specular reflection account for the highlight that you ee on ome object. It i particularly important for mooth, hiny urface, uch a: metal polihed tone platic apple kin For a perfect mirror reflector, light i reflected about N, o I L if V R I 0 otherwie Propertie: Specular reflection depend on the viewing direction V. For non-metal, the color i determined olely by the color of the light. For metal, the color may be altered (e.g., bra) For a near-perfect reflector, you might expect the highlight to fall off quickly with increaing angle. Alo known a: rough pecular reflection directional diffue reflection gloy reflection 17 18 Phong pecular reflection Blinn-Phong pecular reflection co n φ 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 n = 1 A common alternative for pecular reflection i the Blinn-Phong model (ometime called the modified Phong model.) We compute the vector halfway between L and V a: 0.2 0.1 n = 128 0 100 80 60 40 20 0 20 40 60 80 100 φ One way to get thi effect i to take (R V), raied to a power n. A n get larger, the dropoff become {more,le} gradual give a {larger,maller} highlight imulate a {more,le} mirror-like urface Phong pecular reflection i proportional to: where (x ) + max(0, x ). n pecular ~ B R V I ( ) Analogou to Phong pecular reflection, we can compute the pecular contribution in term of (N H), raied to a power n : n pecular ~ B NH I ( ) where, again, (x ) + max(0, x ). 19 20

Iteration three Directional light The next update to the Blinn-Phong hading model i then: n I=k +k I +k I B( NL ) +k I B( NH) where: e a La d L L k e+kai La+ ILB k d( NL ) +k( NH) n The implet form of light upported by renderer are ambient, directional, and point. Spotlight are alo upported often a a pecial form of point light. We ve een ambient light ource, which are not really geometric. Directional light ource have a ingle direction and intenity aociated with them. k i the pecular reflection coefficient n i the pecular exponent or hinine H i the unit halfway vector between L and V, where V i the viewing direction. [Note: Angel ue a intead of n, and maintain a eparate L d and L, intead of a ingle I L. Thi choice reflect the flexibility available in OpenGL.] Uing affine notation, what i the homogeneou coordinate for a directional light? 21 22 Point light Spotlight The direction of a point light ource i determined by the vector from the light poition to the urface point. We can alo apply a directional attenuation of a point light ource, giving a potlight effect. E-P L= E-P r =E-P Phyic tell u the intenity mut drop off inverely with the quare of the ditance: 1 f atten r 2 Sometime, thi ditance-quared dropoff i conidered too harh. A common alternative i: 1 f atten 2 a+br +cr with uer-upplied contant for a, b, and c. Uing affine notation, what i the homogeneou coordinate for a point light? 23 A common choice for the potlight intenity i: LS f = 2 pot abrcr 0 otherwie where L i the direction to the point light. S i the center direction of the potlight. i the angle between L and S i the cutoff angle for the potlight e i the angular falloff coefficient 1 Note: co ( LS ) LS co. e 24

Iteration four Since light i additive, we can handle multiple light by taking the um over every light. Our equation i now: I=k +k I + Thi i the Blinn-Phong illumination model (for potlight). Which quantitie are patial vector? Which are RGB triple? Which are calar? e j Lj Sj j n I B NH L,j j k d NLj +k 2 j j a+b j jrj +cjrj e a La 25 Shading in OpenGL The OpenGL lighting model allow you to aociate different lighting color according to material propertie they will influence. Thu, our original hading equation (for point light): I=k +k I + e a La 1 n I B NH L,j j k d NLj +k 2 j r r + j a+b j j j +cj j become: I=k +k I + e a La 1 a+b r +cr 2 j j j j j j where you can have a global ambient light with intenity I La in addition to having an ambient light intenity I La, j aociated with each individual light, a well a eparate diffue and pecular intenitie, I Ld, j and I L, j, repectively. ki + B ki ( NL ) +ki ( NH ) n a La,j j d Ld, j j L,j j + 26 Material in OpenGL The OpenGL code to pecify the urface hading propertie i fairly traightforward. For example: GLfloat ke[] = { 0.1, 0.15, 0.05, 1.0 }; GLfloat ka[] = { 0.1, 0.15, 0.1, 1.0 }; GLfloat kd[] = { 0.3, 0.3, 0.2, 1.0 }; GLfloat k[] = { 0.2, 0.2, 0.2, 1.0 }; GLfloat n[] = { 50.0 }; glmaterialfv(gl_front, GL_EMISSION, ke); glmaterialfv(gl_front, GL_AMBIENT, ka); glmaterialfv(gl_front, GL_DIFFUSE, kd); glmaterialfv(gl_front, GL_SPECULAR, k); glmaterialfv(gl_front, GL_SHININESS, n); Note: The GL_FRONT parameter tell OpenGL that we are pecifiying the material for the front of the urface. Only the alpha value of the diffue color i ued for blending. It uually et to 1. 27 Shading in OpenGL, cont d In OpenGL thi equation, for one light ource (the 0 th ) i pecified omething like: GLfloat La[] = { 0.2, 0.2, 0.2, 1.0 }; GLfloat La0[] = { 0.1, 0.1, 0.1, 1.0 }; GLfloat Ld0[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat L0[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat po0[] = { 1.0, 1.0, 1.0, 0.0 }; GLfloat a0[] = { 1.0 }; GLfloat b0[] = { 0.5 }; GLfloat c0[] = { 0.25 }; GLfloat S0[] = { -1.0, -1.0, 0.0 }; GLfloat beta0[] = { 45 }; GLfloat e0[] = { 2 }; gllightmodelfv(gl_light_model_ambient, La); gllightfv(gl_light0, GL_AMBIENT, La0); gllightfv(gl_light0, GL_DIFFUSE, Ld0); gllightfv(gl_light0, GL_SPECULAR, L0); gllightfv(gl_light0, GL_POSITION, po0); gllightfv(gl_light0, GL_CONSTANT_ATTENUATION, a0); gllightfv(gl_light0, GL_LINEAR_ATTENUATION, b0); gllightfv(gl_light0, GL_QUADRATIC_ATTENUATION, c0); gllightfv(gl_light0, GL_SPOT_DIRECTION, S0); gllightf(gl_light0, GL_SPOT_CUTOFF, beta0); gllightf(gl_light0, GL_SPOT_EXPONENT, e0); 28

Shading in OpenGL, cont d Note: You can have a many a GL_MAX_LIGHTS light in a cene. Thi number i ytem-dependent. 3D Geometry in the Graphic Hardware Pipeline Graphic hardware applie tranformation to bring the object and lighting into the camera coordinate ytem: For directional light, you pecify a light direction, not poition, and the attenuation and potlight term are ignored. The direction of directional light and potlight are pecified in the coordinate ytem of the light, not the urface point a we ve been doing in lecture. 29 The geometry i aumed to be made of triangle, and the vertice are projected onto the image plane. 30 Raterization After projecting the vertice, graphic hardware mear vertex propertie acro the interior of the triangle in a proce called raterization. Shading the interior of triangle We will be computing color uing the Blinn-Phong lighting model. Let aume (a graphic hardware doe) that we are working with triangle. How hould we hade the interior of triangle? Smearing the z-value and uing a Z-buffer will enable the graphic hardware to determine if a point inide a triangle i viible. (More on thi in another lecture.) If we have tored color at the vertice, then we can mear thee a well. 31 32

Shading with per-face normal Faceted hading (cont d) Aume each face ha a contant normal: For a ditant viewer and a ditant light ource and contant material propertie over the urface, how will the color of each triangle vary? 33 [William and Siegel 1990] 34 Facted hading v. Gouraud interpolation Gouraud interpolation To get a moother reult that i eaily performed in hardware, we can do Gouraud interpolation. Here how it work: 1. Compute normal at the vertice. 2. Shade only the vertice. 3. Interpolate the reulting vertex color. 35 [William and Siegel 1990] 36

Gouraud interpolation artifact Phong interpolation Gouraud interpolation ha ignificant limitation. To get an even moother reult with fewer artifact, we can perform Phong interpolation. 1. If the polygonal approximation i too coare, we can mi pecular highlight. Here how it work: 1. Compute normal at the vertice. 2. Interpolate normal and normalize. 3. Shade uing the interpolated normal. 2. We will encounter Mach banding (derivative dicontinuity enhanced by human eye). Thi i what graphic hardware doe by default. A ubtantial improvement i to do 37 38 Old pipeline: Gouraud interpolation Gouraud v. Phong interpolation Vertex proceor Default vertex proceing: L determine lighting direction V determine viewing direction N normalize(ne ) cblinn-phong hade with L, V, N, kd, k, n attach cblinn-phong to vertex a varying vi project v to image Primitive aembler v1i, v i2, v i3 triangle Raterizer Fragment proceor [William and Siegel 1990] 39 Default fragment proceing: p color cblinn-phong 40

Programmable pipeline: Phong-interpolated normal! Vertex proceor Primitive aembler Vertex hader: attach n e to vertex a varying attach v e to vertex a varying v i project v to image v, v, v 1 2 3 i i i triangle Chooing Blinn-Phong hading parameter Experiment with different parameter etting. To get you tarted, here are a few uggetion: Try n in the range [0,100] Try k a + k d + k < 1 Ue a mall k a (~0.1) n k d k Metal large Small, color of metal Large, color of metal Raterizer Platic medium Medium, color of platic Medium, white Planet 0 varying 0 Fragment proceor Fragment hader: p L determine lighting direction (uing v e ) V v p e p N normalize( n e ) color hade with LV,, Nk,, k, n d 41 42 BRDF More ophiticated BRDF The diffue+pecular part of the Blinn-Phong illumination model are a mapping from light to viewing direction: L V I= I LB k d( NL) +kn L V I f ( LV, ) L r The mapping function f r i often written in term of incoming (light) direction in and outgoing (viewing) direction out : n [Cook and Torrance, 1982] f (, ) or f ( ) r in out r in out Thi function i called the Bi-directional Reflectance Ditribution Function (BRDF). Aniotropic BRDF [Wetin, Arvo, Torrance 1992] Here a plot with in held contant: f (, ) r in out in BRDF can be quite ophiticated 43 Artitic BRDF [Gooch] 44

More ophiticated BRDF (cont d) BSSRDF for uburface cattering Hair illuminated from different angle [Marchner et al., 2003] [Jenen et al. 2001] Wool cloth and ilk cloth [Irawan and Marchner, 2012] 45 46 Summary You hould undertand the equation for the Blinn- Phong lighting model decribed in the Iteration Four lide: What i the phyical meaning of each variable? How are the term computed? What effect doe each term contribute to the image? What doe varying the parameter do? You hould alo undertand the difference between faceted, Gouraud, and Phong interpolated hading. 47