Understanding Computer Graphics Shading and Light Interactions
Explore the importance of shading in computer graphics to achieve realistic images by considering light-material interactions, surface properties, and viewer perspective. Discover concepts such as light scattering, reflection models, and approximations for solving shading equations.
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
CS 480/680 Computer Graphics Shading
Introduction We have learned to build three-dimensional models and to display them. However, if you render one of our models, you might be disappointed to see images that look flat. This appearance is a consequence of our unnatural assumption that each surface is lit such that it appears to the viewer in a single color. We have left out the interaction between light and the surfaces in our models So, we will begin by developing models of light sources and the most common light-material interactions.
Introduction We then will investigate how we can apply shading to a polygonal model. We then discuss how light and material properties are specified in OpenGL and can be added to our sphere approximating program.
Why we need shading Suppose we build a model of a sphere using many polygons and color it with glColor. We get something like But we want
Shading Why does the image of a real sphere look like Light-material interactions cause each point to have a different color or shade Need to consider Light sources Material properties Location of viewer Surface orientation
Light and Matter From a physical perspective, a surface can either emit light by self-emission (as a light bulb does) or reflect light from other surfaces that illuminate it.
Scattering Light strikes A Some scattered Some absorbed Some of scattered light strikes B Some scattered Some absorbed Some of this scattered light strikes A and so on
Light and Matter The equation for solving this shading (infinite scattering and absorption of light) is called the rendering equation. This cannot be solved in general, so we use approximations. Radiosity and ray-tracing are approximations to this. Rendering equation is global and includes Shadows Multiple scattering from object to object
Light and Matter Unfortunately these approximations cannot yet be used to render scenes at the rate we can pass polygons through the modeling-projection pipeline. Therefore, we will focus on a simpler rendering model This model is based upon the Phong reflection model
Light and Matter To get an overview of the process, we can start following rays of light from a point-light-source
Global Effects shadow multiple reflection translucent surface
Local vs Global Rendering Correct shading requires a global calculation involving all objects and light sources Incompatible with pipeline model which shades each polygon independently (local rendering) However, in computer graphics, especially real time graphics, we are happy if things look right Exist many techniques for approximating global effects
Light-Material Interaction Light that strikes an object is partially absorbed and partially scattered (reflected) The amount reflected determines the color and brightness of the object A surface appears red under white light because the red component of the light is reflected and the rest is absorbed The reflected light is scattered in a manner that depends on the smoothness and orientation of the surface
Light and Matter In terms of Computer graphics, we replace the viewer with the projection plane Note that most rays leaving a source do not contribute to the image and are thus of no interest to us.
Light Sources General light sources are difficult to work with because we must integrate light coming from all points on the source
Simple Light Sources Point source Model with position and color Distant source = infinite distance away (parallel) Spotlight Restrict light from ideal point source Ambient light Same amount of light everywhere in scene Can model contribution of many sources and reflecting surfaces
Light and Matter The interaction between light and materials can be classified into three groups (a) specular (b) diffuse (c) translucent
Light and Matter Specular Surfaces appear shiny because most of the light that is reflected is reflected in a narrow range of angles close to the angle of reflection. Angle of Incidence is equal to the angle of reflection. Diffuse Surfaces reflected light is scattered in all directions. Translucent Surfaces allow some light to penetrate the surface and to emerge from another location on the object. Refraction
Color Sources Not only do light sources emit different amounts of light at different frequencies, but also their directional properties can very with frequency. Consequently, a physically correct model can be complex. However, since our visual system is based upon three colors, for most applications, we can use each of the three colors to obtain what the human observer sees.
Ambient Light In some rooms, such as certain classrooms or kitchens, the lights have been designed and positioned to provide uniform illumination throughout the room. Often this is achieved with light sources that have diffusers whose purpose is to scatter light in all directions. Florescent lights have covers designed to do this.
Ambient Light Making such a model and rendering the scene with it would be a daunting task for a graphics system. Alternatively, we can look at the desired effect: to achieve a uniform light level in the room This uniform lighting is called Ambient Light.
Point Sources An ideal point source emits light equally in all directions. We can characterize a point light source by a three- component color matrix. The intensity of illumination received from a point source is proportional to the inverse square of the distance from the source to the surface.
Point Sources Scenes rendered with only point sources tend to have high contrast (objects appear either bright or dark) In the real world, it is the large size of most light sources that contributes to softer scenes. Umbra Penumbra
Spotlights spotlights are characterized by a narrow range of angles through which light is emitted. We can construct a spotlight from a point source by limiting the angles. For example, we can use a cone
More realistic spotlights are characterized by the distribution of light in the cone. Usually most of the light is concentrated at the center of the cone. The intensity is a function of the angle As we will see throughout lighting, cosines are convenient functions for lighting calculations.
Distant Light Sources Most shading calculations require the direction from the point on the surface to the light source As we move across a surface, calculating the intensity at each point, we should recompute this vector repeatedly. This is very expensive and is a significant part of the shading calculation. However, if the light source is far from the surface, the vector does not change much
Distant Light Sources In this case, we are effectively replacing a point light source with a source that illuminates objects with parallel rays of light. Graphics systems can carry out rendering calculations more efficiently for distant light sources than for near ones. OpenGL allows both
The Phong Reflection Model Although we could approach light-material interactions through physical models, we have chosen to use a model that leads to efficient computations and to be a close enough approximation to physical reality to produce good renderings under a variety of lighting conditions and material properties.
Phong Model A simple model that can be computed rapidly Has three components Diffuse Specular Ambient Uses four vectors To source To viewer Normal Perfect reflector This is determined by n and l
Ideal Reflector Normal is determined by local orientation Angle of incidence = angle of reflection The three vectors must be coplanar r = 2 (l n ) n - l
Lambertian Surface Perfectly diffuse reflector Light scattered equally in all directions Amount of light reflected is proportional to the vertical component of incoming light reflected light ~cos i cos i = l n if vectors normalized There are also three coefficients, kr, kb, kg that show how much of each color component is reflected
Specular Surfaces Most surfaces are neither ideal diffusers nor perfectly specular (ideal reflectors) Smooth surfaces show specular highlights due to incoming light being reflected in directions concentrated close to the direction of a perfect reflection specular highlight
Modeling Specular Relections Phong proposed using a term that dropped off as the angle between the viewer and the ideal reflection increased the angle is the angle between r and the reflector v Ir ~ ksI cos shininess coef incoming intensity reflected intensity absorption coef
The Shininess Coefficient Values of between 100 and 200 correspond to metals Values between 5 and 10 give surface that look like plastic cos 90 -90