SI23 Introduction to Computer Graphics - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

SI23 Introduction to Computer Graphics

Description:

Bump Mapping. This is another texturing technique. Aims to simulate a dimpled or wrinkled surface ... bump map b(u) add b(u) to P(u) in surface normal ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 37
Provided by: kenbr
Category:

less

Transcript and Presenter's Notes

Title: SI23 Introduction to Computer Graphics


1
SI23Introduction to Computer Graphics
  • Lecture 16 Some Special Rendering Effects

2
Where were we?
  • Phong reflection model tells us how light
    reflects from surfaces

3
Phong Reflection Model
light source
N
R
L
eye
?
V
?
surface
dist distance attenuation factor
In practice, we evaluate IRED, IGREEN, IBLUE for
red, green, blue intensities IRED KaREDIaRED
( KdRED( L . N ) Ks( R . V )n ) IRED/dist
4
Interpolated Shading
  • Polygons can be efficiently shaded using
  • Flat shading
  • Gouraud shading
  • Phong shading
  • Visible surfaces are determined using the
    z-buffer algorithm

5
Flat, Gouraud and Phong Shading
6
Phong versus Gouraud Shading
  • A major advantage of Phong shading over Gouraud
    is that specular highlights tend to be much more
    accurate
  • vertex highlight is much sharper
  • a highlight can occur within a polygon
  • Also Mach banding greatly reduced
  • The cost is a substantial increase in processing
    time because reflection model applied per pixel
  • OpenGL only supports Gouraud shading

7
  • Adding Realism Through Texture Effects

8
Adding Realism
  • Objects rendered using Phong reflection model and
    Gouraud or Phong interpolated shading often
    appear rather plastic and floating in air
  • Texture effects can be added to give more
    realistic looking surface appearance
  • Simple texture
  • Bumps
  • Light maps

9
Adding Surface Detail
  • The most obvious solution is not the best
  • breaking the scene into smaller and smaller
    polygonal objects increases the detail
  • ..BUT it is very hard to model and very
    time-consuming to render
  • Preferred solution is texture mapping
  • typically a 2D image painted onto objects

10
A Simple Example
  • Suppose we have a 2D image...
  • .. and a 3D box
  • .. we can paint the image on a face of the box

11
or a teapot
12
Basic Concept
  • Replace the shading calculation with a look-up
    into a texture map (ie 2D image) to get the
    colour of a pixel
  • May replace shaded value - or modulate it in some
    way

13
Question
  • We could apply the texture in screen space (ie
    after projection)
  • ... or we could apply it in object space (ie
    before projection)
  • Which is more sensible?

14
Texture Mapping - Overview
texture space
screen space
object space
15
Mapping Texture to Polygons
  • For polygon texture mapping, we explicitly define
    the (u,v) co-ordinates of the polygon vertices
  • That is, we pin the texture at the vertices
  • We interpolate within the triangle at the time of
    scan converting into screen space

texture space
16
Texture Mapping Triangles
Interpolation is done during scan
conversion, similar as is done for Gouraud
interpolated shading
But rather than interpolate to get RGB values,
we get (u,v) values which point to elements of
texture map.
17
Interpolation in Texture Space
  • The interpolation in texture space has to be done
    carefully
  • Equal steps in screen space do not correspond to
    equal steps in object space (and hence texture
    space)
  • Why?

V
texture
U
Y
object
X
Z
J
screen
I
A line is a line in all 3 spaces
18
Interpolation in Texture Space
  • The rate of change in texture space will depend
    on the depth of the points from the viewer
  • Correct approach is to scale by the distance (zP,
    zQ) of the points from the viewer

P
Q
P
Q
If Q further away than P, then as we take equal
steps from P towards Q, we want to take
increasingly large steps in (U,V) space from P
to Q.
19
Interpolation in Texture Space
  • Suppose (uP, vP) and (uQ,vQ) are texture co-ords
    at end-points P, Q
  • Linear interpolation would be
  • u auQ (1-a)uP
  • with a increasing from 0 to 1 (similarly for v)
  • Correct texture interpolation is
  • u auQ / zQ (1-a)uP / zP / D
  • where D a/ zQ (1-a)/ zP

P
Q
P
Q
Note this is equivalent to a linear
interpolation in projective space
20
Check for Yourself
  • Suppose P is one unit from viewer, and Q is two
    units from viewer
  • Show that the mid-point in screen space is
    equivalent to one-third of the distance along the
    line in texture space

21
Summing Up
  • We have seen how a 2D texture image can be mapped
    to an object, at the rendering stage
  • for a polygon, we pin texture to vertices and
    interpolate (correctly!) at scan conversion time
  • The texture value is used to modify the colour
    that would otherwise be drawn
  • options include replacing completely, or
    modulating (eg by multiplying shaded value with
    texture value)

22
  • Bump Mapping

23
Bump Mapping
  • This is another texturing technique
  • Aims to simulate a dimpled or wrinkled surface
  • for example, surface of an orange
  • Like Gouraud and Phong shading, it is a trick
  • surface stays the same
  • but the true normal is perturbed, or jittered, to
    give the illusion of surface bumps

24
Bump Mapping
25
How Does It Work?
  • Looking at it in 1D

original surface P(u)
bump map b(u)
add b(u) to P(u) in surface normal direction,
N(u)
new surface normal N(u) for reflection model
26
Bump MappingA Bump Map
27
Bump MappingResulting Image
28
Bump Mapping - Another Example
29
Bump MappingAnother Example
30
Bump MappingProcedurally Defined Bump Map
31
Another pioneer
  • Jim Blinn
  • Creator of bump mapping and many other graphics
    effects

32
  • Light Maps

33
The Problem with Gouraud.
  • Gouraud shading is established technique for
    rendering but has well known limitations
  • Vertex lighting only works well for small
    polygons
  • but we dont want lots of polygons!

34
Pre-Compute the Lighting
  • Solution is to pre-compute some canonical light
    effects as texture maps
  • For example

35
Rendering using Light Maps
  • Suppose we want to show effect of a wall light
  • Create wall as a single polygon
  • Apply vertex lighting
  • Apply texture map
  • In a second rendering pass, apply light map to
    the wall

36
Light Maps
  • Widely used in games industry
  • Latest graphics cards will allow multiple texture
    maps per pixel
Write a Comment
User Comments (0)
About PowerShow.com