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

Similar documents
Computer Graphics. Illumination and Shading

Visualisatie BMT. Rendering. Arjan Kok

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Illumination and Shading

CPSC / Illumination and Shading

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Virtual Reality for Human Computer Interaction

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

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

CS5620 Intro to Computer Graphics

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

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

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

Introduction to Computer Graphics 7. Shading

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Illumination Models & Shading

w Foley, Section16.1 Reading

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

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

Illumination & Shading

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Shading I Computer Graphics I, Fall 2008

Reflection and Shading

Computer Graphics MTAT Raimond Tunnel

Comp 410/510 Computer Graphics. Spring Shading

CS770/870 Spring 2017 Color and Shading

CPSC 314 LIGHTING AND SHADING

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

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

Computer Graphics: 3-Local Illumination Models

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

Computer Graphics and GPGPU Programming

Chapter 7 - Light, Materials, Appearance

Deferred Rendering Due: Wednesday November 15 at 10pm

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

CS Illumination and Shading. Slide 1

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

9. Illumination and Shading

Shading. Brian Curless CSE 457 Spring 2017

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

Supplement to Lecture 16

Illumination and Shading

Illumination. The slides combine material from Andy van Dam, Spike Hughes, Travis Webb and Lyn Fong

Lighting and Materials

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

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

Computer Graphics. Illumination and Shading

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

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

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Lighting. Figure 10.1

Introduction to Visualization and Computer Graphics

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Shading Models. Welcome!

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

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

INF3320 Computer Graphics and Discrete Geometry

Shading and Illumination

Illumination & Shading I

Simple Lighting/Illumination Models

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Sung-Eui Yoon ( 윤성의 )

CEng 477 Introduction to Computer Graphics Fall

Light Sources. Spotlight model

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

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

CS 4600 Fall Utah School of Computing

Lighting and Shading

The Rasterizer Stage. Texturing, Lighting, Testing and Blending

CS 325 Computer Graphics

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Photorealism: Ray Tracing

Hot Sync. Materials Needed Today

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Illumination and Shading

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

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

CS452/552; EE465/505. Intro to Lighting

Shading. Brian Curless CSE 557 Autumn 2017

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

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

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

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

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

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

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

Illumination and Shading

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

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

6. Illumination, Lighting

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

CS 130 Exam I. Fall 2015

Pipeline Operations. CS 4620 Lecture 14

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

Raytracing CS148 AS3. Due :59pm PDT

Complex Shading Algorithms

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

Transcription:

Light

Shading

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

Shading Shading = find color values at pixels of screen (when rendering a virtual 3D scene). Same as finding color value for the closest triangle on the ray of the pixel (assuming this is an opaque object, and air is clear).

Shading Shading = find color values at pixels of screen (when rendering a virtual 3D scene). Same as finding color value for the closest triangle on the ray of the pixel (assuming this is an opaque object, and air is clear). Core objective: Find color values for intersection of a ray with a triangle.

Shading Core objective: Find color values for point at intersection of a ray with a triangle.

Shading Core objective: Find color values for point at intersection of a ray with a triangle. Recall: Rendering is triangle-driven (foreach triangle: render). Triangles are simply (triples of) vertices until rasterization phase, where pixels of the triangle are found from pixels of the vertices. So the rays relevant for a given triangle are determined in the rasterization phase.

Modeling Light Core objective: Find color values for intersection of a ray with a triangle.

Modeling Light Core objective: Find color values for intersection of a ray with a triangle. Model physical light (photons)

Modeling Light Core objective: Find color values for intersection of a ray with a triangle. Model physical light (photons) In real life, photons are Emitted from ligth sources. Reflected, absorbed, re-emitted, transmitted when hitting objects.

Modeling Light Highly complex physical proces, mainly at surfaces of materials. Zillions of photons involved. Can only be modeled to a certain degree mathematically (ongoing research expands on the available models).

Modeling Light Highly complex physical proces, mainly at surfaces of materials. Zillions of photons involved. Can only be modeled to a certain degree mathematically (ongoing research expands on the available models). (Figure by Jason Jacobs)

Modeling Light Realtime rendering additionally has severe time constraints. Framerate 30/sec, screen size 10 6 pixels few GPU cycles available for calculation per ray. For a 0.3 Teraflop CPU, this gives a maximum of 10 4 flops for all handling of all triangles pertaining to a given pixel/ray.

