Specular Reflection. Lecture 19. Robb T. Koether. Hampden-Sydney College. Wed, Oct 4, 2017

Similar documents
The Critical-Path Algorithm

Ambient and Diffuse Light

The Projection Matrix

The Graphics Pipeline

The Mesh Class. Lecture 23. Robb T. Koether. Hampden-Sydney College. Wed, Oct 18, 2017

Minimal Spanning Trees

The Graphics Pipeline

The Projection Matrix

Illumination & Shading

Stack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017

Recursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. Hampden-Sydney College. Wed, Feb 27, 2013

Rotations and Translations

Recursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. Hampden-Sydney College. Wed, Feb 26, 2014

Comp 410/510 Computer Graphics. Spring Shading

Density Curves Sections

Street-Routing Problems

The Decreasing-Time Algorithm

while Loops Lecture 13 Sections Robb T. Koether Wed, Sep 26, 2018 Hampden-Sydney College

The Pairwise-Comparison Method

Sampling Distribution Examples Sections 15.4, 15.5

Shading I Computer Graphics I, Fall 2008

The Traveling Salesman Problem Brute Force Method

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011

The View Frustum. Lecture 9 Sections 2.6, 5.1, 5.2. Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2011

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

Lecture 15: Shading-I. CITS3003 Graphics & Animation

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

Applying Textures. Lecture 27. Robb T. Koether. Hampden-Sydney College. Fri, Nov 3, 2017

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

Scope and Parameter Passing

Solving Recursive Sequences by Iteration

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

CS452/552; EE465/505. Lighting & Shading

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

Shading II. CITS3003 Graphics & Animation

Recursive Descent Parsers

CS452/552; EE465/505. Intro to Lighting

The Class Construct Part 1

The Traveling Salesman Problem Nearest-Neighbor Algorithm

The string Class. Lecture 21 Sections 2.9, 3.9, Robb T. Koether. Wed, Oct 17, Hampden-Sydney College

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

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

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

Displaying Distributions - Quantitative Variables

Scheduling and Digraphs

Scope and Parameter Passing

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

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

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Computer Graphics MTAT Raimond Tunnel

Shading Triangles. Lecture 37. Robb T. Koether. Hampden-Sydney College. Mon, Nov 30, 2015

CS5620 Intro to Computer Graphics

Illumination Models & Shading

Boxplots. Lecture 17 Section Robb T. Koether. Hampden-Sydney College. Wed, Feb 10, 2010

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

Boolean Expressions. Lecture 31 Sections 6.6, 6.7. Robb T. Koether. Hampden-Sydney College. Wed, Apr 8, 2015

XPath Lecture 34. Robb T. Koether. Hampden-Sydney College. Wed, Apr 11, 2012

Illumination in Computer Graphics

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

The Normal Distribution

Pointers. Lecture 1 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 14, 2015

CS230 : Computer Graphics Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

The Mesh Class. Lecture 26. Robb T. Koether. Wed, Oct 28, Hampden-Sydney College

LR Parsing - Conflicts

Pointer Arithmetic. Lecture 4 Chapter 10. Robb T. Koether. Hampden-Sydney College. Wed, Jan 25, 2017

Total Orders. Lecture 41 Section 8.5. Robb T. Koether. Hampden-Sydney College. Mon, Apr 8, 2013

CPSC 314 LIGHTING AND SHADING

The Coefficient of Determination

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

Visualisatie BMT. Rendering. Arjan Kok

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

The Model Stack. Lecture 8. Robb T. Koether. Hampden-Sydney College. Wed, Sep 6, 2017

Function Definition Syntax Tree

Lab 9 - Metal and Glass

Introduction to Databases

Binary Tree Applications

The Traveling Salesman Problem Cheapest-Link Algorithm

Mipmaps. Lecture 35. Robb T. Koether. Hampden-Sydney College. Wed, Nov 18, 2015

The CYK Parsing Algorithm

Linked Lists. Lecture 16 Sections Robb T. Koether. Hampden-Sydney College. Wed, Feb 22, 2017

Magnification and Minification

Why we need shading?

Abstract Data Types. Lecture 23 Section 7.1. Robb T. Koether. Hampden-Sydney College. Wed, Oct 24, 2012

CS770/870 Spring 2017 Color and Shading

Implementing Linked Lists

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

Building the Abstract Syntax Trees

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

Computer Graphics Coursework 1

XML Attributes. Lecture 33. Robb T. Koether. Hampden-Sydney College. Wed, Apr 25, 2018

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

Regular Expressions. Lecture 10 Sections Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2016

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

CSE 681 Illumination and Phong Shading

XPath. Lecture 36. Robb T. Koether. Wed, Apr 16, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) XPath Wed, Apr 16, / 28

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

CS 4600 Fall Utah School of Computing

Shading II. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

INF3320 Computer Graphics and Discrete Geometry

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

