Texture Mapping - PowerPoint PPT Presentation

About This Presentation
Title:

Texture Mapping

Description:

Marching towards Visual Realism. http://www.3drender.com/jbirn/productions.html ... Using only triangles to model everything is hard. Think about a label on a soup can ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 29
Provided by: lok
Learn more at: https://www.cise.ufl.edu
Category:

less

Transcript and Presenter's Notes

Title: Texture Mapping


1
Texture Mapping
CAP4730 Computational Structures in Computer
Graphics
2
Outline
  • What is texture mapping?
  • Math behind texture mapping
  • OpenGL texture mapping
  • Advanced Topics in texture mapping

3
Marching towards Visual Realism
http//www.3drender.com/jbirn/productions.html
4
How do we do this?
5
Another Example
6
Using only Triangles
  • Using only triangles to model everything is hard
  • Think about a label on a soup can
  • Instead of interpolating colors, map a pattern
  • Run Demo
  • How do you create a pattern?

7
Texture
  • A color array that holds an image
  • Similar to a framebuffer
  • gluint bufferxy3
  • 255 0 255

8
Procedural Texture
  • Calculate pixel values via functions

9
Image Textures
Load pixel values from a file
10
Lets look at some games
11
Texture Space
  • How would you store this in your program?
  • How much memory?

s
s 01 t 01
t
12
Object Space
(u1,v1)
(u0,v0)
s
Texture -gt Object Transformation
s 01 t 01 u 01 v 01
(u3,v3)
t
(u2,v2)
13
Going from pixels to textures
Object -gt Texture Transformation
Image -gt Object Transformation
(x,y)
(s,t)
(u,v)
14
What is the question?
  • A pixel (x,y) corresponds to what texture element
    (s,t)?
  • Q How do we convert (s,t) into texture element
    coordinates?
  • TEXture Elements (TEXELS)
  • A Linearly Interpolate texture coordinates!
  • http//graphics.lcs.mit.edu/classes/6.837/F98/Lect
    ure21/Slide05.html

15
Tiling
  • Lets look at the texture coordinates

(u1,v1)
(u0,v0)
s
(u3,v3)
t
(u2,v2)
16
Textures built to Tile
  • Think Windows Background
  • Why would you want this? Discuss the Pros and
    Cons of tiling.
  • Look at code

0,0
1,0
0,1
1,1
17
Filtering
  • Why does this happen?

(u0,v0)
(u1,v1)
(u2,v2)
18
Filtering
  • Why does this happen?
  • What are some alternatives?

(ui,vi)
(uj,vj)
19
Combining Lighting Texturing
  • If you notice there is no lighting involved with
    texture mapping!
  • They are independent operations, which MAY (you
    decide) be combined
  • It all depends on how you apply the texture to
    the underlying triangle

20
Combining Lighting Texturing
  • CT Texture Color
  • CC Base Triangle
  • Replace, CF CT
  • Blend, CF CT CC
  • OpenGL
  • glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
    GL_BLEND)
  • http//trant.sgi.com/opengl/docs/man_pages/hardcop
    y/GL/html/gl/texenv.html

21
Screen space vs. world space
P0(x,y,z)
V0(x,y)
V1(x,y)
P1(x,y,z)
22
Interpolation in Screen Space
P0(x,y,z)
V0(x,y)
V1(x,y)
P1(x,y,z)
z1
23
Interpolation in World Space
P0(x,y,z)
V0(x,y)
V1(x,y)
P1(x,y,z)
z1
24
Comparing the two
  • What do we need to interpolate in screen space
    now?
  • What happens if we dont have Z? What have we
    discussed that doesnt have Z?
  • Perspectively Correct Z
  • http//graphics.lcs.mit.edu/classes/6.837/F98/Lect
    ure21/Slide14.html

25
Other solutions
  • Cost of screen space interpolation now?
  • Increase of triangles

26
Linear Interpolation is wrong?
  • Gouraud is wrong, but why does it look okay?
  • Q Why does Texture mapping not look right even
    though we are doing the same thing?
  • A All about the slope of the interpolation and
    the gradualness or abruptness of the change

27
Transparencies
  • We will revisit this later, but we can use the
    alpha channel to stencil out textures.
  • Thus per pixel, set alpha 1 or alpha 0.
    Where alpha 0,

28
Lets Look at some games
  • Pick a favorite game from the class
Write a Comment
User Comments (0)
About PowerShow.com