Modeling Light Realtime rendering additionally has severe time constraints. Framerate 30/sec, screen size 10 6 pixels few GPU cycles available for calculation per ray. For a 0.3 Teraflop CPU, this gives a maximum of 10 4 flops for all handling of all triangles pertaining to a given pixel/ray. Hence, realtime rendering uses rough models.

Modeling Light Realtime rendering additionally has severe time constraints. Framerate 30/sec, screen size 10 6 pixels few GPU cycles available for calculation per ray. For a 0.3 Teraflop CPU, this gives a maximum of 10 4 flops for all handling of all triangles pertaining to a given pixel/ray. Hence, realtime rendering uses rough models. Today: the classic model (Phong s lighting model, 1975) built into classic OpenGL under the name the fixed-functionality pipeline. The model is very heuristic (has skimpy physical backing). But gives an introduction to many main ingredients of lighting models.

Modeling Light Realtime rendering additionally has severe time constraints. Framerate 30/sec, screen size 10 6 pixels few GPU cycles available for calculation per ray. For a 0.3 Teraflop CPU, this gives a maximum of 10 4 flops for all handling of all triangles pertaining to a given pixel/ray. Hence, realtime rendering uses rough models. Today: the classic model (Phong s lighting model, 1975) built into classic OpenGL under the name the fixed-functionality pipeline. The model is very heuristic (has skimpy physical backing). But gives an introduction to many main ingredients of lighting models. More advanced models: use programmable GPU (shaders = programs for light calculations (and other vertex manipulation), see Chapters 20 21).

Modeling Light Realtime rendering additionally has severe time constraints. Framerate 30/sec, screen size 10 6 pixels few GPU cycles available for calculation per ray. For a 0.3 Teraflop CPU, this gives a maximum of 10 4 flops for all handling of all triangles pertaining to a given pixel/ray. Hence, realtime rendering uses rough models. Today: the classic model (Phong s lighting model, 1975) built into classic OpenGL under the name the fixed-functionality pipeline. The model is very heuristic (has skimpy physical backing). But gives an introduction to many main ingredients of lighting models. More advanced models: use programmable GPU (shaders = programs for light calculations (and other vertex manipulation), see Chapters 20 21). Actually, on modern programmable GPUs, the fixed-functionality pipeline of classic mode OpenGL is just a default shader program. (Used to be hardwired into GPUs).

Color Photons/light waves have frequencies:

Color The lights following a ray has in real life a spectrum:

Color The lights following a ray has in real life a spectrum: The eye sees colors by ligth-sensitive cells called cones. Three types of cone cells, with different sensitivity to various wavelengths. Peaks of sensitiviy in red, green, blue parts of spectrum, respectively.

Color The lights following a ray has in real life a spectrum: The eye sees colors by ligth-sensitive cells called cones. Three types of cone cells, with different sensitivity to various wavelengths. Peaks of sensitiviy in red, green, blue parts of spectrum, respectively. So input spectrum in ray three-tuple output from each cone-triple to brain. Different spectra can give same output to brain.

Color The lights following a ray has in real life a spectrum: The eye sees colors by ligth-sensitive cells called cones. Three types of cone cells, with different sensitivity to various wavelengths. Peaks of sensitiviy in red, green, blue parts of spectrum, respectively. So input spectrum in ray three-tuple output from each cone-triple to brain. Different spectra can give same output to brain. On computer displays: use mix of (monocromatic) red, green, blue to stimulate cones and control the eye/brain s color perception.

Color The lights following a ray has in real life a spectrum: The eye sees colors by ligth-sensitive cells called cones. Three types of cone cells, with different sensitivity to various wavelengths. Peaks of sensitiviy in red, green, blue parts of spectrum, respectively. So input spectrum in ray three-tuple output from each cone-triple to brain. Different spectra can give same output to brain. On computer displays: use mix of (monocromatic) red, green, blue to stimulate cones and control the eye/brain s color perception. Hence, displays (and hence OpenGL) work with (R,G,B)-tuples as color values. [Or four-tuples, if alpha/transparency information is included.]

Lightning Models Define virtual lights. Define light/surface interactions.

Virtual Lights in OpenGL Directional: light direction same for all points in scene (light emits infinitely far from scene think sun).

