0% found this document useful (0 votes)
13 views57 pages

7280_lecture3_graphics-pipeline-2

The document discusses various aspects of the graphics pipeline, focusing on illumination and shading techniques such as the Phong Reflection Model, diffuse and specular reflection, and texture mapping. It explains how these techniques contribute to realistic rendering in computer graphics, including methods like Gouraud and Phong shading, as well as the use of bump and environment mapping. Additionally, it highlights the evolution of graphics hardware to meet the demands of real-time and high-quality rendering in the gaming industry.

Uploaded by

rkrams1989
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views57 pages

7280_lecture3_graphics-pipeline-2

The document discusses various aspects of the graphics pipeline, focusing on illumination and shading techniques such as the Phong Reflection Model, diffuse and specular reflection, and texture mapping. It explains how these techniques contribute to realistic rendering in computer graphics, including methods like Gouraud and Phong shading, as well as the use of bump and environment mapping. Additionally, it highlights the evolution of graphics hardware to meet the demands of real-time and high-quality rendering in the gaming industry.

Uploaded by

rkrams1989
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

CSC7280

Graphics Pipeline 2

CSC7280 (Fall 2006)


Illumination and Shading

CSC7280 (Fall 2006)


Reflection from Surfaces

• Although we have modeled different light source in computer graphics,


we seldom draw light sources.
• What we draw is usually the surfaces that reflect light.

CSC7280 (Fall 2006)


Reflection from Surfaces

• Light is a spectral quantity.


• We usually sample at three wavelengths, R G B
• There are three major components in the calculation of the intensity
(either R, G, or B channel) reflected from a surface.
• Diffuse
• Specular
• Ambient
• The first two terms are realistic while the third term is heuristic.

CSC7280 (Fall 2006)


Phong Reflection Model
• The most commonly used reflection model in most graphics systems.
• Notation:

• Many variations, the following is a common model:

reflected = ambient + diffuse + specular

I r ( λ ) = I a k a ( λ ) + ∑ m I m ( λ )[ k d ( λ )( Lm ⋅ N ) + k s ( λ )( R m ⋅ V ) n ]

CSC7280 (Fall 2006)


Indirect Illumination (Ambient)
• Some surfaces are illuminated even it is in shadow. Why?
• There is indirect lighting (background lighting) reflected from other surfaces

2 3

4
5

• Each surface illuminated by all point and extended sources becomes itself, a source
of light for illumination off all other line-of-sight surface of the scene.
• Each of these surfaces, in turn, reflect light to other surfaces, including the original
one, thus achieving an “infinite regression” of reflections and illumination.
• Heuristic: Simply assume the indirect lighting is constant (same to all objects in the
scene) in most graphics systems.

CSC7280 (Fall 2006)


Diffuse Reflection
• So, the diffuse contribution of the m-th light source is

I m ( λ ) k d ( λ )( Lm ⋅ N )
• where
– I is the intensity from the light source
– kd is the diffuse reflectivity of the surface (color of the object)
– N is the surface normal vector
– L is the light vector (the direction from the point to the light source)
– λ is the wavelength parameter
– m is the id of the light source
• If you plot the reflected intensity viewed from different
direction as a distance to the surface point, we will plot a
hemisphere.

CSC7280 (Fall 2006)


Appearance of a
diffuse (dull) sphere

3D plot of reflected intensity

CSC7280 (Fall 2006)


Specular Reflection
Specular
• Model the glossy appearance of shiny object.
• Viewpoint dependent
• You will observe highlight from glossy surface around the mirror reflection
direction R.

CSC7280 (Fall 2006)


Specular Reflection
• The shape of the bump looks like a cosine function.
• Let’s model the bump using cosine function

cos n φ
n=5
n=50
n=200

-π/2 0 π/2 φ

CSC7280 (Fall 2006)


Specular Reflection
• So, the specular contribution due to the m-th light source is

I m ( λ ) k s ( λ )( R m ⋅ V ) n
• where
– I is the intensity from the light source
– ks is the specular reflectivity of the surface (color of the object)
– R is the normalized mirror reflection vector
– V is the viewing vector (the direction from the point to your eye)
– λ is the wavelength parameter
– m is the id of the light source
– n controls the sharpness of the bump

CSC7280 (Fall 2006)


Appearance of a
specular sphere

3D plot of reflected intensity

n=5

CSC7280 (Fall 2006)


Appearance of a
specular sphere

3D plot of reflected intensity

n = 15

CSC7280 (Fall 2006)


Diffuse +Specular Reflection
• Diffuse + Specular

• You can control the ratio of diffuse to specular by adjusting ks and kd


• Contribution due to multiple light sources are simply added together

∑ m
I m ( λ )[ k d ( λ )( Lm ⋅ N ) + k s ( λ )( R m ⋅ V ) ] n

CSC7280 (Fall 2006)


kd = 0.7
ks = 0.4
n = 15

CSC7280 (Fall 2006)


kd = 0.85
ks = 0.25
n = 15

CSC7280 (Fall 2006)


Interpolative Shading
• Remember that most graphics hardware can only draw polygon.
• Smooth curved surface has to be polygonized in order to be displayed.
• If you shade the surface honestly using previously mentioned illumination
model, you will see ….

