# Texture Mapping - University of Florida

CAP4730: Computational Structures in Computer Graphics Texture Mapping Outline What is texture mapping? Math behind texture mapping OpenGL texture mapping

Advanced Topics in texture mapping Marching towards Visual Realism http://www.3drender.com/jbirn/productions.html How do we do this? Another Example 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? Texture A color array that holds an image Similar to a framebuffer gluint buffer[x*y*3] 255 0 255

Procedural Texture Calculate pixel values via functions Image Textures Load pixel values from a file Lets look at some games Texture Space

How would you store this in your program? How much memory? s s = [01] t = [01] t Object Space (u1,v1) (u0,v0)

s Texture -> Object Transformation s = [01] t = [01] t u = [01] v = [01] (u3,v3) (u2,v2)

Going from pixels to textures Object -> Texture Transformation (s,t) (u,v) Image -> Object Transformation (x,y) 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/ Lecture21/Slide05.html Tiling Lets look at the texture coordinates (u1,v1) s

t (u0,v0) (u3,v3) (u2,v2) Textures built to Tile Think Windows Background 0,0

0,1 0,0 2,0 1,1 0,2 2,2

1,0 Why would you want this? Discuss the Pros and Cons of tiling. Look at code Filtering Why does this happen? (u0,v0) (u1,v1)

(u2,v2) Filtering Why does this happen? (ui,vi) (uj,vj) What are some alternatives?

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 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/ hardcopy/GL/html/gl/texenv.html

Screen space vs. world space P0(x,y,z) V0(x,y) V1(x,y) P1(x,y,z) Interpolation in Screen Space P t V0 t V1 V0 V0(x,y)

x0 x1 x0 P t t z0 z1 z0 V1(x,y) z=1 P1(x,y,z) P0(x,y,z) Interpolation in World Space

P t P0 s P1 P0 V0(x,y) x0 x1 x0 P t s z0 z1 z0 V1(x,y) z=1 P1(x,y,z) P0(x,y,z)

Comparing the two P t V0 t V1 V0 P t P0 s P1 P0

x0 x1 x0 P t t z0 z1 z0 x x x P t 0 s 1 0 z0 z1 z0 What do we need to interpolate in screen space now? What happens if we dont have Z? What have we discussed that doesnt

doesn have Z? Perspectively Correct Z http://graphics.lcs.mit.edu/ classes/6.837/F98/Lecture21/ Slide14.html x0 x1 x0 x0 s( x1 x0 ) t z0 z1 z0 z0 s( z1 z0 ) tz0 s z1 t ( z0 z1 ) u u0 s(u1 u0 )

v v0 s( v1 v0 ) Other solutions Cost of screen space interpolation now? Increase # of triangles x0 x1 x0 x0 s( x1 x0 ) t z0 z1 z0 z0 s( z1 z0 )

tz0 s z1 t ( z0 z1 ) u u0 s(u1 u0 ) v v0 s( v1 v0 ) 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 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, Lets Look at some games Pick a favorite game from the class

## Recently Viewed Presentations

• Which of the following adaptations would probably help a plant survive in the desert? ... Western gorilla. 121. Which animal most likely has the characteristics described below:1. Feet covered in hair for protection against extreme temperatures2.
• In addition to thermal layers of thickness δ. T, f, the sidewalls develop viscous (velocity) wall jets. The thickness of these jets δ v from the momentum balance (5.7) for the region of thickness x ∼ δ v outside the...
• Cómo moverse en Gmail. Inbox Sent Mail Drafts Compose. Enlace de vido para -Gmail: cómo bloquear mensajes. Pulse en el mensaje para abrir y leer. Your in-box is the folder where all your mail arrives. Click on a message to...
• Въведение в C# Необходими знания Добро познаване на поне един език за програмиране от високо ниво C C++ C# Java Pascal/Delphi Perl Python Базови познания за архитектурата на .NET Framework Съдържание (1) Какво е C# Принципи при дизайна на езика...
• REDCap Shared Library . Forms already created and validated can be imported directly into library. Listserv: email . [email protected] (in body of message, type the word "subscribe") Email . [email protected] (to reach administrators) REDCap videos
• Coaxial helix. Two separate helical regions stack to form coaxial helices as a pseudo-continuous (quasi-continuous) helix. Coaxial helices are highly stabilizing tertiary interactions and are seen in several large RNA structures, including tRNA, pseudoknots, the group I intron P4-P6 domain,...
• Interface documentation definition between the PCS and Diagnostics is ongoing. The interfaces will include the requirements from PCS for each of the diagnostics allowing additional documentation (i.e. flow-down reports) with the specifications from diagnostics to plasma parameters. IDM UID:
• As a provider accredited by ACCME, the University of Nebraska Medical Center, Center for Continuing Education, the University of Nebraska Medical Center, College of Nursing Continuing Nursing Education, and the American Nurses Credentialing Center's Commission on Accreditation must ensure balance,...