Illumination and Shading

Similar documents
Illumination & Shading: Part 1

Shading and Illumination

Computer Graphics. Illumination and Shading

Illumination and Shading

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

Sung-Eui Yoon ( 윤성의 )

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

INF3320 Computer Graphics and Discrete Geometry

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

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

Illumination and Shading

OpenGL Lighting Computer Graphics Spring Frank Palermo

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010)

Illumination & Shading

LIGHTING AND SHADING

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Illumination Models & Shading

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

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

Comp 410/510 Computer Graphics. Spring Shading

Why we need shading?

Shading. Brian Curless CSE 457 Spring 2015

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

Shading. CSE 457 Winter 2015

CS5620 Intro to Computer Graphics

Light Sources. Spotlight model

Introduction to Computer Graphics 7. Shading

Lighting and Shading

5.2 Shading in OpenGL

Shading , Fall 2004 Nancy Pollard Mark Tomczak

w Foley, Section16.1 Reading

Shading in OpenGL. Outline. Defining and Maintaining Normals. Normalization. Enabling Lighting and Lights. Outline

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

Shading II. CITS3003 Graphics & Animation

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

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

Lighting/Shading III. Week 7, Wed Mar 3

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

Illumination and Shading ECE 567

Illumination and Shading

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

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

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

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

CGT520 Lighting. Lighting. T-vertices. Normal vector. Color of an object can be specified 1) Explicitly as a color buffer

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Projections and Hardware Rendering. Brian Curless CSE 557 Fall 2014

CEng 477 Introduction to Computer Graphics Fall

Interpolation using scanline algorithm

Shading Intro. Shading & Lighting. Light and Matter. Light and Matter

Shading 1: basics Christian Miller CS Fall 2011

CS 148, Summer 2012 Introduction to Computer Graphics and Imaging

CS Surface Rendering

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

CS 432 Interactive Computer Graphics

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

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

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

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

CPSC 314 LIGHTING AND SHADING

Lighting/Shading II. Week 7, Mon Mar 1

Shading. Brian Curless CSE 457 Spring 2017

Surface Rendering Methods

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Illumination & Shading I

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

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

Light Transport Baoquan Chen 2017

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

Illumination and Reflection in OpenGL CS 460/560. Computer Graphics. Shadows. Photo-Realism: Ray Tracing. Binghamton University.

Virtual Reality for Human Computer Interaction

Virtual Reality for Human Computer Interaction

Illumination in Computer Graphics

Illumination. Illumination CMSC 435/634

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

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

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

Shading I Computer Graphics I, Fall 2008

Illumination & Shading

Ambient reflection. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 407

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

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

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

Shading. Brian Curless CSE 557 Autumn 2017

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

Pipeline Operations. CS 4620 Lecture 14

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

Computer Graphics MTAT Raimond Tunnel

Pipeline Operations. CS 4620 Lecture 10

University of Victoria CSC 305 Shading. Brian Wyvill 2016

Rendering Light Reflection Models

Lecture 15: Shading-I. CITS3003 Graphics & Animation

CS770/870 Spring 2017 Color and Shading

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

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

Lab 9 - Metal and Glass

The Rasterization Pipeline

Transcription:

CT4510: Computer Graphics Illumination and Shading BOCHANG MOON

Photorealism The ultimate goal of rendering is to produce photo realistic images. i.e., rendered images should be indistinguishable from photographs

Illumination (Lighting) Model A technique (or a model) that computes the color of a surface, by considering the following: Lights color, geometry (position and direction), Surfaces reflectance (color), geometry (position and normal), direct path indirect path

Phong Illumination Model A simple model that considers the three terms below: Ambient: Assume that each surface receives a constant amount of light Ignore the following: Position and orientation of a surface Position of a viewer Direction of a light II = LL aa kk aa LL aa : intensity of an ambient light kk aa : coefficient of ambient reflection ambient

Phong Illumination Model A simple model that considers the three terms below: Diffuse: Surfaces can have different colors based on distance and orientation with respect to the light source diffuse