• Hmm, the surface is not smooth when display.

CSC7280 (Fall 2006)


Interpolative Shading
Interpolative shading
To recover (approximately) the visual appearance of curved surface
which is now represented by flat polygons.
Assumption:
1) An approximate normal to the original smooth surface is given or can be
computed at each vertex by averaging the normals to the polygons
sharing that vertex.

Np=(N1+N2+N3+N4)/4

2) The shading of a particular pixel can be obtained by a bilinear


interpolation of the the appropriate quantities from adjacent vertices.

CSC7280 (Fall 2006)


Gouraud Shading
• Calculate the intensity at each vertex using local reflection model
• Intensities of interior pixels are determined by linearly interpolating the vertices’
intensities

• Interpolation equations are:


Ia = [I1 (ys- y2 ) + I2(y1-ys)] / (y1 - y2)
Ib = [I1 (ys- y3) + I3(y1-ys)] / (y1 - y3)
Is = [Ia (xb- xs) + Ib(xs-xa)] / (xb - xa)

CSC7280 (Fall 2006)


Gouraud Shading

CSC7280 (Fall 2006)


Gouraud Shading
• Flaws of Gouraud Shading:
1) Highlight anomalies

If the highlight appears in the interior of the polygon, Gouraud may fail to
shade this highlight because no highlighted intensities are recorded/calculated
at the vertices.

2) Mach banding
Human visual system emphasizes intensity changes occurring at a boundary,
which creates a banding effect. The bands can be obvious if insufficient
polygons are used to model area of high curvature.

CSC7280 (Fall 2006)


Phong Shading
• Instead of interpolating the vertex intensities, Phong interpolates vertex normal
vector.
• Solves the interior highlight problem:

• Interpolation equations are:


Na = [N1 (ys- y2 ) + N2(y1-ys)] / (y1 - y2)
Nb = [N1 (ys- y3) + N3(y1-ys)] / (y1 - y3)
Ns = [Na (xb- xs) + Nb(xs-xa)] / (xb - xa)

CSC7280 (Fall 2006)


Phong Shading
• Since illumination calculation has to be invoked at each interior surface point,
Phong shading is more expensive than Gouraud shading.

CSC7280 (Fall 2006)


Texture Mapping

CSC7280 (Fall 2006)


Texture Mapping

• When you shade an object with single color on the screen, the
image will be quite boring and not realistic.
• Reason: real objects are seldom in single color and perfectly clean.
• Texture mapping is a technique to put texture (color pattern) on the
object surface to improve visual richness and realism.
• It is a process of replacing/modifying the original surface properties
(e.g. color, reflectivity and roughness) of the object surface by
referring to a table (map) stored in an image (texture map).

CSC7280 (Fall 2006)


Texture Mapping
• The map exists in a coordinate system called the texture space.
• A texture is a function that is defined on the interval 0 to 1 along both
axes in the texture space.
• The individual elements of a texture are called texels
T Y

1.0
mapping
t
0.0 S X
0.0 s 1.0
Object
space
Z

Mapping from 2-D texture space to 3-D object space.

CSC7280 (Fall 2006)


Texture Mapping
• Example 1:

The curve surface looks


more like a flag

CSC7280 (Fall 2006)


Texture Mapping
• Example 2:

The cylinder looks


more like a can.

CSC7280 (Fall 2006)


Texture Mapping

How to Texture Map?

1. What attribute or parameter of the object is to be modulated


(modified) to produce the desired effect.

2. How is the texture mapping to be carried out ?

3. Why my texture mapped so ugly? Any antialiasing solution?

CSC7280 (Fall 2006)


Attributes To Be Modulated

1 Surface color (diffuse reflection coefficient(s)).

CSC7280 (Fall 2006)


Attributes To Be Modulated
2 Transparency (opacity mapping)
Modulate the opacity (1.0-transparency) of a surface. This enables
transparent objects to be simulated.
It can also be used to generate a cloud - using a mathematical texture
function to modulate the transparency of an ellipsoid.

CSC7280 (Fall 2006)


Attributes To Be Modulated
3 Normal vector perturbation (bump mapping)
A bump map is a 2D look-up table holding intensity level used to
modulate a surface whilst rendering.
The table is generally a photograph of some obliquely illuminated
textured surface, and when this disturbs the surface normal the illusion
of surface depth is created, even though the rendered surface is still
completely smooth. (to be discussed later)
4 Specular and diffuse reflection (environment mapping)
Use texture maps to create the impression of high-gloss surface such as
mirrors and polished metal surfaces.
One approach is to surround the reference object with a six-sided box,
whose sides will effectively hold the texture maps. A renderer can then
determine which map is visible on any surface, and apply the reflected
texels to the relevant pixel.

CSC7280 (Fall 2006)


Bump mapping
This technique enables a surface to appear as if were wrinkled or
dimpled without the need to model these depressions geometrically
The surface normal is angularly perturbed according to information
given in a 2D bump map.

Original surface and its normal vectors

Height field added to the surface and the new


normal vectors.

