Shading 03/19/2003. Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting.

Slides:



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

Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering.
Illumination Lighting and Shading CSE 470/598 Introduction to Computer Graphics Arizona State University Dianne Hansford.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
CSPC 352: Computer Graphics
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1 MAE152 Computer Graphics for Scientists and Engineers Lighting in OpenGL.
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
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading III Week.
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
1 Lecture 10 Lighting in OpenGL. 2 Sources of light GLfloat myLightPosition[] = {3.0, 6.0, 5.0, 1.0}; GLLightfv(GL_LIGHT0, GL_POSITION, myLightPosition);
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Illumination and Shading
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Color in OpenGL (Chapter 4) Presented by: Stacy C. Lovell.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
CS 445 / 645: Introductory Computer Graphics
Computer Graphics Lighting.
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.
Shading in OpenGL.
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
Shading and Illumination. OpenGL Shading Without ShadingWith Shading.
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.
Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.
OpenGL Lighting Jian-Liang Lin 2002 Hidden-Surface Removal -1 Original Code: while (1) { get_viewing_point_from_mouse_position(); glClear(GL_COLOR_BUFFER_BIT);
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
11/04/04© University of Wisconsin, CS559 Fall 2004 Last Time Visibility –Z-Buffer and transparency –A-buffer –Area subdivision –BSP Trees –Exact Cell-Portal.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
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.
Local Illumination and Shading
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
In the name of God Computer Graphics. Where We Stand So far we know how to: –Transform between spaces –Draw polygons Next –Deciding a pixel’s intensity.
Lighting Dave Shreiner. 2 Lighting Principles Lighting simulates how objects reflect light Lighting simulates how objects reflect light material composition.
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.
Shading NOTE: Some of these slides are from Ed Angel’s presentation at SIGGRAPH February 27, 2008.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
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.
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
1 Dr. Scott Schaefer Lighting. 2/49 Lighting/Illumination Color is a function of how light reflects from surfaces to the eye Global illumination accounts.
Graphics Graphics Korea University kucg.korea.ac.kr 1 Lights & Material 고려대학교 컴퓨터 그래픽스 연구실.
CSC Graphics Programming
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
Shading in OpenGL Ed Angel
Lighting Phong's Lighting Model normals
Illumination and Shading
Lighting and Materials
CS5500 Computer Graphics April 10, 2006.
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Computer Graphics Material Colours and Lighting
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
CS 480/680 Computer Graphics Shading.
Presentation transcript:

Shading 03/19/2003

Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting settings OpenGL uses an additive color model Phong lighting model

Lighting Principles Light that is directly reflected off the surface creates a specular highlight Light that is absorbed into the material before it is reflected creates the color we see. (Diffuse color) Material's appearance is the result of a combination of several light and material properties

Surface Normals Color determined by several factors –Surface normal and color –Light position –Eye position N

Specifying Material Properties glMaterialfv( face, property, value ); Material properties –GL_EMISSION –GL_AMBIENT –GL_DIFFUSE –GL_SPECULAR –GL_SHININESS Primitives have material properties for front and back sides

Setting Material Properties GLfloat green[] = { 0.0, 1.0, 0.0, 1.0 }; GLfloat red[] = { 1.0, 0.0, 0.0, 1.0 }; GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green ); glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, red ); glMaterialfv( GL_FRONT, GL_SPECULAR, white ); glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, );

Determining Vertex Color vertex color = the material emission at that vertex + the global ambient light scaled by the material's ambient property at that vertex + the ambient, diffuse, and specular contributions from all the light sources, properly attenuated

Material Properties

Ambient Reflection of Material Ambient reflectance affects the overall color of the object. –Diffuse reflectance is brightest where an object is directly illuminated. –Ambient reflectance is most noticeable where an object receives no direct illumination. An object's total ambient reflectance is affected by the global ambient light and ambient light from individual light sources. Like diffuse reflectance, ambient reflectance isn't affected by the position of the viewpoint.

Lighted, smooth-shaded teapots drawn with different material properties that approximate real materials. The first column has materials that resemble (from top to bottom) emerald, jade, obsidian, pearl, ruby, and turquoise. The second column resembles brass, bronze, chrome, copper, gold, and silver. The third column represents various colors of plastic: black, cyan, green, red, white, and yellow. The fourth column is drawn with similar colors of rubber.

Specular Reflectance If gray, the highlight is the color of the light If non gray, the highlight is a combination of the light and the specular color Characteristics of specular highlight set with shininess exponent ( ) –High value - concentrated specular reflection –Low value - larger less concentrated (more diffuse) specular reflection

Specular Reflectance Specular reflection from an object produces highlights. The amount of specular reflection seen by a viewer does depend on the location of the viewpoint –It's brightest along the direct angle of reflection.

Diffuse Reflectance Plays the most important role in determining what you perceive the color of an object to be. Affected by the color of the incident diffuse light and the angle of the incident light relative to the normal direction. (It's most intense where the incident light falls perpendicular to the surface.) Position of the viewpoint doesn't affect diffuse reflectance at all.

Ambient Reflectance Affects the overall color of the object. Diffuse reflectance is brightest where an object is directly illuminated, ambient reflectance is most noticeable where an object receives no direct illumination. Object’s total ambient reflectance is affected by the global ambient light and ambient light from individual light sources. Diffuse reflectance, ambient reflectance isn't affected by the position of the viewpoint.

Emissive Reflectance Make an object appear to be giving off light of that color. Most real-world objects (except lights) don't emit light, you'll probably use this feature mostly to simulate lamps and other light sources in a scene. Give appearance of slightly glowing. –They're not actually acting as light sources. –Create a light source and position it at the same location as the sphere to create that effect.

Twelve spheres, each with different material parameters. The row properties are as follows: row 1 - No ambient reflection row 2 - Grey ambient reflection row 3 - Blue ambient reflection. Column 1 - uses a blue diffuse material color with no specular properties Column 2 - The second column adds white specular reflection with a low shininess exponent Column 3 - The third column uses a high shininess exponent and thus has a more concentrated highlight. Column 4 - The fourth column uses the blue diffuse color and, instead of specular reflection, adds an emissive component.

Light Sources glLightfv( light, property, value ); –light specifies which light –multiple lights, starting with GL_LIGHT0 Infinite and local lights Local lights can also be spot lights ( the local light will shine in a direction and its light will be limited to a cone centered around that direction vector. –GL_SPOT_DIRECTION –GL_SPOT_CUTOFF –GL_SPOT_EXPONENT

Light in OpenGL Ambient Light Emitted Light Diffuse Light Specular Light

Global Ambient Light Uniform light level Light has been scattered so much that you can't tell where it comes from Appears to come from all directions Constant throughout the scene A kludge Ambient light is scattered equally in all directions after hitting an object

Emitted Light The simplest light. It originates from an object and is unaffected by any light sources.

Diffuse Light Comes from one direction So it's brighter if it comes squarely down on a surface than if it barely glances off the surface After hitting a surface, it's scattered equally in all directions, so it appears equally bright, no matter where the eye is located Any light coming from a particular position or direction probably has a diffuse component.

Specular Light Comes from a particular direction Bounces off the surface in a preferred direction A well-collimated laser beam bouncing off a high-quality mirror produces almost 100 percent specular reflection specularity as shininess.

Specifying Light Sources in OpenGL Light sources have a number of properties, such as color, position, and direction. void glLight{if}[v](GLenum light, GLenum pname, TYPEparam); Creates the light specified by light, which can be GL_LIGHT0, GL_LIGHT1,..., or GL_LIGHT7. The characteristic of the light being set is defined by pname

Position Directional light source –Located infinitely far away from the scene –Rays of light can be considered parallel by the time they reach an object –Sun Positional light source –Located near to the scene –The direction from which the light rays come –Desk lamp

Objects drawn with gray material parameters and colored light sources. (left) An infinite light source is used; (right) A local light source is used. With the infinite light source, the highlight (specular reflection) is centered on both the cone and the sphere because the angle between the object and the line of sight is ignored. With a local light source, the angle is taken into account, so the highlights are located appropriately on both objects.

Attenuation For real-world lights –the intensity of light decreases as distance from the light increases OpenGL attenuates a light source by multiplying the contribution of that source by an attenuation factor:

Light Sources Light color properties –GL_AMBIENT –GL_DIFFUSE –GL_SPECULAR Light attenuation –GL_CONSTANT_ATTENUATION –GL_LINEAR_ATTENUATION –GL_QUADRATIC_ATTENUATION

Lighting Example GLfloat white[] = { 1, 1, 1, 0 }; GLfloat magenta[] = { 0.8, 0, 0.8, 0 }; GLfloat pos[] = { 2.5, 6, 3.5, 1.0 }; glLightfv( GL_LIGHT0, GL_AMBIENT_AND_DIFFUSE, magenta ); glLightfv( GL_LIGHT0,GL_SPECULAR,white); glLightfv( GL_LIGHT0, GL_POSITION, pos ); glEnable( GL_LIGHT0 ); glEnable( GL_LIGHTING );

Enabling Lighting Turn on lighting calculations –glEnable( GL_LIGHTING ); Turn on each light –glEnable( GL_LIGHTn );

Polygon Rendering Shading calculations require a tremendous amount of processing. Based on polygon normals or vertex normals and pixel color.

Wireframe Shows underlying structure No surfaces are visible No shading necessary

Flat Polygon is shaded with a single color. Same geometric polygon normal used for each vertex. If polygon normal points toward a light, the surface is illuminated

Faceted Polygon normal is the same for all vertices. If polygon normal points toward a light, the surface is illuminated

Smooth Render Style Uses vertex normals Colors are calculated for vertices Colors are interpolated between the vertices for edge colors Colors are interpolated across rendered scan lines

Gouraud Shading May be done in hardware Uses vertex normals Interpolated vertex normals to calculate light at every pixel

Phong Shading Calculates surface normals at vertices Interpolates surface normals between vertices Calculates color of surface

Phong Shading Almost always done off line Better quality than Gouraud Increased rendering time

Lighting Principles Review Light that is directly reflected off the surface creates a specular highlight Light that is absorbed into the material before it is reflected creates the color we see. (Diffuse color) Material's appearance is the result of a combination of several light and material properties

Rendering Process of producing a two dimensional image from 3D model Rendering Approaches –LOCAL Gouraud Shading Phong Shading –GLOBAL Ray Tracing Radiosity

Local Illumination Local –Contribution from the light that goes directly from the light source and is reflected from the surface –Shading of any surface is independent from the shading of all other surfaces

Global Illumination Contribution from the light that goes directly from the light source and is reflected from the surface Contribution from the light that is reflected from other surfaces to the current surface

Local Illumination Algorithms Scan line rendering Wireframe Faceted or flat shading Gouraud shading Phong shading

Photorealism Vs Lighting Visualization Photorealism –Mimic reality but not physically real (ambient light) –Look real –Approximate interplay of lighting Lighting visualization –Used when lighting must match real world –Calculates scene lighting from reality –Distinguishes between natural and electric lights

Gouraud Uses vertex normals Colors are calculated for vertices Colors are interpolated between the polygon edges May be done in hardware

Phong Shading Uses vertex normals Interpolated vertex normals to calculate light at every pixel Almost always done off line

Ray Tracing Ray tracing involves following paths or trees of line segments through the scene to compute the effects of typical light paths.

Ray Tracing Advantages Shadows Shiny objects Arbitrary geometry types, anything that you can intersect with a ray

Ray Tracing Disadvantages No distance fall-off of light Sharp shadows, Sharp specular reflections

Radiosity The rate at which energy leaves a surface Energy per time per unit area "radiosity equation" describes the amount of energy which can be emitted from a surface, as the sum of the energy inherent in the surface (a light source, for example) and the energy which strikes the surface, being emitted from some other surface.

Radiosity