Light Sources. Spotlight model

Similar documents
Shading and Illumination

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

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

INF3320 Computer Graphics and Discrete Geometry

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

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

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

Why we need shading?

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

Lighting. CSC 7443: Scientific Information Visualization

LIGHTING AND SHADING

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

CEng 477 Introduction to Computer Graphics Fall

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

Illumination and Shading ECE 567

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

Shading. Brian Curless CSE 457 Spring 2015

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Shading. CSE 457 Winter 2015

Illumination Models & Shading

Lighting/Shading III. Week 7, Wed Mar 3

Virtual Reality for Human Computer Interaction

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

Illumination and Shading

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Illumination & Shading: Part 1

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

CS5620 Intro to Computer Graphics

Illumination and Shading

Sung-Eui Yoon ( 윤성의 )

OpenGL Lighting Computer Graphics Spring Frank Palermo

CS Surface Rendering

Shading , Fall 2004 Nancy Pollard Mark Tomczak

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

Graphics and Visualization

Light Transport Baoquan Chen 2017

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

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

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

Computer Graphics. Illumination and Shading

Lecture 4 Advanced Computer Graphics (CS & SE )

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

Surface Rendering Methods

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

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

Interpolation using scanline algorithm

CS 148, Summer 2012 Introduction to Computer Graphics and Imaging

Illumination and Shading

Lights, Colour and Materials In OpenGL

CPSC 314 LIGHTING AND SHADING

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

Ligh%ng and Shading. Ligh%ng and Shading. q Is this a plate or a ball? q What color should I set for each pixel?

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

w Foley, Section16.1 Reading

Projections and Hardware Rendering. Brian Curless CSE 557 Fall 2014

Illumination & Shading

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Comp 410/510 Computer Graphics. Spring Shading

Shading. Brian Curless CSE 557 Autumn 2017

Virtual Reality for Human Computer Interaction

Lighting/Shading II. Week 7, Mon Mar 1

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

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

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

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

Shading I Computer Graphics I, Fall 2008

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

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

5.2 Shading in OpenGL

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

Shading. Brian Curless CSE 457 Spring 2017

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

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

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

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

Display Issues Week 5

Illumination & Shading

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

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

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

Chapter 7 - Light, Materials, Appearance

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

CS 5625 Lec 2: Shading Models

Introduction to Computer Graphics 7. Shading

Realtime 3D Computer Graphics & Virtual Reality. Shading and Color. Introduction to Lighting and Shading

CSCI 4620/8626. Computer Graphics Illumination Models and Surface Rendering Methods (Chapter 17)

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

CS 4600 Fall Utah School of Computing

Shading 1: basics Christian Miller CS Fall 2011

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

Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 557 Fall Required: Shirley, Chapter 10

The Rasterization Pipeline

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

Computer Graphics. Illumination and Shading

Illumination and Shading

Illumination. Illumination CMSC 435/634

Lighting. Figure 10.1

Transcription:

lecture 12 Light Sources sunlight (parallel) Sunny day model : "point source at infinity" - lighting - materials: diffuse, specular, ambient spotlight - shading: Flat vs. Gouraud vs Phong light bulb ambient Light reaching a unit area patch is proportional to Spotlight model Spotlight model Why are the poles of the earth cold and the equator hot? other examples: lamp, ceiling light, window,... Properties of a spotlight: - 3D position - peak direction - spread (light bulb vs. laser beam) - falloff in strength with distance The illumination depends on the spread of the spotlight's beam. We can model this effect as: illumination at x ~ The illumination at x depends on direction of the spotlight and on the spread of the spotlight's beam (conceptually, the cone width).

Putting it all together... let l(x) be the effective light source vector at x that is due to the spotlight. How should the illumination at x depend on distance? Model the illumination from spotlight to be proportional to: Special case: (non-directional) point light e.g. candle flame, light bulb Ambient light - lighting lecture 12 - materials: diffuse, specular, ambient Lighting + material allows us to calculate RGB. i.e. RGB(x) =? - shading: Flat vs. Gouraud vs Phong Same illumination everywhere in space. Material (Reflectance) Material (Reflectance) Diffuse / Matte / Lambertian diffuse glossy mirror diffuse glossy mirror I will discuss them in order: diffuse, mirror, glossy. Recall: light reaching a unit area patch is proportional to

Mirror (extreme opposite of diffuse) Mirror Glossy ( "specular", shiny) High school physics: angle of incidence = angle of reflection. In the next few slides, all vectors are unit length. Bright regions are called "highlights". Glossy ( "specular", shiny) Phong model ("specular") Note the conceptual similarity to the spotlight model. spotlight - spread of emitted beam glossy highlight - spread of reflected beam Highlights occur at points near points where r = V. Blinn-Phong model ("specular") -> used in OpenGL OpenGL 1.0 (somewhat arbitrarily...) OpenGL lights gllightf( light, parametername, parameter ) light : a number (you can have up to 8 lights) parametername: H is called the "half way vector" Exercise: what is the computational advantage of Blinn-Phong over Phong? GL_AMBIENT GL_DIFFUSE color of the light GL_SPECULAR GL_POSITION GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_SPOT_CUTOFF* GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION * cutoff in [0, 90] or 180 (uniform)