Virtual Lights in OpenGL Directional: light direction same for all points in scene (light emits infinitely far from scene think sun). Positional: light emits from a 3D point in the scene. Light direction varies for different points in the scene.

Virtual Lights in OpenGL Directional: light direction same for all points in scene (light emits infinitely far from scene think sun). Positional: light emits from a 3D point in the scene. Light direction varies for different points in the scene. Spot: like positional, but with cone restricting light emission. Attenuation factor towards side of cone: (cos α) h

Virtual Lights in OpenGL Directional: light direction same for all points in scene (light emits infinitely far from scene think sun). Positional: light emits from a 3D point in the scene. Light direction varies for different points in the scene. Spot: like positional, but with cone restricting light emission. Attenuation factor towards side of cone: (cos α) h

Virtual Lights in OpenGL Directional: light direction same for all points in scene (light emits infinitely far from scene think sun). Positional: light emits from a 3D point in the scene. Light direction varies for different points in the scene. Spot: like positional, but with cone restricting light emission. Attenuation factor towards side of cone: (cos α) h Attenuation factor for positional/spot lights (d = distance from surface point to light position): 1 a + b d + c d 2

Phongs Lightning Model

Phongs Lightning Model Models only opaque objects. Models generally only one level of light/surface interactions (except ambient term, see below). Light/surface interaction is modeled by two simple submodels, diffuse and specular term. Models indirect light effects very crudely (ambient term). Light actually generated at surface can be added (emissive term). Occlusion is not modeled (all objects see all lights).

Generic Material and Light Interaction Surfaces (materials) and light has color.

Generic Material and Light Interaction Surfaces (materials) and light has color. Light: intensity value in [0, 1] for each of the three RGB-channels. One triple for each light.

Generic Material and Light Interaction Surfaces (materials) and light has color. Light: intensity value in [0, 1] for each of the three RGB-channels. One triple for each light. Material: scaling factor in [0, 1] for each of the three RGB-channels. One triple for each vertex in each primitive.

Generic Material and Light Interaction Surfaces (materials) and light has color. Light: intensity value in [0, 1] for each of the three RGB-channels. One triple for each light. Material: scaling factor in [0, 1] for each of the three RGB-channels. One triple for each vertex in each primitive. Basic interaction: (light intensity value) (material attenuation factor).

Generic Material and Light Interaction Surfaces (materials) and light has color. Light: intensity value in [0, 1] for each of the three RGB-channels. One triple for each light. Material: scaling factor in [0, 1] for each of the three RGB-channels. One triple for each vertex in each primitive. Basic interaction: (light intensity value) (material attenuation factor). (Note: multiplication performed separately on each of the three RGB-channels).

Generic Material and Light Interaction Surfaces (materials) and light has color. Light: intensity value in [0, 1] for each of the three RGB-channels. One triple for each light. Material: scaling factor in [0, 1] for each of the three RGB-channels. One triple for each vertex in each primitive. Basic interaction: (light intensity value) (material attenuation factor). (Note: multiplication performed separately on each of the three RGB-channels). (Note: actually one light intensity triple (for lights) and one material attenuation factor (for vertices) for each of the terms ambient, diffuse, and specular (see later). But this flexibility often not used/needed.)

Diffuse Term in Phong L Amberts law [1760] for perfectly scattered light (100% matte surfaces).

Diffuse Term in Phong L Amberts law [1760] for perfectly scattered light (100% matte surfaces). Light influx per area on surface depends on angle θ between light vector (light direction) and surface normal at point. Dependency/attenuation is factor of cos θ. Light is scattered equally from point in all directions ( eye ray vector does not matter).

Diffuse Term in Phong L Amberts law [1760] for perfectly scattered light (100% matte surfaces). Light influx per area on surface depends on angle θ between light vector (light direction) and surface normal at point. Dependency/attenuation is factor of cos θ. Light is scattered equally from point in all directions ( eye ray vector does not matter).

Specular Term in Phong Models highlights/shininess using heuristic formula.

Specular Term in Phong Models highlights/shininess using heuristic formula. Depends on light vector (light direction), eye ray vector, and surface normal at point.

Specular Term in Phong Models highlights/shininess using heuristic formula. Depends on light vector (light direction), eye ray vector, and surface normal at point.