Perturbed normal vector according to the height


field store in the texture map.

CSC7280 (Fall 2006)


Bump mapping
We perceive surface roughness is not because we see the difference in
height.
It is because we perceive the distribution of light reflected from the
bumpy surface. This distribution is because of normal vectors!!
Bump mapping is a clear trick that makes use of our limitation

CSC7280 (Fall 2006)


Environment mapping

• Z-buffer rendering has one serious problem.


• There can be no reflection!!
• Even the surface of the object is mirror-like, it does not reflect surrounding
environment.
• For a reflective object embedded in a complex environment, ray tracing
the reflections would be prohibitively expensive.
• Environment mapping gives us these reflections more cheaply, though
with loss of accuracy.
• Object is surrounded by a closed 3D surface onto which the environment is
projected.
• Reflected rays are traced from the objects, hit the surface and then index
into the map.

CSC7280 (Fall 2006)


Environment mapping
• Note that environment map is viewpoint dependent i.e. when your
viewpoint change the texture change.
• This is very different from previous texture mapping techniques
• The accuracy depends on the object being positioned at the center of this
surface, and it is assumed that the objects in the environment are distant form
the object receiving the environment map.
e.g. the Abyss - reflect an environment in a transparent animated object.

Environment can also be a box


CSC7280 (Fall 2006)
Mapping 2D Texture to 3D Surface
• We try to take the vertices of the polygon and associate a
texture map coordinate (U,V) with each vertex.
Deriving a mapping or projection function F() such that
(U,V) = F(X, Y, Z)
where (X, Y, Z) are the coordinates of the objects to be mapped
• But HOW?

Best solution so far is by hand!


There is no complete solution.
You will face distortion or discontinuity of the texture
e.g. wrap a sphere with a sheet of paper. You must either
distort it or cut it.

CSC7280 (Fall 2006)


CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
3D Texture
• The only general way to solve the distortion and discontinuity problem of
2D texture mapping is to use 3D texture mapping instead.
• The texture used is no longer 2D, but 3D.
• 3D texture can be thought of as a stack of 2-D texture (ie. volume).

u
0,1,0

0,1,1 1,1,0
v
0,0,0 1,1,1
1,0,0 w
0,0,1
1,0,1

• This time we want a mapping from 3D to 3D


(U,V,W) = F(X, Y, Z)

CSC7280 (Fall 2006)


3D Texture
• We are no longer warping a paper onto the 3D object, but crafting a 3D
object from 3D material

CSC7280 (Fall 2006)


3D Texture
3-D texture can be used for
1. Volume rendering
2. Examining a 3-D volume one slice at a time
3. Animating textured geometry
Texel values defined in a 3-D coordinate system form a texture volume.

CSC7280 (Fall 2006)


Graphics Processing Unit
(GPU)

CSC7280 (Fall 2006)


Graphics Hardware
• Due to the blooming of games industry, hardware
manufacturers has developed powerful graphics accelerators in
90’s
• We want:
– real-time rendering
– movie-quality rendering
• Why 90’s games look unrealistic or “plastic”?
• The graphics board has fixed rendering equation that is good
for rendering plastic, not metal nor human skin
• To achieve, we need to look at Pixar’s RenderMan shading
language, the industry de facto standard, like Monsters, Inc.

CSC7280 (Fall 2006)


Graphics Hardware (2)
• To tackle the two goals, hardware manufacturers employ:
– parallelism to achieve real-time rendering
– shader programmability to achieve movie-quality rendering
• It is also the ideal shading language that hardware designers
want to support

CSC7280 (Fall 2006)


Programmable Pipeline

CSC7280 (Fall 2006)


Graphics Processing Unit (GPU)
• Hardware-accelerated shader is virtually the descendant of
RenderMan shader (software).
• The primitive geometry in GPU is triangle
• Two major components: vertex and fragment shaders

CSC7280 (Fall 2006)


SIMD
• This GPU parallel machine is SIMD (Single Instruction
Multiple Data) in nature, i.e. each processor executes the
same instruction but on different data
• Suitable for graphics operations. For example,
– Addition of two images: Each processor holds a pixel
data and performs the same addition operation
– Transformation of vertex normal: Each processor holds a
vertex data and performs the same transformation to
different vertex normal

CSC7280 (Fall 2006)


Vertex Shader
• Vertex shader is the first shader in the graphics pipeline
• Vertex shader is executed at each vertex. Each vertex shader is
supposed to be executed independently and in parallel

vs
……
……
…… vs
……
……
……

vs
……
……
……

CSC7280 (Fall 2006)


Fragment Shader
• Fragment shader works for the projected and rasterized triangle, i.e.
image space of a triangle
• It is pixel-wise shader fs
… … fs

fs fs
fs …
… …
fs
fs …

fs fs
… …

CSC7280 (Fall 2006)


Fragment Shader (2)
• Again each fragment shader is supposed to be processed
independently and in parallel
• Fragment shader performs texture lookup
• You can also perform postfiltering and any other
processing
• Early hardware implementation of fragment shader
restricted to 8-bit, but the latest implementation supports
32-bit

CSC7280 (Fall 2006)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy