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

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

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

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

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

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

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

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

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

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

Pipeline Operations. CS 4620 Lecture 14

Light Sources. Spotlight model

Shading and Illumination

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

Computer Graphics. Illumination and Shading

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

CEng 477 Introduction to Computer Graphics Fall

Illumination & Shading: Part 1

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

Computer Graphics. Illumination and Shading

Comp 410/510 Computer Graphics. Spring Shading

CPSC / Illumination and Shading

Pipeline Operations. CS 4620 Lecture 10

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

CSE 167: Lecture #7: Color and Shading. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Introduction to Computer Graphics 7. Shading

Shading. Brian Curless CSE 457 Spring 2017

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

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

Shading I Computer Graphics I, Fall 2008

LIGHTING AND SHADING

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

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

Illumination Models & Shading

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

CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

CS5620 Intro to Computer Graphics

Illumination and Shading

Virtual Reality for Human Computer Interaction

Exercise Max. Points Total 90

Deferred Rendering Due: Wednesday November 15 at 10pm

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

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

Lecture 15: Shading-I. CITS3003 Graphics & Animation

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

CS 4600 Fall Utah School of Computing

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

The Rasterization Pipeline

CSE 167: Introduction to Computer Graphics Lecture #11: Visibility Culling

CSE 167: Lecture 11: Textures 2. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

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

INF3320 Computer Graphics and Discrete Geometry

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

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

Illumination and Shading

Visualisatie BMT. Rendering. Arjan Kok

Shading 1: basics Christian Miller CS Fall 2011

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

Sung-Eui Yoon ( 윤성의 )

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

CS 354R: Computer Game Technology

CS 130 Final. Fall 2015

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Shading. Brian Curless CSE 457 Spring 2015

CS451Real-time Rendering Pipeline

Chapter 7 - Light, Materials, Appearance

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

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

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

CS 325 Computer Graphics

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

Computer Graphics I Lecture 11

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

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Shading. CSE 457 Winter 2015

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Graphics Hardware and Display Devices

Rasterization Overview

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

CHAPTER 1 Graphics Systems and Models 3

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

Projections and Hardware Rendering. Brian Curless CSE 557 Fall 2014

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

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

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Virtual Reality for Human Computer Interaction

CSE 167: Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

Complex Shading Algorithms

Illumination & Shading

CPSC 314 LIGHTING AND SHADING

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

Lecture 2. Shaders, GLSL and GPGPU

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

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

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

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

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

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

Transcription:

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

Announcements Thursday in-class: Midterm Can include material up to and including today s lecture Project 3 late grading deadline this Friday Grading starts at 12:30pm, ends at 1:30pm 2

Lecture Overview OpenGL Light Sources Directional Lights Point Lights Spot Lights 3

Light Sources Real light sources can have complex properties Geometric area over which light is produced Anisotropy (directionally dependent) Reflective surfaces act as light sources (indirect light) OpenGL uses a drastically simplified model to allow real-time rendering 4

OpenGL Light Sources At each point on surfaces we need to know Direction of incoming light (the L vector) Intensity of incoming light (the c l values) Standard light sources in OpenGL Directional: from a specific direction Point light source: from a specific point Spotlight: from a specific point with intensity that depends on direction 5

Lecture Overview OpenGL Light Sources Directional Lights Point Lights Spot Lights 6

Directional Light Light from a distant source Light rays are parallel Direction and intensity are the same everywhere As if the source were infinitely far away Good approximation of sunlight Specified by a unit length direction vector, and a color 7 Light source Receiving surface

Lecture Overview OpenGL Light Sources Directional Lights Point Lights Spot Lights 8

Point Lights Similar to light bulbs Infinitely small point radiates light equally in all directions Light vector varies across receiving surface What is light intensity over distance proportional to? Intensity drops off proportionally to the inverse square of the distance from the light Reason for inverse square falloff: Surface area A of sphere: A = 4 π r 2 9

Point Lights in Theory p c src Light source At any point v on the surface: c l v c l Receiving surface v 10

Point Lights in OpenGL OpenGL model for distance attenuation: Attenuation parameters: k c = constant attenuation, default: 1 k l = linear attenuation, default: 0 k q = quadratic attenuation, default: 0 Default: no attenuation: c l =c src Change attenuation parameters with: GL_CONSTANT_ATTENUATION 11 c l = GL_LINEAR_ATTENUATION c src k c + k l p v + k q p v 2 GL_QUADRATIC_ATTENUATION