Specular Term in Phong Models highlights/shininess using heuristic formula. Depends on light vector (light direction), eye ray vector, and surface normal at point. Let φ be angle between halfway vector s = (l + e) and the normal vector n.

Specular Term in Phong Models highlights/shininess using heuristic formula. Depends on light vector (light direction), eye ray vector, and surface normal at point. Let φ be angle between halfway vector s = (l + e) and the normal vector n. Attenuation factor: (cos φ) f

Specular Term in Phong Models highlights/shininess using heuristic formula. Depends on light vector (light direction), eye ray vector, and surface normal at point. Let φ be angle between halfway vector s = (l + e) and the normal vector n. Attenuation factor: (cos φ) f

Ambient Term(s) in Phong Models indirect light (crudely).

Ambient Term(s) in Phong Models indirect light (crudely). Everywhere is some light.

Ambient Term(s) in Phong Models indirect light (crudely). Everywhere is some light. Light calculation does not depend points normal vector, direction of eye ray, direction of light (except for spot attenuation).

Ambient Term(s) in Phong Models indirect light (crudely). Everywhere is some light. Light calculation does not depend points normal vector, direction of eye ray, direction of light (except for spot attenuation). More precisely: there is one global ambient term, plus one ambient term for each light. The latter allows for individually colored light, and distance and spot attenuation. Besides distance and spot attenuation, the calculation is just the basic multiplication of material and light.

Emissive Term in Phong This is another material value signifying if light is actually created at the point. This is just an RGB-triple added to the result of the rest of the calculations for the point.

Emissive Term in Phong This is another material value signifying if light is actually created at the point. This is just an RGB-triple added to the result of the rest of the calculations for the point. Note: the emitted light is only used for the color value of the pixel (of the ray hitting the point). It is not taken into consideration when calculating color values at other points.

Emissive Term in Phong This is another material value signifying if light is actually created at the point. This is just an RGB-triple added to the result of the rest of the calculations for the point. Note: the emitted light is only used for the color value of the pixel (of the ray hitting the point). It is not taken into consideration when calculating color values at other points. Thus, having a bulb both visible and giving light in a scene will involve: Creating polygons for the bulb and setting their emissive properties to non-zero (probably close to (1,1,1)). Creating a virtual light at the center of the bulb.

Lighting Equation Add basic interactions between material and light as follows: One term for object light emission (usually zero). One term for global ambient light. For each light defined: add terms for per-light ambient term, diffuse term, and specular term (with distance and spot attenuation where appropriate). This is done once for each RGB-channel. A resulting value above 1.0 is just truncated to 1.0.

Lighting Equation in Math channel value = emissive term + amb material amb global + all lights dist attenuation spot attenuation (amb material amb light + max{ l n, 0} diff material diff light + (max{ s n, 0}) f spec material spec light)

Shading models So we now have information in each vertex. How spread color calculation over entire triangle pixels?

Shading models So we now have information in each vertex. How spread color calculation over entire triangle pixels? Flat shading: Color calculated for one point is used for entire triangle.

Shading models So we now have information in each vertex. How spread color calculation over entire triangle pixels? Flat shading: Color calculated for one point is used for entire triangle. Smooth shading (aka. Gouraud shading): Colors calculated for three vertices are interpolated across the entire triangle (individually for each RGB-channel).

Shading models So we now have information in each vertex. How spread color calculation over entire triangle pixels? Flat shading: Color calculated for one point is used for entire triangle. Smooth shading (aka. Gouraud shading): Colors calculated for three vertices are interpolated across the entire triangle (individually for each RGB-channel). Phong shading: Color calculation done for all points of pixels.

Shading models So we now have information in each vertex. How spread color calculation over entire triangle pixels? Flat shading: Color calculated for one point is used for entire triangle. Smooth shading (aka. Gouraud shading): Colors calculated for three vertices are interpolated across the entire triangle (individually for each RGB-channel). Phong shading: Color calculation done for all points of pixels.

Shading models So we now have information in each vertex. How spread color calculation over entire triangle pixels? Flat shading: Color calculated for one point is used for entire triangle. Smooth shading (aka. Gouraud shading): Colors calculated for three vertices are interpolated across the entire triangle (individually for each RGB-channel). Phong shading: Color calculation done for all points of pixels. Calculation time increases down the list. Phong shading needs programmable shaders (not part of OpenGL fixed-functionality pipeline).