Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.

Slides:



Advertisements
Similar presentations
OpenGL Course Notes Chapter 5: Lighting Jim Mims, Spring 2009.
Advertisements

1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Local Reflection Model Jian Huang, CS 594, Fall 2002.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1 Computer Graphics By : Mohammed abu Lamdy ITGD3107 University of Palestine Supervision: Assistant Professor Dr. Sana’a Wafa Al-Sayegh.
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
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading III Week.
IMGD 1001: Illumination by Mark Claypool
Lighting and Shading Wen-Chieh (Steve) Lin
6.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 6 Physically Based Reflection Model.
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.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Illumination and Shading
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 affects appearance. Light Source emits photons Photons travel in a straight line When they hit an object they: bounce off in a new direction.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
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.
CS 445 / 645: Introductory Computer Graphics
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
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.
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
Shading 03/19/2003. Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Computer Graphics I, Fall 2010 Shading in OpenGL.
Lecture 9: Lighting and Shading 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271
Lecture 14 Shading models 1.Shading Constant Shading (to be implemented) Gouraud Shading Phong Shading 2.Light and shading with OpenGL 1.
David Luebke 1 10/26/2015 Lighting CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Illumination and Shading How to shade surfaces based on the position,orientation,characteristics of the surfaces and the light sources illuminating them.
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.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
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
Chris Mayer & Nic Shulver Shading Definitions Light emanating from small surfaces is called a Point light sourcee.g. the sun (not really small though!)
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
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.
Illumination and Shading Sang Il Park Sejong University.
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
Shading NOTE: Some of these slides are from Ed Angel’s presentation at SIGGRAPH February 27, 2008.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Computer Graphics Lecture 25 Fasih ur Rehman. Last Class Shading.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics: Illumination
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.
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
Illumination and Shading
Isaac Gang University of Mary Hardin-Baylor
ייצוג בעולם 3D ייצוג מצולעים (פוליגונים) צלע קודקוד צלעe0 : {v1,v2}
Computer Graphics Material Colours and Lighting
CS 480/680 Computer Graphics Shading.
Lighting Calculations
Presentation transcript:

Steve Sterley

Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission (glass)

Lighting in OpenGL Simulates absorption and reflection through 3 different types of light: Diffuse Specular Ambient

Components of Colour All colours in the spectrum can be represented through the combination of intensities of 3 distinct colours, namely:red, green, blue 1.In coming light carries information about the intensity of each of its 3 components. 2.The reflected intensity of each component is calculated individually. 3.The resulting colour of the reflected light is then the combination of the 3 reflected components. 1. Incoming light 2. Surface colour 3. Reflected light

Diffuse Light Does not originate from the source!! Originates from atoms on the surface being excited by incident radiation Therefore Light emitted in all directions (moving the camera relative to the surface and light source will not change how much the face is lit)

The amount of diffuse light emitted, does depend on orientation of surface to the light source. A surface  to light source emits the most light I d – Intensity of emitted light I s – Intensity of light source  d – diffuse reflection coefficient (for material) A surface // to light source emits no light Or… A surface at some arbitrary angle to the source emits light whose intensity is dependent on the angle

Note: I d – Intensity of emitted light I s – Intensity of light source  d – diffuse reflection coefficient (for material) Or… Its not possible to have a negative intensity!! When  > 90 or  < -90  I d = 0 We could then rewrite the formula above as follows : Note: This is not a physically accurate model: 1.True light is not composed of three components, but an entire spectrum of frequencies. 2.In reality, Light intensity is inversely proportional to the distance from the source squared.

Realistically, objects emit diffuse light from all points on their surface, which once again should fall incident on every other object in the room. Practically, OpenGL allows only eight light sources to be used. Why does OpenGL not stick to a physically accurate lighting model?

Specular Light Originates from the source, not the material!! Material colour should not influence it Causes highlights to appear on shiny surfaces Light is emitted in specific directions (moving the camera relative to the surface and light source is expected to change which portions of the face are lit)

Method used by OpenGL to simulate specular lighting Best for modeling plastic or glassy materials, not very good for metals Phong Model Perfect MirrorPhong Model Light is only reflected in the direction where i = r ir For one particular angle of incidence, light is reflected in a number of directions, but is most intense in the direction where i = r. On either side of this angle, the intensity drops off to 0. i i

