Uni 4 Graficacion
-
Upload
ernesto-a-gongora-estopier -
Category
Documents
-
view
237 -
download
0
Transcript of Uni 4 Graficacion
-
8/11/2019 Uni 4 Graficacion
1/42
GraficacinUnidad IV. Iluminacin y Sombreado
-
8/11/2019 Uni 4 Graficacion
2/42
Iluminacin y Sombreado
Projections, required for displaying a three-dimensional stwo-dimensional plane or screen.
A projection is a special type of mapping from the three-dispace to a plane.
In this sense, a projection describes only where a point orhas to be drawn on the projection plane.
-
8/11/2019 Uni 4 Graficacion
3/42
Iluminacin y Sombreado
The information where an object should be drawn on the plane, i.e., which pixels are covered by the object, is sufficient for a realistic representation of a three-dimension
Figure 8.1 shows the projections of a grey sphere and a g
both in two variants.
The first variant simply assigns the colour of the sphere anddirectly to the pixels that are occupied by the corresponding
-
8/11/2019 Uni 4 Graficacion
4/42
Iluminacin y Sombreado
This leads to geometric shapes with a homogeneous colalmost the complete information about the three-distructure. The projection of the sphere is a grey circle,becomes a grey hexagon.
-
8/11/2019 Uni 4 Graficacion
5/42
Iluminacin y Sombreado
Taking illumination and light reflections into account leads tlight effects on the surfaces of the three-dimensional objecnonhomogeneous shading of their projections.
In this way, even the flat images appear vivid and provid
dimensional impression as can be seen in figure 8.1
Shadingrefers to rendering an objectssurface with illuminlight reflection effects.
-
8/11/2019 Uni 4 Graficacion
6/42
4.1 Relleno de polgonos
-
8/11/2019 Uni 4 Graficacion
7/42
4.2 Modelos bsicos de iluminacin
-
8/11/2019 Uni 4 Graficacion
8/42
Light sources
In addition to information about the objects and the vdescription of a three-dimensional scene must alsinformation about illumination of the scene.
A single light source or a number of light sources can con
the illumination of a scene.
The colour and intensity of a light source are defined by suivalues.
-
8/11/2019 Uni 4 Graficacion
9/42
Light sources
The simplest form of light is ambient light.
Ambient light does not come from a specific light source adirection.
It represents the light that is more or less everywhere in originating from multiple reflections of light at various surfa
-
8/11/2019 Uni 4 Graficacion
10/42
Light sources
In a room with a lamp on a table, it will not be completely dthe table although the lamp cannot shed its light directly table.
The light is reflected by the surface of the table, the walls,
and the floor.
Ambient light is a simplification of the computations for illum
-
8/11/2019 Uni 4 Graficacion
11/42
Light sources
The correct way to take ambient light into account would bthe multiple reflections of the light completely. This woulthe computational effort enormously, so that this appro(yet) well suited for real-time computer graphics.
For ambient light it is sufficient to specify its colour.
A directional light source has in addition to a colour also a d
-
8/11/2019 Uni 4 Graficacion
12/42
Light sources
The light rays from a directional light source are parallel.
Directional light is used to model light coming from a sourceinfinite distance, for instance sunlight.
A lamp is modelled as a point light source. A point light soposition and the light rays spread in all directions from this p
-
8/11/2019 Uni 4 Graficacion
13/42
Light sources
The intensity of the light decreases with increasing disteffect is called attenuation.
The following argument shows that the intensity of decreases quadratically with the distance to the light source
If a point light source is in the centre of a sphere with radthe full energy of the light will be distributed equally on theof the surface of the sphere.
-
8/11/2019 Uni 4 Graficacion
14/42
Light sources
If the sphere is replaced by a bigger sphere with radius R, thenergy of the light will not change. But it is now distributed surface.
The ratio of the surfaces of the two spheres is
-
8/11/2019 Uni 4 Graficacion
15/42
Light sources
For a ratio of r/R = 1/2 each point on the inner part of the the larger sphere receives therefore only one quarter of thea point on the inner part of the surface of the smaller spher
The theoretical model for attenuation would then be to m
intensity of the light from a point light source by t1/2when it hits the surface of an object at distanced tosource.
-
8/11/2019 Uni 4 Graficacion
16/42
Light sources
The decrease of the intensity caused by attenuation is modgeneral quadratic polynomial in the denominator in the form
where the constants c1, c2, c3 can be chosen individually
point light source, d is the distance of an object to the light
This formula guarantees that the intensity can never exceed1.
-
8/11/2019 Uni 4 Graficacion
17/42
Light sources
The quadratic decrease of the light intensity comes distribution of the energy of the light onto a larger surfaincreasing distance.
In addition, part of the light is absorbed by dust particles
causing atmospheric opacity.
This leads obviously to a linear decrease of the inteincreasing distance.
-
8/11/2019 Uni 4 Graficacion
18/42
Light sources
Another common light source are spotlights (proyectores). to a point light source, a spotlight has a direction in whichits light in the form of a cone.
A spotlight is characterised by the colour of its light, its loc
direction in which it shines and an angular limit that desextension of the cone of light.
-
8/11/2019 Uni 4 Graficacion
19/42
Light sources
Attenuation is computed for a spotlight on the basis of equin the same way as for point light sources.
The quadratic decrease of the intensity with increasing disalso be deduced from figure 8.2 where it can be seen th
energy of the light from the spotlight is distributed ovewhose radius growth is linear with the distance.
Therefore, the surface grows quadratically with the distance
-
8/11/2019 Uni 4 Graficacion
20/42
Light sources
As
For a more realistic model of a spotlight, it should be account that the intensity of the light is smaller close to theof the cone of light than at the centre.
-
8/11/2019 Uni 4 Graficacion
21/42
-
8/11/2019 Uni 4 Graficacion
22/42
Light sources
Then the intensity of light at the point on the surface cominspotlight is computed in the Warn model by
I = IS fatt (cos )
[Eq. 8.2]
ISis the intensity of the spotlight,fattis the distance-dependfor attenuation as in equation (8.1) and is the angle betw
IS. The value p controls how much the spotlight is focussed.
For p = 0 the spotlight behaves in the same way as a source.
-
8/11/2019 Uni 4 Graficacion
23/42
Light sources
The larger p is chosen, the more the light concentrated aaxis of the cone and the smaller is the intensity at the bothe cone.
The cosine in equation (8.2) can be computed as the dot p
the vectors land lS
if they are normalised, i.e., if both of tthe length one.
-
8/11/2019 Uni 4 Graficacion
24/42
Light sources
The
-
8/11/2019 Uni 4 Graficacion
25/42
4.3 Tcnicas de sombreado
To make objects appear to have more volume, it can hshading, i.e., the surface is paintedwith light.
-
8/11/2019 Uni 4 Graficacion
26/42
Diffuse Shading
Many objects in the world have a surface appearancdescribed as matte, indicating that the object is not atExamples include paper and unfinished wood.
Such objects do not have a color change with a change in vi
Such matte objects can be considered as behaving as Lobjects.
-
8/11/2019 Uni 4 Graficacion
27/42
-
8/11/2019 Uni 4 Graficacion
28/42
Lambertian Shading Model
Ssdsd
-
8/11/2019 Uni 4 Graficacion
29/42
Lambertian Shading Model
Thus, the color on the surface will vary according to the coangle between the surface normal and the light direction.
Note that the vector l is typically assumed not to depelocation of the object. That assumption is equivalent to asslight is distantrelative to object size.
Such a distant light is often called a directional light, bposition is specified only by a direction.
-
8/11/2019 Uni 4 Graficacion
30/42
Lambertian Shading Model
A surface can be made lighter or darker by changing the ithe light source or the reflectance of the surface.
The diffuse reflectance cr is the fraction of light reflectsurface. This fraction will be different for different color com
For example, a surface is red if it reflects a higher fractincident light than blue incident light.
-
8/11/2019 Uni 4 Graficacion
31/42
Lambertian Shading Model
If we assume surface color is proportional to the light reflecsurface, then the diffuse reflectance cr( an RGB color ) muincluded:
The right-hand side of Equation (10.1) is an RGB color wicomponents in the range[0,1].
-
8/11/2019 Uni 4 Graficacion
32/42
Lambertian Shading Model
We would like to add the effects of light intensity while keRGB components in the range [0,1].
This suggests adding an RGB intensity term cl which components in the range [0,1]:
-
8/11/2019 Uni 4 Graficacion
33/42
Lambertian Shading Model
This is a very convenient form, but it can produce RGB co
for c that are outside the range[0,1], because the dot prodnegative.
The max function can be added to Equation (10.2) to tecase:
-
8/11/2019 Uni 4 Graficacion
34/42
Lambertian Shading Model
Another way to deal with the negative light is to use a
value:
-
8/11/2019 Uni 4 Graficacion
35/42
Ambient Shading
One problem with the diffuse shading of Equation (10.3) i
point whose normal faces away from the light will be black.
In real life, light is reflected all over, and some light is incievery direction.
In addition, there is often skylight giving ambientlighting.
Libro: Fundamentals Computer Graphics, pp 235, pdf, 3ed, Peter Shirley
-
8/11/2019 Uni 4 Graficacion
36/42
Ambient Shading
One way to handle this is to use several light sources.
Another way is to use two-sided lighting as described by(10.4).
A more common approach is to add an ambient term 1971).
Libro: Fundamentals Computer Graphics, pp 235, pdf, 3ed, Peter Shirley
-
8/11/2019 Uni 4 Graficacion
37/42
Ambient Shading
This is just a constant color term added to Equation (10.3):
c = cr( ca+ clmax (0, n l ) )
Intuitively, you can think of the ambient color caas the avera
all surfaces in the scene.
Libro: Fundamentals Computer Graphics, pp 235, pdf, 3ed, Peter Shirley
-
8/11/2019 Uni 4 Graficacion
38/42
Phong Shading
Some surfaces are essentially like matte surfaces, but
highlights
Examples of such surfaces include polished tile flwhiteboards.
Highlights move across a surface as the viewpoint moves.
Libro: Fundamentals Computer Graphics, pp 236, pdf, 3ed, Peter Shirley
-
8/11/2019 Uni 4 Graficacion
39/42
Phong Shading
This means that we must add a unit vector e toward the eye
equations.
If you look carefully at highlights, you will see that they are reflections of the light.
The color of these highlights is the color of the light
Libro: Fundamentals Computer Graphics, pp 236, pdf, 3ed, Peter Shirley
-
8/11/2019 Uni 4 Graficacion
40/42
Phong Shading
Nosotros buscamos agregar un brillo difuso del mismo color
fuente de luz en el sitio correcto.
El centro del brillo debe colocarse donde la direccin del veunitarioe se ponga en lnea con la direccin del reflejo reprpor el vector unitario r.
Alinear los vectores ry e, equivale a que el ngulo entre ryrepresentado por sea cero.
-
8/11/2019 Uni 4 Graficacion
41/42
Phong Shading
-
8/11/2019 Uni 4 Graficacion
42/42
Referencias
Introduction to computer graphics using Java 2D and 3D, K
Frank, Springer, 2008, pp 216
Libro: Fundamentals Computer Graphics, pp 235, pdf, 3ed, PShirley