Chapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

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

Today we will start to look at illumination models in computer graphics

Computer Graphics

Comp 410/510 Computer Graphics. Spring Shading

Illumination & Shading

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

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Introduction to Computer Graphics 7. Shading

Illumination Models & Shading

CEng 477 Introduction to Computer Graphics Fall

CS5620 Intro to Computer Graphics

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

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

Illumination Models and Surface-Rendering Methods. Chapter 10

Shading I Computer Graphics I, Fall 2008

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

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

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

Reflection and Shading

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information

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

CPSC 314 LIGHTING AND SHADING

Graphics for VEs. Ruth Aylett

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

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

CS Illumination and Shading. Slide 1

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

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

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

Illumination in Computer Graphics

University of Victoria CSC 305 Shading. Brian Wyvill 2016

Illumination & Shading: Part 1

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

CS 325 Computer Graphics

Virtual Reality for Human Computer Interaction

CS 4600 Fall Utah School of Computing

Graphics for VEs. Ruth Aylett

Illumination & Shading I

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

Computer Graphics. Illumination and Shading

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Introduction to Computer Graphics. Farhana Bandukwala, PhD Lecture 14: Light Interacting with Surfaces

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

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

Computer Graphics. Illumination and Shading

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

Lighting Models. CS116B Chris Pollett Mar 21, 2004.

Illumination Modelling

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

Why we need shading?

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Simple Lighting/Illumination Models

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

w Foley, Section16.1 Reading

Illumination and Shading

Illumination and Shading

Shading. Brian Curless CSE 557 Autumn 2017

Surface Rendering. Surface Rendering

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

9. Illumination and Shading

Lighting. Figure 10.1

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

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

Objectives. Shading II. Distance Terms. The Phong Reflection Model

Shading II. CITS3003 Graphics & Animation

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

CS770/870 Spring 2017 Color and Shading

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

CSCI 4620/8626. Computer Graphics Illumination Models and Surface Rendering Methods (Chapter 17)

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

CPSC / Texture Mapping

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

Visualisatie BMT. Rendering. Arjan Kok

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

Raytracing. COSC 4328/5327 Scott A. King

Illumination Models. To calculate the color of an illuminated position on the

Lighting and Shading

CSE 681 Illumination and Phong Shading

Illumination and Shading

CS452/552; EE465/505. Intro to Lighting

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

Virtual Reality for Human Computer Interaction

Illumination and Shading

CPSC / Illumination and Shading

Graphics and Visualization

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

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

Shading. Brian Curless CSE 457 Spring 2017

Illumination Models and Shading

Computer Graphics MTAT Raimond Tunnel

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

Topics and things to know about them:

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

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Transcription:

Computer Graphics Chapter 10 llumination Models and Surface-Rendering Methods Somsak Walairacht, Computer Engineering, KMTL 1

Outline Light Sources Surface Lighting Effects Basic llumination Models Polygon Rendering Methods Texture Mapping Ray-Tracing Radiosity 2

llumination Model Lighting model or Shading model Calculate the color of an illuminated positions on the surface of an object Ray-tracing Topics Light sources Basic models Lighting-surface effects 3

Surface-Rendering Method Shading Method Determine the pixel color using color calculations from an illumination model Scan-line, mage-space algorithms Topics Polygon rendering methods Ray-tracing Radiosity Texture Mapping 4

Why Lighting? f we don t have lighting effects nothing looks three dimensional 5

Photorealism in Computer Graphics Accurate representation of surface properties Good physical descriptions of light effects in the scene Reflections Refraction Transparency Surface texture Shadows 6

7

Light Sources 1) Point light Simplest, position and color 2) nfinite distant light Large source, the sun Constant distance to any positions Directional vector and color Radial intensity attenuation 3) Directional light Spotlight, cone beam Directional vector, angular limit, position, and color 4) Extended light Large source closed to object Light emitting surface 8

Point Light Sources A point source is the simplest model we can use for a light source Simply define The position of the light The RGB values for the colour of the light Light is emitted in all directions Useful for small light sources 9

