Lighting Calculations

Slides:



Advertisements
Similar presentations
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Advertisements

CS 480/680 Computer Graphics Shading 2 Dr. Frederick C Harris, Jr.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Lighting and Illumination Lighting is the major problem in computer graphics, for either realism or real-time compositions- harder than modeling Consider.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of New Mexico
Computer Graphics - Class 10
Rendering (彩現 渲染).
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
Lighting and Shading Wen-Chieh (Steve) Lin
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
7M836 Animation & Rendering
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Course Website: Computer Graphics 16: Illumination.
LIGHTING Part One - Theory based on Chapter 6. Lights in the real world Lights bounce off surfaces and reflect colors, scattering light in many directions.
Shading Surface can either (both) 1.Emit light. E.g. light bult 2.Reflect light. E.g. Mirror.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Illumination.
CS 445 / 645: Introductory Computer Graphics
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.
CSE 381 – Advanced Game Programming GLSL Lighting.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
Local Illumination and Shading
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
Chris Mayer & Nic Shulver Shading Definitions Light emanating from small surfaces is called a Point light sourcee.g. the sun (not really small though!)
Lighting and Shading Part 2. Global Ambient Light There are at least 8 OpenGL lights and 1 Global Ambient Setting the Global Ambient globalAmbient[] =
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Computer Graphics Lecture 25 Fasih ur Rehman. Last Class Shading.
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics: Illumination
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
Computer Graphics (fall,2010) School of Computer Science University of Seoul Minho Kim.
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
Unit-7 Lighting and Shading
School of Computer Science
CSC461: Lecture 23 Shading Computation
Lighting.
CSE 470 Introduction to Computer Graphics Arizona State University
Fundamentals of Computer Graphics Part 6 Shading
Lighting – Light Sources
Lighting – Material Properties
Isaac Gang University of Mary Hardin-Baylor
Chapter IX Lighting.
Illumination and Shading
Computer Graphics Material Colours and Lighting
Computer Graphics (Fall 2003)
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
CS 480/680 Computer Graphics Shading.
Presentation transcript:

Lighting Calculations Lecture 27 Wed, Oct 31, 2007

Types of Light Source Ambient Point Source Directional Source No position in space. Illuminates objects equally from all directions. Point Source At a point in space. Equal intensity in all directions. Directional Source Source is “at infinity.” Has direction only.

Types of Light Source Ambient Point Source Directional Source

Example – The Light Source Suppose General ambient light is (0.2, 0.2, 0.2). Light source 0 properties are Ambient light is (0.3, 0.3, 0.3). Diffuse light is (0.8, 0.8, 0.8). Specular light is (1.0, 1.0, 1.0). The light’s position is L = (10, 10, 0).

Example – The Material Suppose Material properties are Ambient reflection is (0.6, 0.4, 0.2). Diffuse reflection is (0.6, 0.4, 0.2). Specular reflection is (1.0, 1.0, 1.0). Shininess is 128. The object is brown: The position is P = (0, 5, 10). The surface normal is n = (0.8, 0.6, 0.0).

Example – The Viewer Suppose The viewer is located at V = (5, 10, 15).

Computing Ambient Reflection The ambient reflection depends on The ambient light inherent in the scene. 0  sa  1. The ambient light from the light source. 0  La  1. The ambient property of the surface. 0  ma  1. The ambient reflection is computed as ra = sama + Lama

Example In the example, sa = 0.2, La = 0.3, and ma = (0.6, 0.4, 0.2). The ambient reflection is sama + Lama = (0.3, 0.2, 0.1).

Point and Directional Sources At each point of a surface, the light from a light source has a direction. Point source – direction varies with position on surface. Directional source – direction does not vary with position on surface. With a point source, the intensity may also depend on distance from the source if we enable attenuation.

Diffuse Relection Intensity of reflected diffuse light Depends on angle of incidence. Reflects equal in all directions. Therefore, it does not depend on the viewer’s location.

Computing Diffuse Reflection Let P be a point on the surface. We need to know two geometric facts. Location of light source. Vector s from P to the light source. Orientation of the surface. Vector n normal to the surface.

Diffuse Reflection Light Source Eye n s v  P Surface

Lambert’s Law Diffuse reflection is equal in intensity in all directions. However, the intensity depends on the angle of the incident light. Lambert’s law says that the intensity is proportional to the cosine of the angle of incidence (as measured down from the normal).

Lambert’s Law s n s n s n s n

Angle small  cosine big Lambert’s Law s n s n Angle small  cosine big s n s n

Angle big  cosine small Lambert’s Law s n s n s n s n Angle big  cosine small

Diffuse Reflection If s and n are unit vectors, then the cosine of the angle between them is s  n. Two other factors. Intensity of the incident light. 0  Ld  1. Reflective property of the surface. 0  md  1.

Diffuse Reflection The formula for diffuse reflection is rd = Ldmd(s  n). Of course, if s  n < 0, then rd = 0. Why?

