1 9. Textures v Create the illusion of detail by wraping a complex image (texture) around a simple...

Post on 12-Jan-2016

216 views 0 download

Transcript of 1 9. Textures v Create the illusion of detail by wraping a complex image (texture) around a simple...

1

9. Textures9. Textures Create the illusion of detail by wraping a Create the illusion of detail by wraping a

complex image (texture) around a simple complex image (texture) around a simple geometrygeometry– realism is increased without the need for a realism is increased without the need for a

complex shapecomplex shape

Texture Mapping

continued

2

TexturesTextures

3

OpenGL PipelineOpenGL Pipeline

OpenGL Pipeline Overview DiagramOpenGL Reference Manual (Addison-Wesley Publishing Company)

4

TexturesTextures

Express a image or complex objectsExpress a image or complex objects How to present wall or treeHow to present wall or tree

– Geometry and color??Geometry and color??

– Texture!!Texture!!

5

TexturesTextures

Basic PrinciplesBasic Principles Create a Simple TextureCreate a Simple Texture

6

TexturesTextures

ObjectivesObjectives

Know what a texture is and why we need it. Know what a texture is and why we need it. Be able to program simple textures. Be able to program simple textures.

7

TexturesTextures

Basic PrinciplesBasic Principles

Detailed surface structures are hard and Detailed surface structures are hard and expensive to build in 3D -> Texture!expensive to build in 3D -> Texture!

„„Texel“ is „texture element“ -> one pixel of Texel“ is „texture element“ -> one pixel of a texture.a texture.

Texture mapping: Fit image to a given Texture mapping: Fit image to a given geometry.geometry.

8

TexturesTextures

Create a Simple TextureCreate a Simple Texture

Load an imageLoad an image

Create a textureCreate a texture

Create 3D-Create 3D-object with appearanceobject with appearance

String filename = "earth.jpg"; TextureLoader loader = new TextureLoader(filename, this);ImageComponent2D image = loader.getImage();

Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, image.getWidth(), image.getHeight());texture.setImage(0, image);

Appearance appear = new Appearance(); appear.setTexture(texture);

Sphere earth = new Sphere(1.0f, Primitive.GENERATE_TEXTURE_COORDS, appear));

9

Java3D TexturesJava3D Textures

TextureLoader classTextureLoader class TexCoordGeneration classTexCoordGeneration class Texture2D classTexture2D class Texture3D classTexture3D class

10

Adding TextureAdding Texture

Adds high-frequency detail that would be Adds high-frequency detail that would be unreasonable to achieve through polygons unreasonable to achieve through polygons and colorand color

11

12

13

14

TexturesTextures

ArtistArtist creates creates BitmapsBitmaps

““wrap the wrap the bitmap around bitmap around the model” via the model” via UV MappingUV Mapping

15

UV MappingUV Mapping

Cutting, Stretching, Rotating a flat texture Cutting, Stretching, Rotating a flat texture to project on a 3D surfaceto project on a 3D surface

Texture Exists in (u,v) spaceTexture Exists in (u,v) space Model’s polygons carry (u,v) coordinates in Model’s polygons carry (u,v) coordinates in

addition to (xyz)addition to (xyz) Use tools to assign the proper (u,v) pairs to Use tools to assign the proper (u,v) pairs to

each polygoneach polygon

16

u

v

1.0, 0.5

0,0

0.5, 1.0 0,0

1.0, 0.5 0.5, 1.0

17

2D and 3D textures are supported2D and 3D textures are supported

Textures an be attached to shapes in a varietTextures an be attached to shapes in a variety of predefined ways, or linked to specific cy of predefined ways, or linked to specific coordinates in the shape.oordinates in the shape.

18

Texture MappingTexture Mapping Wrap and ClampWrap and Clamp

FilteringFiltering– Texel to pixelTexel to pixel– MagnificationMagnification– MinificationMinification– MIPmapsMIPmaps

19

Texture Coordinate GenerationTexture Coordinate Generation

TexCoordGeneration classTexCoordGeneration class– Automatically generate texture coordinates.Automatically generate texture coordinates.– Linear ProjectionLinear Projection– Sphere MapSphere Map