Transcription:

Specular Reflection Lecture 19 Robb T. Koether Hampden-Sydney College Wed, Oct 4, 2017 Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 1 / 22

Outline 1 Specular Reflection 2 The Specular Calculations The Phong Lighting Model The Blinn Lighting Model 3 Assignment Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 2 / 22

Outline 1 Specular Reflection 2 The Specular Calculations The Phong Lighting Model The Blinn Lighting Model 3 Assignment Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 3 / 22

Specular Reflection Specular reflection is different. The specular reflection represents the shininess of the surface. Thus, the color of the specular reflection is typically the color of the light source (which is usually white). Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 4 / 22

Specular Reflection Specular Reflection vec3 specular(1.0f, 1.0f, 1.0f); GLuint spec_loc = glgetuniformlocation(program, "specular"); gluniform3fv(spec_loc, 1, specular); GLfloat shiny = 20.0f; GLuint shiny_loc = glgetuniformlocation(program, "shiny"); gluniform1f(shiny_loc, 1, shiny); We pass the specular light and the shininess as uniform variables the shaders. Note that shiny is a float, not a vec3. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 5 / 22

Outline 1 Specular Reflection 2 The Specular Calculations The Phong Lighting Model The Blinn Lighting Model 3 Assignment Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 6 / 22

Specular Reflection Specular reflections takes into account The specular light (intensity of reflection) The shininess of the material (narrowness of reflection) Orientation of the surface (normal vector N) Direction of the light source (light vector L) Direction of the viewer (view vector V) Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 7 / 22

Outline 1 Specular Reflection 2 The Specular Calculations The Phong Lighting Model The Blinn Lighting Model 3 Assignment Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 8 / 22

Blinn and Phong Lighting There are two standard lighting models for specular reflection. Phong lighting model Blinn lighting model The Phong model is more intuitive, but the Blinn model is more efficient. The results are very similar, but not identical. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 9 / 22

Phong Lighting Model In the Phong model, the intensity of the reflection is a function of the angle between direction V to the viewer and the ideal direction R of reflection from the light source off the surface. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 10 / 22

Phong Lighting Model Light Source L N Ideal Reflection R Viewer θ θ ϕ V P Surface Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 11 / 22

Phong Lighting Model To compute R, note that R + L equals twice the projection of L onto N. R L N L θ θ R Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 12 / 22

Phong Lighting Model The projection of L onto N is ( ) L N N = (L N)N. N N Therefore, so R + L = 2(L N)N R = L + 2(L N)N. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 13 / 22

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 α power, where α is a positive number. This is calculated as (cos ϕ) α = (R V) α. The larger α, the narrower the cone of reflection. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 14 / 22

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 α power, where α is a positive number. This is calculated as (cos ϕ) α = (R V) α. The larger α, the narrower the cone of reflection. α is called the shininess. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 14 / 22

Computing Specular Reflection Two other factors are Intensity of the incident light spec. Material specular property of the surface mat_spec. Therefore, the formula for specular reflection is spec_refl = specular max((r V), 0) α. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 15 / 22

Outline 1 Specular Reflection 2 The Specular Calculations The Phong Lighting Model The Blinn Lighting Model 3 Assignment Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 16 / 22

Blinn Lighting Model The Blinn model is more efficient. Let H be the halfway vector, which is the unit vector halfway between L and V. Then use H N instead of R V. spec_refl = specular max((h N), 0) α. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 17 / 22

Blinn Lighting Model Light Source L N ζ H R Eye ω ω ϕ V P Surface Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 18 / 22

Blinn Lighting Model H is computed as H = L + V L + V. How does H N compare to L V? If L, N, and V are coplanar, then the angle between H and N is half of the angle between R and V. Pretty much the same results can be obtained by adjusting α. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 19 / 22

Blinn Lighting Model Why is Blinn lighting more efficient? The calculation of H uses L and V, but not N. Therefore, if the light source is directional and the viewer is at infinity, then the halfway vector may be computed only once for the entire scene, not once for every vertex. The halfway vector would be passed as a uniform variable. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 20 / 22

Blinn Lighting Model Why is Blinn lighting more efficient? The calculation of H uses L and V, but not N. Therefore, if the light source is directional and the viewer is at infinity, then the halfway vector may be computed only once for the entire scene, not once for every vertex. The halfway vector would be passed as a uniform variable. In other situations, the two methods are about equally efficient. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 20 / 22

Outline 1 Specular Reflection 2 The Specular Calculations The Phong Lighting Model The Blinn Lighting Model 3 Assignment Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 21 / 22

Assignment Assignment Assignment 16. Read pp. 376-387: Fragment Shaders for Different Light Styles. Read pp. 387-390: Moving Calculations to the Vertex Shader. Robb T. Koether (Hampden-Sydney College) Specular Reflection Wed, Oct 4, 2017 22 / 22