Diffuse Reflection A simple model that considers the three terms below: Diffuse: When light intersects with an ideal diffuse surface, the surface reflects light equally in all directions. Lambertian reflection Outgoing light intensity is independent from the position of the viewer. II = LL dd kk dd cccccccc = LL dd kk dd nn ll n pp ll LL dd : intensity of a light source kk dd : coefficient of diffuse reflection Q. When does the second equality hold? Q. kk dd > 1? θθ ll = pp ll pp pp ll pp point light source p

Diffuse Reflection A simple model that considers the three terms below: Diffuse: When light intersects with an ideal diffuse surface, the surface reflects light equally in all directions. Lambertian reflection Outgoing light intensity is independent from the position of the viewer. II = LL dd kk dd cccccccc = LL dd kk dd nn ll n ll = gggggggggg vvvvvvvvvvvv LL dd : intensity of a light source kk dd : coefficient of diffuse reflection Q. When does the second equality hold? Q. kk dd > 1? θθ direction light source when the distance between a light source and objects is infinite (e.g., sun) Q. nn ll < 0? p

Light Source Attenuation (optional) A simple model that considers the three terms below: Diffuse: When light intersects with an ideal diffuse surface, the surface reflects light equally in all directions. Lambertian reflection Outgoing light intensity is independent from the position of the viewer. II = LL dd kk dd cccccccc = ff aaaaaaaaaa LL dd kk dd nn ll n pp ll LL dd : intensity of a light source kk dd : coefficient of diffuse reflection ff aaaaaaaaaa = 1 2 dd oooo min CC 1 1, 2 ll dd ll Intensity of a light source follows an inverse square law (from physics) θθ ll = pp ll pp pp ll pp point light source p

Specular Reflection A simple model that considers the three terms below: specular: When light intersects with a shiny surface, it can be seen as highlights (directional) It also depends on how much the surface is shiny (shininess). The viewing direction is also important. n r ll vv = ee pp ee pp p

Specular Reflection The reflection vector r is determined by Snell s law. Snell s law nn ii ssssssθθ ii = nn oo ssssssθθ oo nn ii, nn oo : indices of refraction Determined by the relative speeds of light Reflection is a special case Image from wikipedia θθ ll = θθ rr The medium of the incoming light and reflected ray is the same. n r ll θθ oo θθ ll p

Specular Reflection A simple model that considers the three terms below: specular: II = LL ss kk ss cos ss αα = LL ss kk ss rr vv ss LL ss : intensity of a light source kk ss : coefficient of specular reflection ss: shininess of a surface n r ll v αα θθ oo θθ ll p

Specular Reflection The reflection vector, r, can be computed as the following: rr = 2 nn ll nn ll nn ll: length of the projected vector onto nn Note: we don t need to use the denominator nn r 2 nn ll nn n ll θθ oo θθ ll p ll

Non-ideal Specular Reflection A simple model that considers the three terms below: specular: II = LL ss kk ss cos ss αα = LL ss kk ss rr vv ss LL ss : intensity of a light source kk ss : coefficient of specular reflection ss: shininess of a surface Note: Snell s law does not explain this case. i.e., it is only for ideal reflection (e.g., reflection on mirror) Approaches Simulate all the reflected rays Empirically capture this effect (highlights) with simple parameters (i.e., s) In practice, we should use a clamping function, mmmmmm rr vv, 0 r n ll p

Non-ideal Specular Reflection A simple model that considers the three terms below: specular: II = LL ss kk ss cos ss αα = LL ss kk ss rr vv ss LL ss : intensity of a light source kk ss : coefficient of specular reflection ss: shininess of a surface control the shape of the highlights s = 3 s = 10 s = 30

Blinn-Phong Model A modification to the Phong specular model is to replace the reflection vector with the halfway vector. h = ll+vv ll+vv II = LL ss kk ss cos ss αα = LL ss kk ss nn hh ss Note Cheaper than the Phong model Another empirical model n r h ll v αα θθ oo θθ ll p

Phong Illumination Model A simple model that considers the three terms below: II = II aa + II dd + II ss = LL aa kk aa + LL dd kk dd max 0, nn ll + LL ss kk ss max 0, rr vv ss + + = ambient diffuse specular

Multiple Light Sources # oooo II = lllllllllll ii=1 LL ii aa kk aa + LL ii dd kk dd max 0, nn ll ii + LL ii ss kk ss max 0, rr ii vv ss OpenGL uses this empirical model. Need to specify LL aa, LL dd, LL ss for each light Need to assign material properties kk aa, kk dd, kk ss, ss to each object (or each triangle) + + = ambient diffuse specular