Radial ntensity Attenuation As light moves from a light source its intensity diminished At any distance d l away from the light source the intensity diminishes by a 1 factor of 2 d l However, using this factor does not produce very good results so we use something different 10

Radial ntensity Attenuation An inverse quadratic function is used instead 1 fradatten( dl ) 2 a a d a d 0 where the coefficients a 0, a 1, and a 2 can be varied to produce optimal results 1 l 2 l 11

Linear attenuation Exponential attenuation where kc = constant attenuation factor kl = linear attenuation factor kq = quadratic attenuation factor d = distance between the surface being lit and the center of the light. 12

nfinite Distant Light Sources A large light source, like the sun, can be modelled as a point light source However, it will have very little directional effect Radial intensity attenuation is not used 13

Directional Light Sources To turn a point light source into a spotlight, simply add a vector direction and an angular limit it θ l 14

Directional Light Sources & Spotlight Effects Denote V light as the unit vector in the direction of the light V obj as the unit vector from the light source to an object The dot-product of these two vectors gives us the angle between them V obj Vlight cos f this angle is inside the light s angular limit then the object is within the spotlight 15

Angular ntensity Attenuation As well as light intensity decreasing as we move away from a light source, it also decreases angularly A commonly used function for calculating angular attenuation is: fangatten al ( ) cos 0 where the attenuation exponent a l is assigned some positive value and angle is measured from the cone axis 16

Extended Light Sources Approximate it as a light-emitting surface We can set the direction for the point sources Behind the light- emitting surface are not illuminated 17

Reflected Light The colors that we perceived are determined by the nature of the light reflected from an object For example, if white light Colors is shone onto a green object most wavelengths are absorbed, while green light is reflected from the object Absorbed 18

Surface Lighting Effects The amount of incident light reflected by a surface depends on the type of material Shiny materials reflect more of the incident light Dull surfaces absorb more of the incident light For transparent surfaces, some of the light is also transmitted through the material 19

Diffuse Reflection Surfaces that are rough or grainy tend to reflect light in all directions กระจาย This scattered light is called Diffuse Reflection 20

Specular Reflection Additionally to diffuse reflection some of the reflected light is concentrated into a highlight or bright spot เก ยวก บกระจกเงา This is called Specular Reflection 21

Basic llumination Model We will consider a basic illumination model which gives reasonably good results and is used in most graphics systems The important components are: Ambient light Diffuse reflection Specular reflection 22

Basic llumination Model Ambient Diffuse Specular Final mage 23

Ambient Light To incorporate background light we simply set a general brightness level for a scene ndependent of viewing direction and the spatial orientation of a surface Assuming only monochromatic light effects, we designate ambient light with the value a 24

Diffuse Reflection Assume that surfaces reflect incident light with equal intensity in all directions Such surfaces are referred to as deal Diffuse Reflectors or Lambertian Reflectors 25

Diffuse Reflection A parameter k d is set for each surface that determines the fraction of incident light that is to be scattered as diffuse reflections from that surface This parameter is known as the Diffuse- Reflection Coefficient i or the Diffuse Reflectivity k d is assigned a value between 0.00 and 1.0 0.0: dull surface that absorbs almost all light 1.0: shiny surface that reflects almost all light 26

Diffuse Reflection Ambient Light For background lighting effects we can assume that every surface is fully illuminated by the ambient light a Therefore the ambient contribution to the diffuse reflection is given as: k ambdiff d a Ambient light alone is very uninteresting so we need some other lights in a scene as well 27

Diffuse Reflection Brightness depends on the orientation of a surface The amount of incident light on a surface is given as: cos l, incident l So we can model the diffuse reflections as: k l, diff d l, incident k d l cos 28

Diffuse Reflection Assuming we denote the normal for a surface as N and the unit direction vector to the light source as L then: So, N L cos l, diff k d l ( N L) if N L 0 if N L 0 0 29

