Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 480/680 Computer Graphics Shading.

Similar presentations


Presentation on theme: "CS 480/680 Computer Graphics Shading."— Presentation transcript:

1 CS 480/680 Computer Graphics Shading

2 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.

3 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.

4 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

5 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

6 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.

7 Scattering Light strikes A Some of scattered light strikes B
Some scattered Some absorbed Some of scattered light strikes B Some of this scattered light strikes A and so on

8 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

9 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

10 Light and Matter To get an overview of the process, we can start following rays of light from a point-light-source

11 Global Effects shadow multiple reflection translucent surface

12 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

13 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

14 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.

15 Light Sources General light sources are difficult to work with because we must integrate light coming from all points on the source

16 Simple Light Sources Point source Spotlight Ambient light
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

17 Light and Matter The interaction between light and materials can be classified into three groups (a) specular (b) diffuse (c) translucent

18 Light and Matter Specular Surfaces Diffuse 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

19 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 we 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.

20 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.

21 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.

22 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.

23 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

24 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

25 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 f As we will see throughout lighting, cosines are convenient functions for lighting calculations.

26 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

27 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

28 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.

29 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

30 Ideal Reflector Normal is determined by local orientation
Angle of incidence = angle of relection The three vectors must be coplanar r = 2 (l · n ) n - l

31 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 qi cos qi = l · n if vectors normalized There are also three coefficients, kr, kb, kg that show how much of each color component is reflected

32 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

33 Modeling Specular Relections
Phong proposed using a term that dropped off as the angle between the viewer and the ideal reflection increased the angle f is the angle between r and the reflector v Ir ~ ks I cosaf shininess coef reflected intensity incoming intensity absorption coef

34 The Shininess Coefficient
Values of a between 100 and 200 correspond to metals Values between 5 and 10 give surface that look like plastic cosa f -90 f 90

35


Download ppt "CS 480/680 Computer Graphics Shading."

Similar presentations


Ads by Google