Shading. Brian Curless CSE 457 Spring 2017

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

Shading. Brian Curless CSE 557 Autumn 2017

Shading. Brian Curless CSE 457 Spring 2015

Shading. CSE 457 Winter 2015

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

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

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

w Foley, Section16.1 Reading

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

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

Projections and Hardware Rendering. Brian Curless CSE 557 Fall 2014

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

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

CPSC 314 LIGHTING AND SHADING

CS5620 Intro to Computer Graphics

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

Comp 410/510 Computer Graphics. Spring Shading

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

Computer Graphics. Illumination and Shading

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

Lecture 15: Shading-I. CITS3003 Graphics & Animation

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

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

Shading I Computer Graphics I, Fall 2008

Illumination & Shading

Illumination Models & Shading

Virtual Reality for Human Computer Interaction

Introduction to Computer Graphics 7. Shading

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

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

Illumination & Shading: Part 1

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

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

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

Computer Graphics. Illumination and Shading

Simple Lighting/Illumination Models

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

WHY WE NEED SHADING. Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something like.

Illumination and Shading

CS 5625 Lec 2: Shading Models

Illumination. Illumination CMSC 435/634

CPSC / Illumination and Shading

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

Lighting affects appearance

CS452/552; EE465/505. Intro to Lighting

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

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

CS 4600 Fall Utah School of Computing

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

CEng 477 Introduction to Computer Graphics Fall

Complex Shading Algorithms

Pipeline Operations. CS 4620 Lecture 10

Lighting affects appearance

Rendering Light Reflection Models

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

CSE 681 Illumination and Phong Shading

Shading 1: basics Christian Miller CS Fall 2011

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

Pipeline Operations. CS 4620 Lecture 14

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Visualisatie BMT. Rendering. Arjan Kok

Sung-Eui Yoon ( 윤성의 )

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

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

Illumination and Shading

CS Illumination and Shading. Slide 1

Shading & Material Appearance

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

Introduction to Visualization and Computer Graphics

Why we need shading?

Shading, lighting, & BRDF Theory. Cliff Lindsay, PHD

Illumination in Computer Graphics

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

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

Illumination and Shading

CS770/870 Spring 2017 Color and Shading

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

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

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

Ray Tracing. Brian Curless CSEP 557 Fall 2016

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

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

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

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

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

BRDF Computer Graphics (Spring 2008)

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

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

Lighting/Shading III. Week 7, Wed Mar 3

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

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Illumination and Shading - II

Virtual Reality for Human Computer Interaction

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

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

Computer Graphics I Lecture 11

Lecture 4: Reflection Models

Reflection and Shading

Raytracing CS148 AS3. Due :59pm PDT

Transcription:

Shading Brian Curless CSE 457 Spring 2017 1

Reading Optional: Angel and Shreiner: chapter 5. Marschner and Shirley: chapter 10, chapter 17. Further reading: OpenGL red book, chapter 5. 2

Basic 3D graphics With affine matrices, we can now transform virtual 3D objects in their local coordinate systems into a global (world) coordinate system: M 1 M 2 To synthesize an image of the scene, we also need to add light sources and a viewer/camera: 3

Pinhole camera To create an image of a virtual scene, we need to define a camera, and we need to model lighting and shading. For the camera, we use a pinhole camera. [Angel, 2011] The image is rendered onto an image plane (usually in front of the camera). Viewing rays emanate from the center of projection (COP) at the center of the pinhole. The image of an object point P is at the intersection of the viewing ray through P and the image plane. But is P visible? This the problem of hidden surface removal (a.k.a., visible surface determination). We ll consider this problem later. 4

Shading Next, we ll need a model to describe how light interacts with surfaces. Such a model is called a shading model. Other names: Lighting model Light reflection model Local illumination model Reflectance model BRDF 5

An abundance of photons Given the camera and shading model, properly determining the right color at each pixel is extremely hard. Look around the room. Each light source has different characteristics. Trillions of photons are pouring out every second. These photons can: interact with molecules and particles in the air ( participating media ) strike a surface and be absorbed be reflected (scattered) cause fluorescence or phosphorescence. interact in a wavelength-dependent manner generally bounce around and around 6

Our problem We re going to build up to a approximations of reality called the Phong and Blinn-Phong illumination models. They have the following characteristics: not physically correct 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. 7

Setup Given: a point P on a surface visible through pixel p The normal N at P The lighting direction, L, and (color) intensity, I 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: N L V 1 8

