BRender Tutorial Guide:6 Texture Mapping

6 Texture Mapping

Loading the Texture Map
Loading the Material
Assigning the Material
8-Bit Colour
Imagine taking a photograph of the bark of a tree and somehow wrapping it around a cylinder to create a 3D image of a tree trunk, or superimposing a 2D image of a brick wall onto a flat rectangular face to make it look like a wall.

Texture mapping attempts to mimic this process. A texture map is a rectangular 2D image (perhaps scanned from a photograph or created using a paint package) that can be mapped onto the surface of a 3D model. The individual elements in a texture map are often called texels. Each of the polygons used in the construction of a model is mapped to a specific area of the texture map by means of texture co-ordinates assigned to the polygon's vertices. Texture co-ordinates are linearly interpolated between vertices in the same way that colour values for the interior of smooth shaded polygons are interpolated between the vertex colours.

Figure 38 Texture Mapping

Texture mapping is by far the most effective way of constructing realistic images. Imagine trying to reproduce the wood grain in your kitchen table or a marble column without using a texture map.

BRTUTOR6.C creates an image of the Earth by superimposing a 2D texture map of the world onto a sphere. Note that a true colour mode has been selected. If you are running BRender under DOS, the following line in the hardware initialisation code selects 320 200, 15-bit true colour:

	screen_buffer = DOSGfxBegin("VESA,W:320,H:200,B:15");

Generated with CERN WebMaker