Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 20

‫ייצוג בעולם ‪3D‬‬

‫• ייצוג מצולעים (פוליגונים)‬


‫צלע‬

‫משולש‬ ‫‪V1‬‬
‫קודקוד‬
‫‪T1‬‬ ‫‪e3‬‬

‫‪T2 e0‬‬
‫}‪e0 : {v1,v2‬צלע‬ ‫‪T0‬‬ ‫‪V0‬‬
‫}‪T2 :{v0,v1,v2‬משולש‬ ‫‪T3‬‬
‫‪e1‬‬

‫‪e2‬‬
‫דוגמאות‬
‫כך זה נראה בגדול‬
‫נוסיף צבע לעולם‬
‫ועוד תאורה ‪...‬‬
‫נעדן את התאורה ‪..‬‬
‫עכשיו זה נראה בסדר‬
‫עם כל השיפורים‬
Illumination and Shading
Light in Reflection
• How to shade a surface Reflection Specular

– Position (Light/Surface) (diffuse)


– Orientation (Light/Surface)
– Characteristics (Light/Surface)
• Local Illumination Models Internal
Reflection
– Individual point and
– The light source/s Illuminate it
• Global Illumination Models
– The light source and Transmitted
– The interchange of light emission Light
between all the surfaces
Ambient Light
• Non reflective
• Self-luminous
• Illumination equation
I = ki
• I is the resulting intensity
• Ki is the object’s intrinsic intensity
• An ambient illumination variable is
associated with each point
• Evaluating the ambient equation
<==> Lighting the object.
Diffuse Reflection
• Point light source
• The brightness depends on the
angle  between direction to the 
light L and the surface normal N
• If the light bean
– Has cross sectional deferential are dA I = Ip kd cos(
– It intercepts an area dA/cos() of the
surface. N


N
dA dA/cos( )

S1 S2
Combining Shading Models

Series of pictures of sphere illuminated by diffuse reflection


model only using different Kd values (0.4, 0.55, 0.7, 0.85,1.0).

Series of pictures of sphere illuminated by ambient and diffuse reflection


model. Ia = Ib = 1.0, Kd = 0.4 and Ka = {0.0, 0.15, 0.30, 0.45, 0.60}
Light Source Attenuation
I  I a K a  f att I p K d ( N  L)

1
f 
att dl2

1
f  min(1,
att ad 2 bd c
Specular Reflection
Phone Illumination N
Developed by Phong Bui-Toung for nonperfect L R
reflection. The model assumes that the maximum
specular reflection occurs when  is zero and falls    V
off sharply as  increases. The rapid falloff is
approximated by cos n() .

I = Ia Ka +
fatt Id [KdOd cos() +W()cos n()]
Od :Object diffuse factor.
W():Factor of specular reflection light
Specular Reflection
Shading Models for Polygons
Shading
We can shade a surface by calculating the surface normal at each visible
point and applying the desired model at that point.

Constant Flat Shading


Applies an illumination model one to determine a singles intensity value
that is then used to shade the entire polygon.

Interpolated Shading
Shading information is linearly interpolated across triangle from illumination
values determined at it vertices
Polygon Mesh Shading
Gouraud Shading extends the concept of interpolated shading applied
to individual polygons by interpolating polygon vertex illumination values
that take into account the surface being approximated.
A vertex intensity is computed by using the vertex
normal with any desired shading model.

Phong Shading interpolates the surface normal vector, rather


than the intensity. Interpolation occurs across a polygon span on a
scan line.
Interpolated Shading Problems
• Polygonal Silhouette
• Perspective distortion
• Orientation dependence
• Problem at shared vertices
• Inaccurate vertex normal
Light & Material in OpenGL
GLfloat lit_mbient[] = {0.2, 0.2, 0.2, 1.0};
GLfloat lit_diffuse[] = {1.0, 1.0, 1.0, 1.0};
GLfloat lit_specular[] = {1.0, 1.0, 1.0, 1.0};
GLfloat lit_position[] = {-2.0, 1.0, 3.0, 1.0};
GLfloat lit_spot_dir[] = {-1.0, -1.0, -1.0};
GLfloat lit_shine[] = {50.0};
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, lit_ position);
glLightfv(GL_LIGHT0, GL_AMBIENT, lit_ ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lit_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, lit_specular);
glLightfv(GL_LIGHT0, GL_SPECULAR, lit_specular);
glLightfv(GL_LIGHT0, GL_SHININESS, lit_shine);
Material

You might also like