Iteration zero The simplest thing you can do is Assign each polygon a single color: where I=k e 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. 9

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

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

Diffuse reflectors Emissive and ambient reflection don t model realistic lighting and reflection. To improve this, we will look at diffuse (a.k.a., Lambertian) reflection. Diffuse reflection can occur from dull, matte surfaces, like latex paint, or chalk. These diffuse reflectors reradiate light equally in all directions. Picture a rough surface with lots of tiny microfacets. 12

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 in this and the previous slide are intuitive, but not strictly (physically) correct. 13

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: 14

Iteration two The incoming energy is proportional to the diffuse reflection equations:, giving I=k +k I +k I e a La d L B =k +k I +k I B( ) e a La d L where: k d is the diffuse reflection coefficient I L is the (color) intensity of the light source N is the normal to the surface (unit vector) L is the direction to the light source (unit vector) B prevents contribution of light from below the surface: 1 if NL 0 B= 0 if NL 0 15

Specular reflection Specular reflection accounts for the highlight that you see on some objects. It is particularly important for smooth, shiny surfaces, such as: metal polished stone plastics apples skin Properties: Specular reflection depends on the viewing direction V. For non-metals, the color is determined solely by the color of the light. For metals, the color may be altered (e.g., brass) 16

Specular reflection derivation For a perfect mirror reflector, light is reflected about N, so I L if V R I 0 otherwise For a near-perfect reflector, you might expect the highlight to fall off quickly with increasing angle. Also known as: rough specular reflection directional diffuse reflection glossy reflection 17

Phong specular reflection cos n s φ 1 0.9 0.8 0.7 0.6 ns = 1 0.5 0.4 0.3 0.2 0.1 ns = 128 0 100 80 60 40 20 0 20 40 60 80 100 φ One way to get this effect is to take (R V), raised to a power n s. Phong specular reflection is proportional to: where (x ) + max(0, x ). n specular ~ B RV s I ( ) Q: As n s gets larger, does the highlight on a curved surface get smaller or larger? 18

Blinn-Phong specular reflection A common alternative for specular reflection is the Blinn-Phong model (sometimes called the modified Phong model.) We compute the vector halfway between L and V as: Analogous to Phong specular reflection, we can compute the specular contribution in terms of (N H), raised to a power n s : n specular ~ B NH s I ( ) where, again, (x ) + max(0, x ). 19

Iteration three The next update to the Blinn-Phong shading model is then: I=k +k I +k I B( NL ) +k I B( NH) e a La d L s L ns k e+kai La+ ILBk d( NL ) +ks( NH) ns where: k s is the specular reflection coefficient n s is the specular exponent or shininess H is the unit halfway vector between L and V, where V is the viewing direction. 20

Directional lights The simplest form of lights supported by renderers are ambient, directional, and point. Spotlights are also supported often as a special form of point light. We ve seen ambient light sources, which are not really geometric. Directional light sources have a single direction and intensity associated with them. Using affine notation, what is the homogeneous coordinate for a directional light? 21

Point lights The direction of a point light sources is determined by the vector from the light position to the surface point. E-P L= E-P r =E-P Physics tells us the intensity must drop off inversely with the square of the distance: 1 f atten r 2 Sometimes, this distance-squared dropoff is considered too harsh. A common alternative is: 1 f atten 2 a+br +cr with user-supplied constants for a, b, and c. Using affine notation, what is the homogeneous coordinate for a point light? 22

Spotlights We can also apply a directional attenuation of a point light source, giving a spotlight effect. A common choice for the spotlight intensity is: where L is the direction to the point light. S is the center direction of the spotlight. is the angle between L and S is the cutoff angle for the spotlight e is the angular falloff coefficient LS f = 2 spot abrcr 0 otherwise 1 Note: cos ( LS ) LS cos. e 23

Iteration four Since light is additive, we can handle multiple lights by taking the sum over every light. Our equation is now: I=k +k I + e a La L S e j j j j 2 j a+b j jrj +cjrj NL NH I B k +k L,j j d j s j n s This is the Blinn-Phong illumination model (for spotlights). Which quantities are spatial vectors? Which are RGB triples? Which are scalars? 24

Shading in OpenGL The OpenGL lighting model allows you to associate different lighting colors according to material properties they will influence. Thus, our original shading equation (for point lights): I=k +k I + e a La 1 a+b r +cr NL NH I B k +k 2 L, j j d j s j + j j j j j j n s becomes: I=k +k I + e a La 1 a+b r +cr 2 j j j j j j ki + B ki ( NL ) +ki ( NH ) n a La, j j d Ld, j j s Ls, j j + s where you can have a global ambient light with intensity I La in addition to having an ambient light intensity I La, j associated with each individual light, as well as separate diffuse and specular intensities, I Ld, j and I Ls, j, repectively. 25