Lecture Overview OpenGL Light Sources Directional Lights Point Lights Spot Lights 12

Spotlights Like point source, but intensity depends on direction Parameters Position: location of light source Spot direction: center axis of light source Falloff parameters: Beam width (cone angle) The way the light tapers off at the edges of the beam (cosine exponent) 13

Spotlights Light source Receiving surface 14

Spotlights Photograph of real spotlight Spotlights in OpenGL 15

Video C++ OpenGL Lesson on Basic Lighting http://www.youtube.com/watch?v=g_0yv7jzvgg 16

Lecture Overview Types of Geometry Shading Shading in OpenGL Fixed-Function Shading Programmable Shaders Vertex Programs Fragment Programs GLSL 17

Types of Shading Per-triangle Per-vertex Per-pixel 18

Per-Triangle Shading A.k.a. flat shading Evaluate shading once per triangle Advantage Fast Disadvantage Faceted appearance 19

Per-Vertex Shading Known as Gouraud shading (Henri Gouraud, 1971) Interpolates vertex colors across triangles Advantages Fast Smoother surface appearance than with flat shading Disadvantage Problems with small highlights 20

Per-Pixel Shading A.k.a. Phong Interpolation (not to be confused with Phong Illumination Model) Rasterizer interpolates normals (instead of colors) across triangles Illumination model is evaluated at each pixel Simulates shading with normals of a curved surface Advantage Higher quality than Gouraud shading Disadvantage Slow 21 Source: Penny Rheingans, UMBC

Gouraud vs. Per-Pixel Shading Gouraud shading has problems with highlights when polygons are large More triangles improve the result, but reduce frame rate Gouraud Per-Pixel 22

Lecture Overview Types of Geometry Shading Shading in OpenGL Fixed-Function Shading Programmable Shaders Vertex Programs Fragment Programs GLSL 23

Shading with Fixed-Function Pipeline Fixed-function pipeline only allows Gouraud (pervertex) shading We need to provide a normal vector for each vertex Shading is performed in camera space Position and direction of light sources are transformed by GL_MODELVIEW matrix If light sources should be in object space: Set GL_MODELVIEW to desired object-to-camera transformation Use object space coordinates for light positions More information: http://glprogramming.com/red/chapter05.html http://www.falloutsoftware.com/tutorials/gl/gl8.htm 24

Tips for Transforming Normals If you need to (manually) transform geometry by a transformation matrix M, which includes shearing or scaling: Transforming the normals with M will not work: transformed normals are no longer perpendicular to surfaces Solution: transform the normals differently: Either transform the end points of the normal vectors separately Or transform normals with OpenGL does this automatically if the following command is used: glenable(gl_normalize) More details on-line at: http://www.oocities.com/vmelkon/transformingnormals.html 25

Lecture Overview Types of Geometry Shading Shading in OpenGL Fixed-Function Shading Programmable Shaders Vertex Programs Fragment Programs GLSL 26

Programmable Shaders in OpenGL Initially, OpenGL only had a fixed-function pipeline for shading Programmers wanted more flexibility, similar to programmable shaders in raytracing software (term shader first introduced by Pixar in 1988) First shading languages came out in 2002: Cg (C for Graphics, created by Nvidia) HLSL (High Level Shader Language, created by Microsoft) They supported: Fragment shaders: allowed per-pixel shading Vertex shaders: allowed modification of geometry 27

Programmable Shaders in OpenGL OpenGL 2.0 supported the OpenGL Shading Language (GLSL) in 2003 Geometry shaders were added in OpenGL 3.2 Tessellation shaders were added in OpenGL 4.0 Programmable shaders allow real-time: Shadows, environment mapping, per-pixel lighting, bump mapping, parallax bump mapping, HDR, etc. 28

Demo NVIDIA Froggy http://www.nvidia.com/coolstuff/demos#!/froggy Bump mapping shader for Froggy s skin Physically-based lighting model simulating sub-surface scattering Supersampling for scene anti-aliasing Raytracing shader for irises to simulate refraction for wet and shiny eyes Dynamically-generated lights and shadows 29