Open GL Texture and Bump Mapping - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Open GL Texture and Bump Mapping

Description:

Open GL Texture and Bump Mapping. COSC 471. Professor Schmitt. Matthew Devilbiss. 3/13/07. Abstract ... This presentation will cover the topics of texture and ... – PowerPoint PPT presentation

Number of Views:110
Avg rating:3.0/5.0
Slides: 30
Provided by: Gren6
Category:

less

Transcript and Presenter's Notes

Title: Open GL Texture and Bump Mapping


1
Open GL Texture and Bump Mapping
  • COSC 471
  • Professor Schmitt
  • Matthew Devilbiss
  • 3/13/07

2
Abstract
  • This presentation will cover the topics of
    texture and bump mapping to produce a more
    realistic 3D image. Texture mapping will receive
    primary focus with details on the how to
    implement it and which OpenGL functions should be
    used.

3
Overview
  • Texture Mapping
  • Definition
  • How to implement
  • Uses
  • Bump Mapping
  • Definition
  • Explanation
  • Simple Implementation

4
What is texture mapping
  • A method to add a color, pattern, or texture to a
    3D model.
  • Think of a flat rectangular shaped model
  • Take that model and map a texture to it in order
    to create a chess board, cardboard box, or
    anything else you can think of.

5
What is a Texture Map?
  • An image that can be attached to a polygon
  • Stored as an array
  • Can be mapped to non rectangular objects such as
    spheres, squares, and other various 3D models.

6
Types of Texture Maps
  • There are three main types of texture maps
  • These are 1D, 2D and 3D.
  • 2D are the most prevalent

7
Example 2D Texture
8
Example 3D texture
9
Requirments
  • A texture
  • OpenGL
  • An API that supports rendering textures onto
    polygons.

10
How are they mapped?
  • The texture is given a coordinate system.

(1.0, 1.0)
(0.0, 1.0)
(1.0, 0.0)
(0.0, 0.0)
11
How to texture mapStep One
  • First you must enable texturing
  • Call glEnable(GL_TEXTURE_2D)
  • This enables 2D texturing.

12
How to texture mapStep Two
  • You must now declare a Texture object
  • Texture objects are special internal
    representations of your texture.
  • Declare one by coding
  • texture1 new CTargaImage

13
How to texture mapStep Three
  • Now you have to upload the texture to video
    memory.
  • Use
  • Load(image file)
  • This loads the texture into memory

14
How to texture mapStep Four
  • Now you have to bind the texture object
  • This is done using glBindTexture()
  • Example
  • glBindTexture(GL_TEXTURE_2D, m_textureObjectOne)

15
How to texture mapStep Five
  • Now you set the filtering properties for your
    texture.
  • Filtering handles how OpenGL displays your
    texture from different distances.
  • Use GLTexParameter()

16
How to texture mapStep Six
  • Now you must specify the texture
  • Call this function to do so
  • glTexImage2D()
  • This has 9 parameters.

17
How to texture mapStep Seven
  • Now draw a polygon
  • When drawing a polygon use these functions.
  • glTexCoord(0.1, 0.3) this specifies the texture
    coordinates.
  • glVertex() this tells the OpenGl to apply a
    particular texture to a particular vertex.

18
Finally Done
  • When OpenGl draws the polygon it should be mapped
    with the texture that you specified.

19
Uses of texture binding
  • Now that you can texture map what is it good for?
  • You can make a bland polygon more realistic.
  • Add great detail to an image

20
Who uses texture mapping
  • Any game will use texture mapping.
  • Computer generated videos
  • Simulations
  • Graphic art

21
Recap
  • 1. Enable texturing
  • 2. Load the texture image data
  • 3. Declare a texture object
  • 4. Bind the texture object
  • 5. Set up filtering
  • 6. Specify a texture for the texture object
  • 7. Draw a polygon and specify texture coordinates

22
Bump Mapping
  • Bump mapping changes the surface of a 3D model
  • This is done to make objects look more realistic.
  • This lets a polygons texture appear 3D.

23
Requirments
  • The GPU must have a vertex shader or a vector
    processing unit
  • It must be fast enough so it doesnt bog down
    calculating each bump

24
Example
Without Bump Mapping
With Bump Mapping
25
How to Bump Map
  • The simplest method uses fragment shaders to
    produce the actual bumps.
  • First you must create a height map which is
    usually an array of texels identical to the
    texture being mapped.
  • The height map is used to determine how high or
    low the bump will be

26
Bump Mapping step 2
  • Once the height map is created you must take the
    light and view vectors of each texel
  • Using the height map you can change the vectors
    of the texture.
  • These changes produce a more detailed image.

27
Who uses bump mapping
  • Many games
  • CG movies and graphic artists
  • Anything that requires a more realistic depth

28
Conclusion
  • Texture and Bump Mapping can create a more
    realistic image
  • Both techniques require some skill but are
    essential to producing detailed images
  • Open GL supports both techniques
  • A good video card with vertex shaders will easily
    produce both

29
Questions?
  • Any Questions???
Write a Comment
User Comments (0)
About PowerShow.com