Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering...

30
Surface shading: materials Computer Graphics CSE 167 Lecture 5

Transcript of Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering...

Page 1: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Surface shading: materials

Computer GraphicsCSE 167Lecture 5

Page 2: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

CSE 167: Computer Graphics

• Global illumination• Local illumination• Surface shading

– Materials– Lights

CSE 167, Winter 2018 2

Page 3: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Rendering Pipeline

CSE 167, Winter 2018 3

Modeling and viewingtransformation

Shading

Projection

Scan conversion,visibility

Scene data

Image

• Position object in 3D

• Map triangles to 2D

• Draw triangles

– Per pixel shading

• Determine colors of vertices

– Per vertex shading

Page 4: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Appearance: lighting, surface reflectance, and shading

CSE 167, Winter 2018 4

Page 5: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Global illumination

• Photorealistic rendering using physics‐based simulation– Multiple bounces of light

• Direct (from light source) and indirect (from light reflected by other surfaces) illumination

• Computationally expensive (minutes per image)

• Used in movies, architectural design, etc.

CSE 167, Winter 2018 5Based on slides courtesy of Jurgen Schulze

Page 6: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Global illumination

CSE 167, Winter 2018 6

Page 7: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Local illumination

• Not a physics‐based simulation• Uses simplified models that reproduce perceptually most important effects– One bounce of light

• Direct (from light source) illumination

– Indirect illumination with an “ambient” term

• Computationally very fast• Used in interactive applications

CSE 167, Winter 2018 7

Page 8: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Local illumination

CSE 167, Winter 2018 8

Page 9: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Local illumination

• Model reflection of light at surfaces– Assumption: no subsurface scattering

• Bidirectional reflectance distribution function (BRDF)– Given light direction, viewing direction, how much light is reflected towards the viewer

– For any pair of light/viewing directions!

CSE 167, Winter 2018 9

Page 10: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Local illumination

• Simplified model– Sum of 3 components– Covers a large class of real surfaces

CSE 167, Winter 2018 10

ambientdiffuse specular

Page 11: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Local illumination

• Simplified model– Sum of 3 components– Covers a large class of real surfaces

CSE 167, Winter 2018 11

ambientdiffuse specular

Page 12: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Diffuse reflection

• Ideal diffuse material reflects light equally in all directions

• View‐independent• Matte, not shiny materials

– Paper– Unfinished wood– Unpolished stone

CSE 167, Winter 2018 12

Page 13: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Diffuse reflection• Beam of parallel rays shining on a surface

– Area covered by beam varies with the angle between the beam and the normal– The larger the area, the less incident light per area– Incident light per unit area is proportional to the cosine of the angle between the 

normal and the light rays

• Object darkens as normal turns away from light• Lambert’s cosine law (Johann Heinrich Lambert, 1760)• Diffuse surfaces are also called Lambertian surfaces

CSE 167, Winter 2018 13

nnn

Page 14: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Diffuse reflection

• Given– Unit surface normal n– Unit light direction L– Material color (albedo) kd– Light color cl

• Reflected color cd is given by

CSE 167, Winter 2018 14

Do not allow angles less than 0 (light is behind back of surface)

Page 15: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Diffuse reflection

• Notes– Material color (albedo) kd and light color cl are r,g,b vectors

– Need to compute r,g,b values of reflected color cdseparately

CSE 167, Winter 2018 15

Page 16: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Surface normals

• Important to bring out 3D appearance• Important for correct shading under lights

• The way shading is done also important– Flat: Each facet has single normal– Smooth: Each vertex has a single normal, interpolate normal vectors to determine normal at point on facet

CSE 167, Winter 2018 16

Flat

Smooth

Page 17: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Diffuse reflection

• Provides visual cues– Surface curvature– Depth variation

CSE 167, Winter 2018 17

Lambertian (diffuse) sphere under different lighting directions

Page 18: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Local illumination

• Simplified model– Sum of 3 components– Covers a large class of real surfaces

CSE 167, Winter 2018 18

ambientdiffuse specular

Page 19: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Specular reflection

• Shiny surfaces– Polished metal– Glossy car finish– Plastics

• Specular highlight– Blurred reflection of the light source

– Position of highlight depends on viewing direction

CSE 167, Winter 2018 19

Specular highlight

Page 20: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Specular reflection

• Ideal specular reflection is mirror reflection– Perfectly smooth surface– Incoming light ray is bounced in single direction– Angle of incidence equals angle of reflection

CSE 167, Winter 2018 20

Page 21: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Projection of vector on another vector

21CSE 167, Winter 2018

Page 22: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Law of reflection

• Angle of incidence equals angle of reflection

CSE 167, Winter 2018 22

Page 23: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Specular reflection

• Many materials are not perfect mirrors– Glossy materials

CSE 167, Winter 2018 23

Glossy teapot

Page 24: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Glossy materials• Assume surface composed of small mirrors with random 

orientation (micro‐facets)• Smooth surfaces

– Micro‐facet normals close to surface normal– Sharp highlights

• Rough surfaces– Micro‐facet normals vary strongly– Blurry highlight

Polished

Smooth

Rough

Very rough24CSE 167, Winter 2018

Page 25: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Glossy surfaces

• Expect most light to be reflected in mirror direction

• Because of micro‐facets, some light is reflected slightly off ideal reflection direction

• Reflection– Brightest when view vector is aligned with reflection

– Decreases as angle between view vector and reflection direction increases

CSE 167, Winter 2018 25

Page 26: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Phong shading model

• Developed by Bui Tuong Phong in 1973• Specular reflectance coefficient ks• Phong exponent p

– Greater pmeans smaller (sharper) highlight

CSE 167, Winter 2018 26

Page 27: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Phong shading model

27CSE 167, Winter 2018

Page 28: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Local Illumination

• Simplified model– Sum of 3 components– Covers a large class of real surfaces

CSE 167, Winter 2018 28

ambientdiffuse specular

Page 29: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Ambient light

• In real world, light is bounced all around scene• Could use global illumination techniques to simulate

• Simple approximation– Add constant ambient light at each point: kaca

• Ambient light color ca• Ambient reflection coefficient ka

• Areas with no direct illumination are not completely dark

CSE 167, Winter 2018 29

Page 30: Surface shading: materials - University of California, San Diego · 2018. 1. 24. · Rendering Pipeline CSE 167, Winter 2018 3 Modeling and viewing transformation Shading Projection

Complete Phong shading model

• Phong model supports multiple light sources• All light colors c and material coefficients k are 3‐component vectors for red, green, blue

CSE 167, Winter 2018 30

∙ ∙

Image by Brad Smith

Sum over all light sources