glenable(gl_lighting) glenable(gl_light0) diffuselight = ( 1, 1,.5, 1 ) // yellowish light specularlight = ( 1, 1,.5, 1 ) // " ambientlight = ( 1, 1,.5, 1 ) // " // The above are RGBA values // (A = alpha, we will cover it later in the course) // OpenGL allows you to use different colored light source for // ambient vs. diffuse vs. specular. // However, IMHO, this makes no sense physically! position = ( -1.5, 1.0, -4.0, 1 ) gllightfv(gl_light0, GL_AMBIENT, ambientlight) gllightfv(gl_light0, GL_DIFFUSE, diffuselight) gllightfv(gl_light0, GL_SPECULAR, specularlight) gllightfv(gl_light0, GL_POSITION, position) OpenGL Materials glmaterialfv( face, parametername, parameters ) face : GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK parametername : GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_SHININESS... A few lectures from now, we will discuss how OpenGL does mirror surfaces ("environment mapping") ambientmaterial = ( 0, 0.5, 0.5, 1 ) // middle cyan diffusematerial = ( 1, 0, 1, 1 ) // magenta specularmaterial = ( 1, 0, 0, 1 ) // red shininess = (100.0, ) // not a typo // rather, Python "tuple" notation glmaterial(gl_front, GL_AMBIENT, ambientmaterial ) glmaterial(gl_front, GL_DIFFUSE, diffusematerial ) glmaterial(gl_front, GL_SPECULAR, specularmaterial ) glmaterial(gl_front, GL_SHININESS, shininess ) Exercise: which of the above values are in the formula below? Material Modelling beyond OpenGL 1.0 BRDF (Bidirectional Reflection Distribution Function) "Measuring and modelling Anisotropic Reflection" [Ward, 1992] The above examples are for the "fixed function pipeline" only. With modern OpenGL (GLSL), you can code up whatever reflectance model and lighting model you wish. This can be part of a vertex shader or fragment shader. To fully characterize the reflection properties of a material at a point, you need 4 parameters. In a real scene, the outgoing light in each outgoing direction is the sum that is due to all incoming directions. e.g. "brushed" metal Recent models use subsurface scattering (especially for modelling wax, skin). - lighting lecture 12 - materials: diffuse, specular (Blinn-Phong), ambient - shading: flat vs Gouraud vs Phong shading surface sub-surface https://graphics.stanford.edu/papers/bssrdf/bssrdf.pdf http://www.vrayc4d.com/manual/scenes/anisotropic-brushed-metal-186

It is natural to associate a surface normal with each polygon. OpenGL allows us to explicitly define a surface normal at each vertex. glbegin(gl_quad) glend() How to choose the RGB values at each pixel? Recall lecture 6: Filling a Polygon for y = ymin to ymax { compute intersection of polygon edges with row y between adjacent pairs of edges } Linear Interpolation (LERP) Compute the RGB at the vertices using a shading model (first half of today's lecture). How do we interpolate? A vertex belongs to more than one polygon. So, in principle, we could use different surface normals when the vertex is being used to fill in different polygons. Smooth (Gouraud) Shading Flat vs. Smooth (Gouraud) Shading http://www.felixgers.de/teaching/jogl/lightalgo.html For smooth shading, we can define vertex normals to be an average of the normals of the faces that the vertex belongs to. Each vertex may have different normals in different polygons. Each vertex may have same normal in all polygons, and this normal is different than the normal of the polygons themselves. (See next slide.) Flat (MODIFIED Feb. 22: color of one vertex is used for the entire polygon ) https://www.opengl.org/sdk/docs/man2/xhtml/glshademodel.xml Smooth / Gouraud (vertex normals are averages of neighboring face normals.)

Phong shading Linearly interpolating the (RGB) intensities from the vertices is not quite right, especially for shiny surfaces. Phong observed it would be better to linearly interpolate the normals and then compute the RGB values at each pixel (using the Phong model). Phong shading If the highlight occurs in the middle of a polygon, Gouraud shading will miss it but Phong shading will find it. Shading in OpenGL 1.0 OpenGL 1.0 does not do Phong shading. It does flat shading and smooth shading. glshademodel( GL_FLAT ) // one color used for each polygon glshademodel( GL_SMOOTH ) // default // Linear interpolation from vertex colors // Smooth shading includes Gouraud shading Announcements Next Tuesday: review Exercises Next Thursday: midterm Last name A-P (Trottier 0100), Last name Q-Z (Rutherford Physics 114) A2 : posted soon (latest next week) due date (to be determined)