Example Code in OpenGL // build a point light on the position & set parameters for the light float pointlight [] = { 0.0, 10.0, 0.0, 1.0 }; float La[] = { 0.1, 0.1, 0.1, 1.0 }; float Ld[] = { 1.0, 1.0, 1.0, 1.0 }; float Ls[] = { 1.0, 1.0, 1.0, 1.0 }; gllightfv(gl_light0, GL_POSITION, pointlight); gllightfv(gl_light0, GL_AMBIENT, La); gllightfv(gl_light0, GL_DIFFUSE, Ld); gllightfv(gl_light0, GL_SPECULAR, Ls); glenable(gl_light0);

Example Code in OpenGL // assign a material to an object float ka[] = { 0.3, 0.8, 0.1, 1.0 }; float kd[] = { 0.3, 0.8, 0.1, 1.0 }; float ks[] = { 0.9, 0.9, 0.9, 1.0 }; float shininess[] = { 30.0 }; glmaterialfv(gl_front, GL_AMBIENT, ka); glmaterialfv(gl_front, GL_DIFFUSE, kd); glmaterialfv(gl_front, GL_SPECULAR, ks); glmaterialfv(gl_front, GL_SHININESS, shininess); Illuminated by light0

Example Code in OpenGL // build a directional light (w = 0.0) float directionallight[] = { 0.0, -10.0, 0.0, 0.0 }; gllightfv(gl_light1, GL_POSITION, directionallight); gllightfv(gl_light1, GL_AMBIENT, La); gllightfv(gl_light1, GL_DIFFUSE, Ld); gllightfv(gl_light1, GL_SPECULAR, Ls); glenable(gl_light1); Illuminated by light0 Illuminated by light1 Illuminated by both lights

Shading An illumination model defines how to compute the color of a point on surfaces. A shading model defines where we should use the illumination model. Flat (constant) Gouraud Phong

Flat (Constant) Shading The illumination model is applied only once to a polygon All points within the polygon have the same color Properties Very simple & cheap Very low rendering quality (not smooth) OpenGL code glshademodel(gl_flat);

Gouraud Shading The illumination model is applied to each vertex of a polygon The inside points colors of the polygon are interpolated ones of the vertex colors Properties More expensive than the flat shading Higher quality than the constant Relatively good but still not very smooth OpenGL code glshademodel(gl_smooth);

Vertex Normal The normal at a vertex is generally an averaged one of the normals of neighboring polygons

Phong Shading The illumination model is applied for each point of a polygon Should compute the normal at a point by interpolating the vertex normals Properties Much more expensive than the flat and Gouraud shading methods Produce very smooth appearance OpenGL code Not supported as a simple function call You should implement it (e.g., per-fragment shading) Further reading: search fragment shader (c/c++ like language) You can make your own shading

Gouraud vs. Phong Shading Gouraud shading may miss some highlights in the middle of a polygon It scarifies the quality to improve rendering speed Q. Is there a way to improve the quality without using Phong shading? Original model Approximate model

Gouraud vs. Phong Shading Gouraud shading may miss some highlights in the middle of a polygon It scarifies the quality to improve rendering speed Q. Is there a way to improve the quality without using Phong shading? We can subdivide a polygon into multiple polygons Original model Approximate model

Gouraud vs. Phong Shading Gouraud shading may miss some highlights in the middle of a polygon It scarifies the quality to improve rendering speed Q. Is there a way to improve the quality without using Phong shading? We can subdivide a polygon into multiple polygons

Illumination Models Local illumination Global illumination

Local Illumination Determine the colors of surface points based on only local information: Materials of the surface Geometry (normal and position) of the point Lights Limitations: One-bounce reflection of light Hack (ambient term) for approximation indirect illumination Phong illumination model Empirical model for local illumination

Global Illumination Light can traverse in the virtual world: Colors of a surface can be affected by lights and other surfaces e.g., ray tracing

Image from [Moon et al., TOG10] Global Illumination

Image from [Moon et al., SIG16] Some videos?

Further Readings Chapter 4.5 Chapter 10