Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lighting and Shading (I)

Similar presentations


Presentation on theme: "Lighting and Shading (I)"— Presentation transcript:

1 Lighting and Shading (I)
姜明 北京大学数学科学学院 Based on [EA], Chapter 5. 更新时间2019年4月11日星期四6时7分19秒

2 Why Shading? What we have left out is the interaction between light and the surfaces in our graphics models. Without this interaction, we can only generate images that look flat and fail to show the 3D presentation. A real photo of a lit sphere has many gradations or shades of color, which shows an appearance of being 3D. Our aim is to add shading to a fast pipeline graphics architecture. Shading: 明暗处理,明暗模型,光照模型。

3 Outline Light and Matter Light Sources The Phong Reflection Model

4 As in all wave theories of light, the elementary process which produces the optical impression is regarded as being a harmonic wave in space-time (studied in its simplest form in [Born and Wolf, 1999,§ 1.3 and 1.4]). If its frequency is in the range from 4×1014s−1 to 7.5×1014s−1 (approximately) it gives raise to the psychological impression of a definite color. The opposite, however, is not true: colored light of a certain subjective quality may be a composition of harmonic waves of very difference frequency distributions. The actual connection between color and frequency is very involved and will not be studied here, c.f. [Born and Wolf, 1999, § 4.8.1]. Born, M. and Wolf, E. (1999). Principles of Optics. Cambridge University Press, 7th edition.

5 Light and Matter Radiosity (rendering in [EA]) equation based on conservation of light energy reflected among surfaces, [HA, Section 14.7]. This is an integral equation, which we could use to find the shading of all surfaces in a scene. Ray tracing [HA, Section 14.6]. Unfortunately, neither radiosity or ray tracing can be used to render scene at the rate at which we can pass polygons through the modeling-projection pipeline.

6 Two independent parts of the problem
We follow rays of light from light-emitting (or self-luminous) surfaces (light sources). We model what happens to these rays as they interact with reflecting surfaces in the scene. This is similar to ray tracing, but we consider only single interactions between light sources and surfaces. If a ray of light enters her eye directly from the source, she sees the color of the source. If the ray of light hits a surface that is visible to our viewer, the color she sees is based on the interaction between the source and the surface material. Two independent parts of the problem Model of light sources. Reflection model. In terms of computer graphics, we replace the viewer by the projection plane.

7 Light and Matter Interactions
Specular Surface Diffuse Translucent (半透明) Note: Any given surface can have some of all three properties.

8 Light Sources A general light source can be characterized by a six-variable illumination function. A physically “correct” model can be complex. For most applications, we use a model that leads to efficient computations, especially when we use it with the pipeline rendering architecture.

9 Several Basic light Sources
Color Sources Ambient Light Point Sources Spotlights Distant Light Sources

10 Color Sources Our model of the human visual system is based on the three-color theory. We perceive three primaries, rather than a full color distribution. For most applications, we can thus model light sources as having three components – red, green and blue – that a human observer sees. We describe a source through a three-component intensity of luminance function. Each of the components is the intensity of the independent red, green, and blue components. Color-light computation involves three similar but independent calculations. We can use a single scalar equation to represent any of the three color components.

11 Ambient Light It represents uniform illumination through the scene.
Such illumination is achieved through large sources that have diffusers whose purpose is to scatter light in all directions. It can be computed through a complicated physics model. We can postulate an ambient intensity at each point in the environment. Thus, ambient illumination is characterized by an intensity that is identical at every point in the scene.

12 Point Sources An ideal point source emits light equally in all directions. We can model a point source located at a point by a three-component color vector. The intensity of illumination received from a point source is proportional to the inverse square of the distance between the source and surface.

13 Scenes rendered with only point sources tend to have high contrast.
We can reduce (mitigate) the high-contrast effect from point source illumination by adding ambient light to a scene. Shadows created by a source of finite size. The distance term also contributes to the unpleasantly rough (harsh) rendering with point sources. The inverse-square law is replaced by another formulae.

14 Spotlights Spotlights are characterized by a narrow range of angles through which light is emitted. We can constructed a simple spotlight from a point source by limiting the angles at which light from the source can be seen – a cone. The distribution of light within the cone is a function of the angle between the direction of the source ls and the direction s from the source to a point on a surface. This function is usually defined as the exponential of the cosine.

15 Distant Light Sources If the light source is far from the surface, the direction vector from the source to each point on the surface does not change much as we move from point to point. Light from the sun, a parallel source. In OpenGL, a distant light source is described by a direction vector in homogenous coordinates.

16 The Phong Reflection Model
It is efficient, close enough to physical reality to produce good rendering under a variety of lighting conditions and material properties. It supports three types of material-light interactions – ambient, diffuse and specular.

17 Suppose we a set of point sources.
Each source can have separate ambient, diffuse, and specular components for each of the three primary colors. Although this assumption may appear unnatural, we can use it to create realistic shading effects efficiently. We use a local model to simulate effects that can be global in nature. We need 9 parameters to characterize the i-th light source. The distance-attenuation terms have not been applied.

18 The contribution from each source to a point is by adding the ambient, diffuse and specular contributions. The total intensity is by adding the contributions from all sources and, possibly, a global term. The computations are the same for each source and for each primary color.

19 Ambient Reflection The intensity of ambient light is the same at each point of the surface. Some of the light is absorbed, and some is reflected. The amount reflected is given by the ambient reflection coefficient,

20 Diffuse Reflection A perfectly diffuse Surface: Light is reflected equally in all directions. Diffuse The amount of light reflected depends on the material and on the direction of the light relative to the surface. There is no preferred angle of reflection. It appears the same to all viewers. Such surfaces, called Lambertian surfaces, can be modeled mathematically with Lambert’s law.

21 Illustration of Lambert’s law
Total light source energy=E The surface is brightest at noon and dimmest at dawn, because the same amount of light is spread over a larger area and the surface appears dimmer. Lambert’s law: we see only the vertical component of the incoming light.

22

23 Specular Reflection Surfaces will look dull with only ambient and diffuse reflections. We need the highlights reflected from shiny objects. When the surface gets smoother, the reflected light is concentrated in a smaller range of angles, centered about the angle of a perfect reflector. Smooth Surface: Light is reflected at an angle near to the incident angle. Specular

24 Phong proposed an approximate model.
For a specular surface, most light is reflected around vector r, corresponding to a reflected angle equal to the angle of incidence. If f is the angle between v and r, The exponent is a shininess coefficient. is the fraction of incoming specular light that is reflected. Large Small

25 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 f 90 -90 cosa f f 90 -90

26 Vectors Used by Phong Lighting Model
p is an arbitrary point on a surface. n is the unit normal to the surface at p. l is a unit vector in the direction of the light source. r is a unit vector in the direction of a perfectly (specular) reflection v is a unit vector in the direction of the viewer.

27 The Complete Phong Model
Specular term Diffuse term Ambient term Distance term You can try out the Lighting Applet to see the effect of Phong shading

28 Illustration of Diffuse Reflection
Patrick Min

29 Illustration of Specular Reflection
Patrick Min

30 Illustration of the Complete Phong Model
Patrick Min


Download ppt "Lighting and Shading (I)"

Similar presentations


Ads by Google