3D Geometry in the Graphics Hardware Pipeline Graphics hardware applies transformations to bring the objects and lighting into the camera s coordinate system: The geometry is assumed to be made of triangles, and the vertices are projected onto the image plane. 26

Rasterization After projecting the vertices, graphics hardware smears vertex properties across the interior of the triangle in a process called rasterization. Smearing the z-values and using a Z-buffer will enable the graphics hardware to determine if a point inside a triangle is visible. (More on this in another lecture.) If we have stored colors at the vertices, then we can smear these as well. 27

Shading the interiors of triangles We will be computing colors using the Blinn-Phong lighting model. Let s assume (as graphics hardware does) that we are working with triangles. How should we shade the interiors of triangles? 28

Shading with per-face normals Assume each face has a constant normal: For a distant viewer and a distant light source and constant material properties over the surface, how will the color of each triangle vary? 29

Faceted shading (cont d) [Williams and Siegel 1990] 30

Gouraud interpolation To get a smoother result that is easily performed in hardware, we can do Gouraud interpolation. Here s how it works: 1. Compute normals at the vertices. 2. Shade only the vertices. 3. Interpolate the resulting vertex colors. 31

Facted shading vs. Gouraud interpolation [Williams and Siegel 1990] 32

Gouraud interpolation artifacts Gouraud interpolation has significant limitations. 1. If the polygonal approximation is too coarse, we can miss specular highlights. 2. We will encounter Mach banding (derivative discontinuity enhanced by human eye). This is what graphics hardware does by default. A substantial improvement is to do 33

Phong interpolation To get an even smoother result with fewer artifacts, we can perform Phong interpolation. Here s how it works: 1. Compute normals at the vertices. 2. Interpolate normals and normalize. 3. Shade using the interpolated normals. 34

Gouraud vs. Phong interpolation [Williams and Siegel 1990] 35

Old pipeline: Gouraud interpolation Vertex processor Primitive assembler Default vertex processing: Ldetermine lighting direction Vdetermine viewing direction Nnormalize( n e ) cblinn-phong shade with LV,, Nk, d, ks, ns attach c blinn-phong to vertex as varying v i project v to image 1 2 3 i, i, vi v v triangle Rasterizer Fragment processor Default fragment processing: p color c blinn-phong 36

Programmable pipeline: Phong-interpolated normals! Vertex processor Vertex shader: attach n e to vertex as varying attach v e to vertex as varying v i project v to image Primitive assembler v, v, v 1 2 3 i i i triangle Rasterizer Fragment processor Fragment shader: p L determine lighting direction (using v e ) p Vnormalize v e p N normalize( n e ) color shade with LV,, N, k, k, n d s s 37

Choosing Blinn-Phong shading parameters Experiment with different parameter settings. To get you started, here are a few suggestions: Try n s in the range [0,100] Try k a + k d + k s < 1 Use a small k a (~0.1) n s k d k s Metal large Small, color of metal Large, color of metal Plastic medium Medium, color of plastic Medium, white Planet 0 varying 0 38

BRDF The diffuse+specular parts of the Blinn-Phong illumination model are a mapping from light to viewing directions: L V I= I LB k d( NL ) +ksn L V I f ( LV, ) The mapping function f r is often written in terms of incoming (light) directions in and outgoing (viewing) directions out : f (, ) or f ( ) r L in r out This function is called the Bi-directional Reflectance Distribution Function (BRDF). r in n s out Here s a plot with in held constant: f (, ) r in out in BRDF s can be quite sophisticated 39

More sophisticated BRDF s [Cook and Torrance, 1982] Anisotropic BRDFs [Westin, Arvo, Torrance 1992] Artistics BRDFs [Gooch] 40

More sophisticated BRDF s (cont d) Hair illuminated from different angles [Marschner et al., 2003] Wool cloth and silk cloth [Irawan and Marschner, 2012] 41

BSSRDFs for subsurface scattering [Jensen et al. 2001] 42

Summary You should understand the equation for the Blinn- Phong lighting model described in the Iteration Four slide: What is the physical meaning of each variable? How are the terms computed? What effect does each term contribute to the image? What does varying the parameters do? You should also understand the differences between faceted, Gouraud, and Phong interpolated shading. 43