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

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

Illumination and Shading

Illumination and Shading

Shading Models. Simulate physical phenomena

Illumination & Shading I

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

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

CS5620 Intro to Computer Graphics

Shading and Illumination

Illumination Models & Shading

521493S Computer Graphics Exercise 3 (Chapters 6-8)

CS770/870 Spring 2017 Color and Shading

11/2/2010. In the last lecture. Monte-Carlo Ray Tracing : Path Tracing. Today. Shadow ray towards the light at each vertex. Path Tracing : algorithm

Comp 410/510 Computer Graphics. Spring Shading

Illumination & Shading

Shading I Computer Graphics I, Fall 2008

CS Illumination and Shading. Slide 1

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Computer Graphics. Illumination and Shading

CPSC 314 LIGHTING AND SHADING

Computer Graphics (CS 543) Lecture 8a: Per-Vertex lighting, Shading and Per-Fragment lighting

CEng 477 Introduction to Computer Graphics Fall

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

CS 428: Fall Introduction to. Geometric Transformations. Andrew Nealen, Rutgers, /15/2010 1

w Foley, Section16.1 Reading

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

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

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

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

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

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Ø Sampling Theory" Ø Fourier Analysis Ø Anti-aliasing Ø Supersampling Strategies" Ø The Hall illumination model. Ø Original ray tracing paper

Illumination in Computer Graphics

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

Visualisatie BMT. Rendering. Arjan Kok

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

Virtual Reality for Human Computer Interaction

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

CPSC / Illumination and Shading

Reflection and Shading

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

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

University of Victoria CSC 305 Shading. Brian Wyvill 2016

Illumination. Michael Kazhdan ( /657) HB Ch. 14.1, 14.2 FvDFH 16.1, 16.2

Computer Graphics. Illumination and Shading

Shading. Shading = find color values at pixels of screen (when rendering a virtual 3D scene).

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

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

CS 5625 Lec 2: Shading Models

CS 4600 Fall Utah School of Computing

CS452/552; EE465/505. Intro to Lighting

Perception of Shape from Shading

Color and Light. CSCI 4229/5229 Computer Graphics Summer 2008

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

Global Illumination with Photon Map Compensation

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

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

-=Bui Tuong Phong's Lighting=- University of Utah, but with shaders. Anton Gerdelan Trinity College Dublin

Models and Architectures

Texture Mapping with Vector Graphics: A Nested Mipmapping Solution

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

Phong Lighting & Materials. Some slides modified from: David Kabala Others from: Andries Van Damm, Brown Univ.

Shading , Fall 2004 Nancy Pollard Mark Tomczak

Assigning colour to pixels or fragments. Modelling Illumination. We shall see how it is done in a rasterization model. CS475/CS675 - Lecture 14

Turn on the Lights: Reflectance

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

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?

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

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

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

Illumination & Shading: Part 1

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

Lighting Models. CS116B Chris Pollett Mar 21, 2004.

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

Computer Graphics (CS 4731) Lecture 18: Lighting, Shading and Materials (Part 3)

CSE 681 Illumination and Phong Shading

Given: scene specification (object positions, optical properties p of the surface, viewer position, viewing direction, )

Illumination Models and Surface-Rendering Methods. Chapter 10

Lighting and Reflectance COS 426

Interactive Real-Time Raycasting

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

Computer Graphics. Shading. Page. Copyright Gotsman, Elber, Barequet, Karni, Sheffer Computer Science, Technion. The Physics

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

Simple Lighting/Illumination Models

Photorealism: Ray Tracing

Illumination and Shading

CS 325 Computer Graphics

Shading. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller/Fuhrmann

Shading. Brian Curless CSE 457 Spring 2017

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

Lighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

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

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

INF3320 Computer Graphics and Discrete Geometry

Lighting/Shading III. Week 7, Wed Mar 3

Introduction to Computer Graphics 7. Shading

Raytracing CS148 AS3. Due :59pm PDT

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

Transcription:

Illumination and Shading Illumination (ighting) Model the interaction of light with surface oints to determine their final color and brightness OenG comutes illumination at vertices illumination Shading Aly the lighting model at a set of oints across the entire surface Shading Illumination Model The governing rinciles for comuting the illumination A illumination model usually considers: ight attributes (light intensity, color, osition, direction, shae) Object surface attributes (color, reflectivity, transarency, etc) Interaction among lights and objects (object orientation) Interaction between objects and eye (viewing dir.)

Illumination Calculation Illumination Models ocal illumination: only consider the light, the observer osition, and the object material roerties Global illumination: take into account the interaction of light from all the surfaces in the scene object 4 θ object 3 object 2 object 1 Examle: OenG Examle: Ray Tracing (CIS681) Basic ight Tyes Directional So far away so that light rays are Remember orthogonal rojection? sun Directional light ight Source Tyes Point ight emanates equally in all directions Sot Point source limited to an angle Sot light Point light from Akenine-Moller & Haines

