Shading models - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Shading models

Description:

... properties so that the object has a high specular reflectance relative the ... ambient light and the colour of the specular light depends only on the colour of ... – PowerPoint PPT presentation

Number of Views:82
Avg rating:3.0/5.0
Slides: 36
Provided by: ericfl
Category:

less

Transcript and Presenter's Notes

Title: Shading models


1
TOPIC 8
  • Shading models

2
(No Transcript)
3
(No Transcript)
4
(No Transcript)
5
(No Transcript)
6
(No Transcript)
7
(No Transcript)
8
(No Transcript)
9
(No Transcript)
10
(No Transcript)
11
(No Transcript)
12
Calculating the angles ? and ?
COM 366
13
(No Transcript)
14
(No Transcript)
15
(No Transcript)
16
Gouraud shading
COM 366
17
(No Transcript)
18
(No Transcript)
19
Problems with Gouraud shading
1        Mach banding in which the polygon edges
appear unrealistically bright. This is a
physiological response of the human eye arising
from the eyes ability to detect changes of
intensity.   2        Problems are encountered in
animation sequences because the intensity
calculations are carried out in screen
co-ordinates from vertex normals calculated in
world co-ordinates.     The process of averaging
normals to produce vertex normals can lead to
loss of information since several different
combinations of normals can lead to the same
average
COM 366
20
Phong shading
The first two objections can be overcome by using
Phong shading developed by Bui-Tuong Phong in
1975. The first stage of the process is the same
as Gouruard shading until the vertex normals have
been calculated.   Instead of now calculating
vertex shading values the vertex normals
themselves are interpolated in two dimensions
across the surface. This interpolated normal is
then used to obtain a shading value at each
polygon pixel position.   On average Phong
shading is typically more computationally
intensive by a factor of 5 1
COM 366
21
Shading in MATLAB
COM 366
22
The properties of the light The properties of the
object The shading algorithm
COM 366
23
Using the light command
light('Position',1 0 0,'Style','infinite','color
','white')
COM 366
24
Parameters for use with patch or surf
colorspec Any of the allowed MATLAB colour
specifications for example green or an RGB
triplet 0.55, 0.7, 1 etc.   flat The colour
data at the first vertex determines the colour of
the whole face.   none Do not draw the face or
edge as appropriate.   interp This is a
bilinear interpolation of the colour across the
face from the vertices of the patch or surface
element.
surf(X,Y,Z,'FaceColor','red','EdgeColor','none')
COM 366
25
Using the material command-1
Shiny sets the reflectance properties so that
the object has a high specular reflectance
relative the diffuse and ambient light and the
colour of the specular light depends only on the
colour of the light source.   Dull sets the
reflectance properties so that the object
reflects more diffuse light, has no specular
highlights, but the colour of the reflected light
depends only on the light source.   metal sets
the reflectance properties so that the object has
a very high specular reflectance, very low
ambient and diffuse reflectance, and the colour
of the reflected light depends on both the colour
of the light source and the colour of the object.
material shiny
COM 366
26
Using the material command-2
material(ka kd ks n sc)
ka, kd ks 0ltklt1
n a positive integer
sc a normal colour spec.
COM 366
27
Using the lighting command
lighting flat lighting gouraud lighting
phong lighting none
COM 366
28
Putting it all together
function LightDemo To demonstrate some of the
properties of lighting Create a sphere with a
red colour and draw it with the surf
command X,Y,Z sphere(30) surf(X,Y,Z,'FaceColo
r','red','EdgeColor','blue') Try changing the
material to dull, shiny, metal and see the
effect material (0.4 0.7 0.95 100) Light is
incident along the X axis and is located an
infinite distance away Try changing the colour
of the light (e.g. 'white', 'green', 'blue'
etc.) light('Position',1 0 0,'Style','infinite',
'color','white') Try the effects of flat,
gourard or phong shading lighting phong axis
square rotate3D on
COM 366
29
COM 366
30
flat
gouraud
Phong
COM 366
31
COM 366
32
COM 366
33
COM 366
34
COM 366
35
COM 366
Write a Comment
User Comments (0)
About PowerShow.com