Texture mapping
Adds realism to computer graphics Texture mapping applies a pattern of color Bump mapping alters the surface Mapping is cheaper than adding polygons
Example
Normalizing mapping We might need to bound the object It’s common no normalize coordinates
Mapping types 2D and 3D
2D mapping How the image is pasted on the object?
Planar mapping Remove Z coordinate
Planar shape Z axis X axisX-Z axis
Cylindrical Use angle and height
Cylindrical
Sphere Longitude and latitude
Sphere
Box Map
A fast way for environment mapping
Parametric patch
Break up model into single texture
Combining textures Background colors are transparent
2D drawbacks Singularities Taking out the right dimension
3D textures Use (x,y,z) to compute the color Similar to carving object out of a solid Colors are not stored for each (x,y,z) Coordinate based computation
3D textures Use point to compute an index into color table. –Using fractional part of X coordinate.
Noise Desired properties –Known range –Stationary –Band limited Lattice noise –Random number at each integer lattice point –Use it for object integers, otherwise – interpolate Gradient noise –Random gradients at integer lattice points
Noise Marbled appearance by perturbing stripes
Noise Making wood by adding noise to concentric rings
Bump mapping Change object normals before rendering Both magnitude and direction are subject to change The geometry does not change With bump mapping No bump mapping
Bump mapping
If transition is from white to black, rotate the point’s surface normal by θ If transition is from black to white, rotate the point’s surface normal by -θ
Displacement map Alters object geometry Displaces points along normal Bump Map Displacement Map
Texture in Inventor Nodes –SoTexture2. Specifies a 2D texture map. –SoTextureCoordinate2. Defines the set of 2D texture coordinates SoTexture2 *rock = new SoTexture2; root->addChild(rock); rock->filename.setValue("brick.1.rgb"); root->addChild(new SoCube);
SoTexture2 Fields Filename (name of the file to use as a map) Image (color and number of pixels) wrapS, wrapT – image wrapping in horizontal (s) and vertical (T) directions. –REPEAT. Repeat all texture –CLAMP. Repeat last row Model –MODULATE. The shaded color times the texture –DECAL. Replace the shaded color with texture –BLEND. Blends the shaded and texture colors blendColor – specifies blending method
Transforming Texture SoTexture2Transform –Rotation –Translation –scaleFactor. Scales texture on object –Center
Mapping texture Several options –Default coordinates (according to shape) –For vertexes it can be specified explicitly –Use texture coordinate functions SoTextureCoordinatePlane SoTexturecoordinateEnvironment
Default texture mapping Compute the bounding box Longest edge is the horizontal edge (s) The next longest is the vertical (t) Set (s) coordinates from 0 to 1 Set (t) coordinates from 0 to |t|/|s|
Mapping to different surfaces