Combining Ambient And ncident Diffuse Reflections Most graphics packages use two separate diffuse-reflection coefficients: k a for ambient light k d for incident light The total diffuse reflection equation for a single point source can then be given as: diff k a a k k d a l a ( N L) if N L 0 if N L 0 30

Combining Ambient And ncident Diffuse Reflections 31

Ambient Light k a a 32

Ambient and Diffuse Reflection k a a k d l ( N L) 33

Specular Reflection The bright spot on a shiny surface is the result of near total of the incident light in a concentrated t region around the specular reflection angle The specular reflection angle equals the angle of the incident light 34

Specular Reflection A perfect mirror reflects light only in the specular-reflection direction Other objects exhibit specular reflections over a finite range of viewing positions around vector R 35

Effect of n shiny The effect of n s on the angular range in which we can expect to see specular reflections 36

The Phong Specular Reflection Model An empirical model for calculating specular reflection range Developed in 1973 by Phong Bui Tuong The intensity of specular reflection is set proportional to the angle between the viewing vector and the specular reflection vector 37

Phong Model The specular reflection intensity is proportional to cos n s The angle can be varied between 0 and 90 so that cos varies from 1.0 to 0.0 The Specular-Reflection Exponent, n s is determined by the type of surface we want to display Shiny surfaces have a very large value (>100) Rough surfaces would have a value near 1 38

Phong Model The specular reflection intensity is given as: n k cos s l, spec s l Since, V R cos l, spec k s l n ( V R ) s if V R 0 and N L 0.0 if V R 0 or N L 0 0 39

Phong Model Calculate of vector R R+L = (2LN)N R = (2LN)N L More efficient, use Halfway vector H 40

The Halfway Vector Blinn proposed an alternative to Phong's model that uses the halfway vector The halfway vector is the direction of maximum m highlights f the surface is oriented so that the normal is aligned along, the viewer sees the brightest specular highlights l, spec H k ( N H ) s L V L V l n s 41

Blinn Phong Reflection Model Using halfway angle Set specular reflection exponent, n s close to the formal expression 42

Diffuse and Specular Constants The diffuse constant determines the intensity of the diffuse component Notice that the diffuse component gets brighter across the rows The specular constant determines the intensity of the specular component Notice that the specular component gets brighter up the columns k s k d 43