Object Proerties What haens when light hits an object? Proerties of light reflection on an object s surface Reflectance Models Ambient Diffuse Secular Absortion, Emission, Transarency/Translucency Irradiance: All light that arrives at a oint on the surface Radiosity: ight leaving a surface in all directions Object Proerties Object Material Shiny (Metal), dull (Matte finish), mirror-like, glass, neon, etc. ocal vs. Global Illumination Simle local illumination ocal Illumination deends on local object & light sources only Global Illumination at a oint can deend on any other oint in the scene The model used by OenG considers three tyes of light contribution to comute the final illumination of an object Ambient Diffuse Secular Final illumination of a oint (vertex) = ambient + diffuse + secular

Ambient lighting examle Diffuse lighting examle Secular light examle ight Reflectance Comonents Take a oint P on the object surface: R R θ θ θ θ φ V : ight Vector R: Reflection Vector Reflects about the ormal () to the surface V: View Vector

Ambient Reflection Background light scattered by the environment ight bounces off of many objects Simle Global Illumination Simle reflectance model Indeendent of ight osition Object orientation Viewer s osition k a : Ambient reflection coefficient Ambient light an object reflects 0 k a 1 Ambient = I a * k a Diffuse Reflection ambert s aw: Radiant energy D that a small surface atch receives from a light source: D = I d * cos(θ) I d = light intensity, θ = Angle between and Also called ambertian or Matte surfaces ambert s aw (1) ambert s aw (2) How does D change if the light source moves? Max intensity How does D change on an object s surface? A shere s surface has all ossible normal directions θ, D = I d * cos(θ) o intensity

Diffuse Reflection Energy D is reflected equally in all directions on the surface Indeendent of Viewer s osition k d : Diffuse reflection coefficient Diffuse light an object reflects 0 k d 1 Secular Reflection (1) The reflection of the light source on the object Shiny/Glossy surfaces ot a erfect mirror Show u as Secular Highlights, i.e., bright sots Diffuse = I d * k d * cos(θ) = I d * k d * ( ) and must be normalized WHY??? Secular Reflection (2) The object reflects maximum light intensity in the direction of the reflection vector θ θ φ R V ight intensity increases as V gets closer to R V R = cos(φ) Secular obe The reflection of the light source is maximum at the reflection direction Falls off quickly as the viewer moves away The size of the lobe determines the shininess of the object The shinier the object the smaller the lobe (cos(φ)) shine

Secular Reflection k s : Secular reflection coefficient Secular light an object reflects 0 k s 1 Ambient/Diffuse/Secular Just ambient light: Diffuse and change Ambient I s φ n : surface normal at P : light intensity : angle between V and R : shininess factor R θ θ φ V Sec = I s * k s * cos n (φ) = I s * k s * (V R) n V and R must be unit vectors WHY??? eft: Shere with just diffuse reflection Right:Shere with just secular reflection Basic Reflectance Equation Reflectance = from Akenine-Moller & Haines Ambient Diffuse Secular Final = I a * k a + I d * k d * ( ) + I s * k s * (R V) n Put it all together Illumination from a single light source: Illum = ambient + diffuse + secular = Ka x I + Kd x I x max(0, ) + Ks x I x max(0,r V) n ote that the K s and the I s are vectors (RGB).

Put it all together If there are lights Total illumination for a oint P = Σ (Illum) Some more terms to be added (in OenG): Self emission Global ambient ight distance attenuation and sot light effect ighting in OenG Adot Phong lighting model (secular) lus diffuse and ambient lights ighting is comuted at vertices Interolate across surface (Gouraud/smooth shading) OR Use a constant illumination (get it from one of the vertices) Setting u OenG ighting: ight Proerties Enable/Disable lighting Surface material roerties Provide correct surface normals ight model roerties ight Proerties Proerty Examle Proerties: Colors / Position and tye / attenuation glightfv(light, roerty, value) 1 2 3 (1) constant: secify which light you want to set the roerty examle: G_IGHT0, G_IGHT1, G_IGHT2 you can create multile lights (OenG allows at least 8 lights) (2) constant: secify which light roerty you want to set the value examle: G_AMBIET, G_DIFFUSE, G_SPECUAR, G_POSITIO (check the red book for more) (3) The value you want to set to the roerty Define colors and osition a light Gfloat light_ambient[] = {0.0, 0.0, 0.0, 1.0}; Gfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0}; Gfloat light_secular[] = {1.0, 1.0, 1.0, 1.0}; Gfloat light_osition[] = {0.0, 0.0, 1.0, 1.0}; glightfv(g_ight0, G_AMBIET, light_ambient); glightfv(g_ight0, G_DIFFUSE, light_diffuse); glightfv(g_ight0, G_SPECUAR, light_secular); glightfv(g_ight0, G_POSITIO, light_osition); colors Position What if I set the Position to (0,0,1,0)?