The Example – Diffuse Reflection L – P = (10, 5, -10). s = (10, 5, -10)/225 = (2/3, 1/3, -2/3). n = (0.8, 0.6, 0.0). s  n = 0.7333. Ld= (0.8, 0.8, 0.8). md= (0.6, 0.4, 0.2).

The Example – Diffuse Reflection The diffuse reflection is Ldmd(s  n) = (0.3520, 0.2347, 0.1173).

The Example – Ambient + Diffuse Ambient and diffuse reflection combined is (0.6520, 0.4347, 0.2173).

Specular Reflection The intensity of specular reflected light varies with viewing direction as well as the direction of the light source. The maximum intensity is in the “ideal” direction. Angle of reflection = angle of incidence.

Specular Reflection Specular reflection creates the appearance of “shininess.” Surfaces with a high specular reflection appear very shiny. Surfaces with a low specular reflection appear matte.

Blinn and Phong Lighting OpenGL uses the Blinn lighting model of specular reflection. However, we will first study the Phong lighting model since it seems more natural.

Phong Lighting The intensity of the reflection is a function of the angle between the viewer and the ideal direction r of reflection of light from the light source off the surface.

Phong Lighting Light Source Eye Ideal Direction n r s   v  P Surface

Phong Lighting To compute r, note that r + s equals twice the projection of s onto n. s n r 

[(s  n)/(n  n)]n = (s  n)n Phong Lighting The projection of s onto n is [(s  n)/(n  n)]n = (s  n)n Therefore, r + s = 2(s  n)n and r = -s + 2(s  n)n

Computing Specular Reflection According to the Phong lighting model, the specular reflection is proportional to the cosine of the angle between v and r, raised to the “shiny” power. This is calculated as (r  v)shiny

Computing Specular Reflection Two other factors are Intensity of the incident light. 0  Ls  1. Specular property of the surface. 0  ms  1. The formula for specular reflection is rs = Lsms(r  v)shiny

Computing Specular Reflection Of course, if s  n < 0 or if r  v < 0, then rs = 0. Why?

The Example – Specular Reflection V – P = (5, 5, 5). v = (5, 5, 5)/75 = (1, 1, 1)/3. r = -s + 2(s  n)n = (0.5067, 0.5467, 0.6667) = (38, 41, 50)/75. r  v = 0.9930.

The Example – Specular Reflection shiny = 128. Ls = 1.0. ms = 1.0. Lsms(r  v)shiny = 0.4091.

The Example – Total Reflection Ambient, diffuse, and specular combined is (1.0, 0.8438, 0.6264). Compared to the material color (0.6, 0.4, 0.2).

Blinn Lighting A slightly more efficient method is the Blinn lighting model. Let h be the halfway vector, the unit vector halfway between s and v. Then use h  n instead of r  v. rs = Lsms(h  n)shiny

Blinn Lighting Light Source Eye Halfway n h  s v P Surface

Blinn Lighting Light Source Eye Halfway n h  s v P Surface

Blinn Lighting How does h  n compare to s  v? If s, n, and v are coplanar, then the angle between h and n is half of the angle between r and v. Why is Blinn lighting more efficient? h is computed as h = (s + v)/|s + v|. This is more efficient to compute than r.

Emissive Lighting Emissive lighting is light that emitted by the surface itself. It is used for objects that are meant to glow. It is independent of all light sources and directions. Let me be the intensity of the emissive light.

Computing the Shade of a Surface The total reflection from a point is the sum of the ambient, diffuse, and specular reflections and the emissive light. sama + Lama + Ldmd(s  n) + Lsms(h  n)shiny + me

Lighting in OpenGL Since the ambient, diffuse, and specular reflections depend on light sources, there is a separate contribution for each light source. OpenGL provides up to 8 light sources. Furthermore, there is a separate color component for each type of light. Red, green, blue.

The Lighting Model The complete formula for the reflected shade (Ir, Ig, Ib) for n lights is

The Lighting Model For each color, the computed value is “clamped” to the interval [0, 1]. If the value exceeds 1, then it is set to 1.

Gouraud Shading Gouraud shading computes the specular reflection only at the vertices and then interpolates. This guarantees that the brightest reflection will be at a vertex (or along an edge). Why?

Gouraud Shading dim dim interpolated dim reflection reflection surface

Gouraud Shading dim dim interpolated dim reflection reflection computed shades

Gouraud Shading dim dim interpolated dim reflection reflection interpolated shades

Phong Shading Phong shading interpolates (and normalizes) the normal vectors and then uses them to compute the specular reflection at each vertex. Phong shading is much more realistic. much less efficient.

Phong Shading bright reflection dim dim reflection reflection interpolated vectors

Phong Shading bright reflection dim dim reflection reflection computed shades

Phong Shading bright reflection dim dim reflection reflection computed shades