Combining Diffuse & Specular Reflections Effects of diffuse and specular reflections can be combined as n s l s l d a a spec diff amb H N k L N k k ) ( ) ( For any number of light sources in a scene n n n d l l spec l diff l amb s H N k L N k k 1,, 44 l s d l a a H N k L N k k 1

RGB Color Considerations For an RGB color description each intensity specification is a three element vector So, for each light source:,, l lr lg Similarly all parameters are given as vectors: a lb k, k k k k, k, k k, ar ag ab k k, k, k s sr d sg sb dr dg db 45

Total llumination k a l a k d l ( L N) 46

Total llumination k a a l k d ( L N) k ( H s N) n s n s 5 47

Total llumination k a a l k d ( L N) k ( H s N) n s n s 50 48

Total llumination k a a l k d ( L N) k ( H s N) n s n s 500 49

Single Light Source k a a l k d ( L N) k ( H s N) n s 50

Multiple Light Sources k a a i i k d ( L i N) k s ( H i N) n s 51

Attenuation Decrease intensity with distance from light d = distance to light r = radius of attenuation for light att ( d, r ) max(0,1 d att( d, r) att( d, r) att ( d, r ) e max(0,1 d 2 r 2 d max(0,(1 r 2 d ) r 2 2 r ) 2 ) 2 ) 52

Attenuation k a a i i n s k L N ) k ( H N ) att( d, r ) d ( i s i i 53

Attenuation k a a i i k L N) k ( H N) ns att( d, r ) ( d i s i i 54

Spot Lights Eliminate light contribution outside of a cone spotcoeff L A cos( ), 0 L A cos( ), L A A L Surface 55

Spot Lights k a a i i k ( L N) k ( H N) ns spotcoeff d i s i i 56

Spot Lights k a a i i k ( L N) k ( H N) ns spotcoeff d i s i i 57

Spot Lights k a a i i k ( L N) k ( H N) ns spotcoeff d i s i i 58

No Surface Rendering VS Flat Surface Rendering No Surface Rendering Flat Surface Rendering 59

Flat Surface Rendering VS Gouraud Surface Rendering Flat Surface Rendering Gouraud Surface Rendering 60

Gouraud Surface Rendering VS Phong Surface Rendering Gouraud Surface Rendering Phong Surface Rendering 61

Flat Surface Rendering The simplest method for rendering a polygon surface The same colour is assigned to all surface positions The illumination at a single point on the surface is calculated and used for the entire surface Flat surface rendering is extremely fast, but can be unrealistic 62

Gouraud Surface Rendering Gouraud surface shading was developed in the 1970s by Henri Gouraud Worked at the University of Utah along with van Sutherland and David Evans Often also called intensityinterpolation surface rendering ntensity levels are calculated at each vertex and interpolated across the surface 63

Gouraud Surface Rendering (cont ) To render a polygon, Gouraud surface rendering gproceeds as follows: 1. Determine the average unit normal vector at each vertex of the polygon 2. Apply an illumination model at each polygon vertex to obtain the light intensity at that position 3. Linearly interpolate the vertex intensities over the projected area of the polygon 64

Gouraud Surface Rendering (cont ) N 1 The average unit normal vector at v is given as: N 4 N v v N 2 N v N N N N N 1 2 3 4 1 N2 N3 N4 or more generally: N 3 n i1 N v n i1 N N i i 65

Gouraud Surface Rendering (cont ) llumination values are linearly interpolated across each scan-line 2 2 1 4 1 1 2 1 2 4 4 y y y y y y y y 3 y interpolated across each scan line 1 4 5 Scan-line p 2 2 3 5 3 3 2 3 2 5 5 y y y y y y y y 4 5 p 2 3 2 3 5 4 5 4 4 4 5 5 x x x x x x x x p p p 66 2 x 4 5 4 5 x x x x

Advantages of Gouraud Surface Rendering 67

Gouraud Surface Rendering mplementation Gouraud surfacing rendering can be implemented relatively efficiently using an iterative approach Typically Grouaud shading is implemented as part of a visible surface detection technique 68

Problems with Gouraud Shading Gouraud shading tends to miss certain highlighting n particular Gouraud shading has a problem with specular reflections Also, Gouraud shading can introduce anomalies known as Machbands 69

Problems with Gouraud Shading (cont ) Gouraud shading Phong shading The major problem with Gouraud shading is in handling specular reflections 70

The Machband Effect A psychological phenomenon whereby we see bright bands where two blocks of solid color meet High light can get lost or grow Corners on silhouette remain Machband effect is visible at some edges A good demo is available to experiment with this at: http://www.nbb.cornell.edu/neurobio/land/oldstudentprojects/c s490-96to97/anson/machbandingapplet/ 71

Phong Shading ncremental normal vector update along and between scan lines Comparison to Gouraud shading Better highlights Less Machbanding More costly 72

Phong Surface Rendering A more accurate interpolation based approach for rendering a polygon was developed by Phong Bui Tuong Basically the Phong surface rendering model (or normal-vector interpolation rendering) interpolates normal vectors instead of intensity values 73

Phong Surface Rendering (cont ) To render a polygon, Phong surface rendering proceeds as follows: 1. Determine the average unit normal vector at each vertex of the polygon 2. Linearly interpolate t the vertex normals over the projected area of the polygon 3. Apply an illumination model at positions along scan lines to calculate pixel intensities using the interpolated normal vectors 74

Phong Surface Rendering (cont ) N N 3 4 1 2 4 N y y N y y N N 1 2 2 1 1 2 1 4 N y y N y y N 5 3 2 5 y y y y N 4 Scan line 2 2 3 5 3 3 2 3 2 5 5 N y y y y N y y y y N N p N N 5 p 5 5 4 4 4 5 4 5 N y y y y N y y y y N p p p 75 N 2

Phong Surface Rendering mplementation Phong shading is much slower than Gouraud shading as the lighting model is revaluated so many times Typically, Phong shading is implemented as part of a visible iibl surface detection technique 76

Texture Mapping Three steps to applying a texture 1. Specify the texture Read or generate image Assign to texture Enable texturing 2. Assign texture coordinates to vertices Proper mapping function is left to application 3. Specify texture parameters Wrapping, Filtering 77

Texture Coordinates Specify a texture coordinate at each vertex Mapping between (s, t) and (u, v) t Texture Space Object Space 1, 1 (s, t) = (0.2, 0.8) 0, 1 A a c (0.4, 0.2) b B C 0, 0 1, 0 (0.8, 0.4) s 78

Transformations Rectangular Pattern Array Surface Pixel Area Texture Space Object Space mage Space (s, t) (u, v) (x, y) Texture - Surface Transformation u = f u (s,t) = a u s + b u t + c u v = f v (s,t) = a v s + b v t + c v Viewing and projection Transformation Texture scanning (s,t) (x,y) nverse scanning (x,y) (s,t) 79

Mapping Functions Basic problem is how to find the maps Consider mapping from texture coordinates to a point a surface Appear to need three functions x = x(s,t) y = y(s,t) z = z(s,t) But we really want to go the other way t s (x,y,z) 80

Backward Mapping We really want to go backwards A B Given a pixel, we want to know to which point on an object it corresponds Given a point on an object, we want to know to which point in the texture it corresponds Need a map of the form s = s(x,y,z) t = t(x,y,z) Such functions are difficult to find in general 81

Texture Mapping Projecting pixel areas to texture space = inverse scanning (x,y)(s,t) A B 82

Example: Surface Texture Mapping 83

84

Planar Map Shape Determine which component was projected by looking for color changes in coordinate directions When moving parallel to the x-axis, an object s color changes. When moving up and down along the y-axis, the object s color also changes. However, movement along the z-axis does not produce a change in color. 85

Cylinder Map Shape An (x,y,z) value is converted to cylindrical coordinates of ( r, theta, height ) theta is converted into x-coordinate height is converted into y-coordinate 86

Sphere Map Shape The (x,y,z) value of a point is converted into spherical coordinates The latitude is converted into an x-coordinate The longitude is converted into a y-coordinate 87

Box Map Shape Enclosing box is usually axis-parallel bounding box of object Six rectangles onto which the texture is mapped Similar to planar mapping 88

Bump Mapping Bump mapping affects object surfaces, making them appear rough, wrinkled, or dented Bump mapping alters the surface normals before the shading calculation takes place 89

Environment Mapping A two-dimensional texture mapping technique that uses a map shape of a box and a map parameter of a reflection ray it s easy to create reflections with a ray tracer, ray tracing is still too expensive for long animations 90

Ray Tracing Provides rendering method with Refraction/Transparent surfaces Reflective surfaces Shadows mage taken from http://www.tjhsst.edu/~dhyatt/superap/samplex.jpg 91

Ray-Tracing Principle A global illumination based rendering method t traces rays of light from the eye back through h the image plane into the scene Handles shadows, multiple specular reflections, and texture mapping 92

Rays & Ray Tree Corresponding binary ray-tracing tree Primary-, Secondary-, Reflected-, Transmitted- Rays 93

Radiosity Light can be reflected between two objects that have diffuse surfaces This is commonly called color bleeding Radiosity treats light as energy llumination of the scene is the transfer of energy mage created by Erik Svanholm 2002 Zumtobel Staff 94

Radiosity Method Describe the physical process of light distribution in a diffuse reflecting environment Areas that are not illuminated directly are also not completely dark Every objects act as a secondary light source 95

Ray-Tracing VS Radiosity Ray-Tracing mage-space From Eye to Light Specular Reflection Radiosity Object-Space From Light to Surface Diffuse Reflection 96

End of Chapter 10 99