Tyes of lights Turning on the lights OenG suorts two tyes of lights ocal light (oint light) Infinite light (directional light) Determined by the light ositions you rovide w = 0: infinite light source (faster) w!= 0: oint light osition = (x/w, y/w, z/w) Gfloat light_osition[] = {x,y,z,w}; Turn on the ower (for all the lights) glenable(g_ightig); gldisable(g_ightig); Fli each light s switch glenable(g_ightn) (n = 0,1,2, ) glightfv(g_ight0, G_POSITIO, light_osition); Controlling light osition Modelview matrix affects a light s osition You can secify the osition relative to: Eye sace: the highlight remains in the same osition relative to the eye call glightfv() before gluookat() World sace: a light s osition/direction aears fixed in the scene Call glightfv() after gluookat() Any model sace (not as intuitive). See ate Robin s Demo Material Proerties The color and surface roerties of a material (dull, shiny, etc.) How much the surface reflects the incident lights (ambient/diffuse/secular reflection coefficients) glmaterialfv(face, roerty, value) Face: material roerty for which face (e.g. G_FROT, G_BACK, G_FROT_AD_BACK) Proerty: what material roerty you want to set (e.g. G_AMBIET, G_DIFFUSE, G_SPECUAR, G_SHIIESS, G_EMISSIO, etc) Value: the value you can to assign to the roerty

Material Examle Define ambient/diffuse/secular reflection and shininess Gfloat mat_amb_diff[] = {1.0, 0.5, 0.8, 1.0}; refl. coefficient Gfloat mat_secular[] = {1.0, 1.0, 1.0, 1.0}; Gfloat shininess[] = {5.0}; (range: dull 0 very shiny128) glmaterialfv(g_frot_ad_back, G_AMBIET_AD_DIFFUSE, mat_amb_diff); glmaterialfv(g_frot, G_SPECUAR, mat_secular); glmaterialfv(g_frot, G_SHIIESS, shininess); Global light roerties glightmodelfv(roerty, value) Enable two-sided lighting roerty = G_IGHT_MODE_TWO_SIDE value = G_TRUE (G_FASE if you don t want two sided lighting) Global ambient color Proerty = G_IGHT_MODE_AMBIET Value = (red, green, blue, 1.0); Check the red book for others Surface ormals Correct normals are essential for correct lighting Associate a normal to each vertex glbegin( ) glormal3f(x,y,z) glvertex3f(x,y,z) glend() The normals you rovide need to have a unit length You can use glenable(g_ormaize) to have OenG normalize all the normals. Why not always have OenG do this? ighting revisit Where is lighting erformed in the grahics ieline? v1, m1 v2, m2 v3, m3 Rasterization texturing shading modeling and viewing viewort maing er vertex lighting interolate vertex colors rojection cliing Dislay

Polygon shading model Flat shading comute lighting once and assign the color to the whole olygon Flat shading Only use one vertex (usually the first one) normal and material roerty to comute the color for the olygon Benefit: fast to comute It is used when: The olygon is small enough The light source is far away (why?) The eye is very far away (why?) OenG command: glshademodel(g_fat) Smooth shading Remove edge discontinuity Comute lighting for more oints on each face Still has a mach-band erceived discontinuity due to your eye s edge detection. Smooth shading Two oular methods: Smooth shading (used by OenG) Per-fragment lighting (better secular highlight, requires rogrammable shaders in OenG) Flat shading smooth shading

Smooth Shading The smooth shading algorithm used in OenG glshademodel(g_smooth) ighting is calculated for each of the olygon vertices Colors are interolated for interior ixels Smooth Shading Per-vertex lighting calculation ormal is needed for each vertex Per-vertex normals can be comuted by averaging the adjacent face normals n1 n3 n n4 n2 n = (n1 + n2 + n3 + n4) / 4.0 Smooth Shading Smooth Shading Comute vertex illumination (color) before the rojection transformation Shade interior ixels: color interolation (normals are not needed) C2 C1 Ca = ler(c1, C2) Cb = ler(c1, C3) C3 er(ca, Cb) for all scanlines * ler: linear interolation inear interolation v1 a x b v2 x = a / (a+b) * v2 + b/(a+b) * v1 Interolate triangle color: use y distance to interolate the two end oints in the scanline, and use x distance to interolate interior ixel colors

Smooth Shading Problem ighting in the olygon interior can be inaccurate Smooth Shading Problem ighting in the olygon interior can be inaccurate Phong Shading Instead of interolation, we calculate lighting for each ixel inside the olygon (er ixel lighting) We need to have normals for all the ixels not rovided by the user Phong shading algorithm interolates the normals and comute lighting during rasterization (need to ma the normal back to world or eye sace though) Phong Shading (2) ormal interolation na = ler(n1, n2) ler(na, nb) n2 n3 n1 nb = ler(n1, n3) Slow! You will do this in the ray-tracing class.