ir  Phong Model The intensity varies as some complicated function of , but in the Phong Model, it is made to vary according to the following function: cos f (  ), where f should range somewhere in the region between 0 and 200. Or… r v I sp – Intensity of reflected light I s – Intensity of specular light source  d – specular reflection coefficient (for material)  - angle between viewing vector and maximum reflection vector

Or… I sp – Intensity of reflected light I s – Intensity of specular light source  d – specular reflection coefficient (for material)  - angle between viewing vector and maximum reflection vector Note: Its not possible to have a negative intensity!! When  > 90 or  < -90  I sp = 0 We could then rewrite the formula above as follows : i This diagram is a polar plot, so the length of the arrows on the right hand side, represent the reflected intensity for different camera angles relative to the normal. Note:

f The graph above, shows how the function: cos f (  ) varies with different values of f. When f = 1, the shininess of the material is low, and the specular highlight will be large. When f = 256, the shininess of the material is high (the material is almost mirror like), and the specular highlight will be small.

Reasons for Ambient Light In the real world, light reflecting off walls and other objects accounts for a lot of the light in a room. Physically, if an object were placed in a lit room, even the faces not directed towards the light would be visible. If only diffuse and specular light were applied to a scene, large areas of it would be left in darkness. (Areas where the angles between the normal to a face and the light vector were greater than 90, or less than 0 degrees) (Shadows would appear unrealistically dark)

Ambient Light Ambient light has a uniform intensity in all directions, and serves to increase the overall brightness of the environment. Too little – Shadows too harsh Too much – picture appears bland

The Overall Picture The overall light intensity used to shade each face of an object, is now simply the sum of the three different light intensities incident on that facei.e. Intensity = ++ This calculation must then be performed for each of the three light components (R, G, B) to calculate the overall colour of that face.

Application of the Model Intensity = ++ This is the very formula used by OpenGL, and its parameters are set as follows: AmbientSpecularDiffuse I a : Use glLight, set GL_AMBIENT to the desired RGBA value  a : Use glMaterial, set GL_AMBIENT to the desired RGBA value. I s : Use glLight, set GL_SPECULAR to the desired RGBA value  s : Use glMaterial, set GL_SPECULAR to the desired RGBA value. f : Use glMaterial, set GL_SHININESS to the desired floating point value. I d : Use glLight, set GL_DIFFUSE to the desired RGBA value  d : Use glMaterial, set GL_DIFFUSE to the desired RGBA value.

Shading Models There are two types of shading available in OpenGL, these are smooth, and flat shading. Flat Shading assigns a single colour to a face Flat shading is best for modeling objects with flat faces e.g. a faceted diamond Smooth shading applies a gradient of colours to a face Smooth shading is best for modeling objects with curved surfaces e.g. sphere, toroid etc.

Flat Shading Each vertex for a face has a normal. In flat shading, OpenGL chooses just one of them to calculate the lighting for that face. In order for flat shading to appear correctly, the normals should be set  to each face, and for any particular face, they should all lie // to each other. If the normals are simply estimated e.g. modeling a sphere, through subdividing an icosahedron, the lighting will not appear accurate.

Problem with Flat Shading A problem with OpenGL flat shading is that it assumes that all the normals for a surface are the same. (This is sometimes not the case) An incorrect normal could be chosen, resulting in incorrect lighting for a surface. A simple fix (which would be computationally inexpensive) would be to average all the normals for a face, and use this average to calculate the lighting Unfortunately OpenGL does not implement this.

Smooth Shading Used for objects that aren’t meant to have flat faces. In OpenGL, smooth surfaces are estimated by a large number of flat faces. Normals should now be different for each vertex of a polygon (perpendicular to the underlying surface)

Gourand Shading The type of smooth shading used by OpenGL A unique colour is calculated for each normal to a polygon The face is then coloured in through interpolation Intensity 1Intensity 2 I right Intensity 3Intensity 4 I left 40% 60% Scan Line

Phong Shading Not used by OpenGL More computationally expensive Normals are interpolated across the surface of the polygon, then the lighting is recalculated for each pixel. n1n1 n2n2 n4n4 n3n3