1 / 15

Advanced Computer Graphics: Texture

Advanced Computer Graphics: Texture. James Gain Department of Computer Science University of Cape Town jgain@cs.uct.ac.za. Objectives. To motivate for surface detail. To introduce the different forms of texture mapping: Two-dimensional Volumetric Bump.

Download Presentation

Advanced Computer Graphics: Texture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Computer Graphics:Texture James Gain Department of Computer ScienceUniversity of Cape Town jgain@cs.uct.ac.za Advanced Computer GraphicsCollaborative Visual Computing Laboratory

  2. Objectives • To motivate for surface detail. • To introduce the different forms of texture mapping: • Two-dimensional • Volumetric • Bump. • To discuss texture sampling issues. Advanced Computer Graphics

  3. Motivation for Surface Detail • So far, we have assumed: • perfectly smooth, uniformly coloured surfaces. • This is unrealistic. In reality surfaces are: • Multi-coloured (e.g. a painting, bottle label, page in a book), bumpy (e.g. almost every surface, few things are perfectly smooth), and textured (e.g. wood, leaves) Without Surface Detail With Surface Detail Advanced Computer Graphics

  4. Types of Surface Detail • Micro-faceting: use objects with hundreds of small polygons. Becomes prohibitively expensive. • Surface Detail polygons: Smaller polygons placed across the surface of larger polygons. Do not add to visible surface determination costs. • Texture mapping: “Wallpaper” an image across the surface of an object. Adds detail as part of rendering rather than modelling. Advanced Computer Graphics

  5. Surface Detail Polygons • Using many small differently coloured polygons is impractical because of rendering costs. • Alternative: Surface Detail Polygons • Overlay co-planar polygons (e.g. doors, windows) onto a base polygon (e.g. a wall). • In visible surface determination, surface-detail polygons are ignored. • In rendering, the surface-detail polygons take precedence over the base. • Not a serious contender. Only good for broad scale detail. Advanced Computer Graphics

  6. Basic Texture Mapping • A texture is simply an image (or a procedure for generating an image), with a 2D co-ordinate system. • Each 3D object is parametrized in 2D texture space. • Screen pixels map to part of an object’s surface and that part of the surface maps to a portion of the texture. • Can be visualized as wrapping an image around an object. Advanced Computer Graphics

  7. Texture Coordinates • Each point on an object needs to have associated texture coordinates: • Polygon: Assign co-ordinates to each vertex. Commercial modelling systems use a variety of projections: spherical, cylindrical, planar to assign texcoords over an entire object. • Plane: Give -axis and -axis directions in the plane. • Cylinder: One axis goes up the cylinder, the other axis around. • Surface: Assign each parameter of a surface to and . (e.g. ) Advanced Computer Graphics

  8. Texture Issues • Sliding - The texture can be translated, rotated and scaled relative to a surface by an affine co-ordinate transformation of . • Seams - If the texture joins without visual discontinuity across opposite edges then repetition can be used to cover an entire object with a single small texture. • Interpolation - During polygon scan conversion care must be taken in interpolating texture co-ordinates. Have to compensate for perspective projection so that the texture is correctly foreshortened. • Aliasing – like all discrete techniques, texture maps suffer from sampling problems. Advanced Computer Graphics

  9. Sampling • Basic approach assumes square texel (texture element) geometry. This produces poor visual results. • Alternative: Treat each texel (texture element) in a texture map as an (r,g,b) value at a point. • A projected pixel may: Cover Several Texels Fall between Texels (oversampling) (undersampling) Advanced Computer Graphics

  10. Handling UnderSampling • The texture co-ordinates of the pixel’s centre are found. • The value at this point in the texture map is a combination of surrounding texels. • Interpolation Methods: • Nearest neighbour: the pixel value is that of the nearest texel. [Fast with many artefacts] • Bilinear reconstruction: the pixel value is the weighted mean of the surrounding texels. [Reasonably fast but blurry] • Biquadratic reconstruction: use a quadratic function of distance to weight the mean [slower, good results] • Bicubic reconstruction [even slower, slightly better results] Advanced Computer Graphics

  11. Handling OverSampling • There are several solutions if the pixel covers a large area of the texture: • Basic Area: Texels are treated as rectangles. Their contribution is weighted by the texel area covered by a pixel. • Filters: A filter (e.g. Gaussian) is used, centred on the pixel centre. Can be very expensive if a single pixel covers a large area of the texture map. • Multi-resolution Textures: Store multiple versions of the same texture at different resolutions. Use interpolation between maps to get pixel values. • MIP Maps (Multum in Parvo – many things in a small space) are an efficient way to store these textures. Advanced Computer Graphics

  12. Summary • What can a texture map modify? • Any, or all, of the colour components • Transparency • Reflectivity • Decaling (blend texture with the object’s colour) • Problems: • Veneer Effect: textures appear to be wall-papered onto the surface. Looks unrealistic in carved objects. • Seams: The match between the shape of a texture (rectangular) and object may cause visible distortion and seams. Classic case: a globe. • Bumpy surfaces: A lot of texture is caused by bumps on the surface. Advanced Computer Graphics

  13. Bump Mapping • The surface normal is used in calculating both diffuse and specular reflection. • Bump mapping modifies the direction of the surface normal so that the surface appears more or less bumpy. • A 2D function (bump map) can be used to vary the surface normal smoothly across the plane. • But bump mapping doesn’t change the object’s silhouette. • Displacement mapping fixes this by actually adjusting the position of vertices in polygonal fragments but it is very expensive. Advanced Computer Graphics

  14. Solid Textures • Texture mapping applies a 2D texture to a surface • Solid textures have colour defined for every point in space • Permits the modelling of objects that appear to be carved from a solid material (e.g. wood, marble). • Simplifies the mapping to texture space. • However, creating 3D texture maps cannot be done by hand. It requires procedural textures (e.g. fractals). From Perlin, K. “An Image Synthesizer”, SIGGRAPH 1985 Advanced Computer Graphics

  15. Simple Texture Mapping in OpenGL • setup: • glTexImage2D(GL_TEXTURE_2D, level, components, width, height, border, format, type, image); • Texture pattern is stored in a width x height array image with type array elements and components colour depth. level and border give finer control associated with MIP-mapping and joining of textures. • Example: • glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, my_image); • A 512x512 RGB texture with 8 bits of resolution for each of 3 colours and no special features. • coordinates: • glTexCoord3f(u, v); associates texture coordinates with a vertex. Advanced Computer Graphics

More Related