About me

Vladimir Nabokov

Books
Programming
Biochemistry
Aim | Communicate

Search
 


 

 

   
Letters from Terra - Life in water warmed by sunlight
 
 

     
 
 

     
The latest incarnation of my 3D engine, with some nice texture mapping - click for more Screenshots
 
 
     

The task, then, is to produce an engine where by polygons can be plotted, the colours originating from a stored texture that is linked to my images engine in the usual way. The mapper must be capable of handling any permutation of polygon; the diagram below demonstrates the function of a Texture Mapper. In each case, the image with vertexes assigned A, B, C and D is mapped onto the quadrilateral polygons, the vertexes arranged in different configurations.

The function of the texture mapper - the original image must be manipulated onto the target polygons, each vertex remaining in the same position

Originally, I planned to use any size of image for texture mapping, allowing many different textures to be taken from one large image; but it soon became apparent that for the very fast, non floating point instructions that were necessary for the engine, it was far easier to have each texture a set size, specifically a power of two (I gather this is the same system that is employed in commercial software), images of 128x128. The solid polygons drawn in the previous engine used one routine to process the polygons, and another that drew the horizontal lines that constituted the polygons in the graphical memory. Hence, the texture mapper was to work on the same principle: a single routines was required, that would draw successsive horizontal lines on the polygon, filling in the texture as the polygon was descended. Central to the concept of texture mapping is that one horizontal line on the polygon can trace another line across the texture that is plotted; for each pixel of the polygon that is plotted, that pixel is sourced from the texture, and the line of the polygon drawn represents another line drawn across the texture, not necessarily horizontal. Hence, if the line drawing procedure (Texline) is given the x and y coordinates that represent the locations on the texture to begin and terminated plotting, as well as the x and y coordinates of the line being drawn on the screen, the procedure must be capable of producing a linear transition from the starting x and y coord to the finishing position, incrementing the current texture 'sampling' position as it does so. In this way, the lines that constitute the polygon as it appears on the screen are resampled from the texture image; and the specification defined for accurate texture mapping, that is that the edges of the texture remain attatched to the same edge of the polygon for all permutations, is satisfied; if the quotients for the varying of the sample x and y are accurately calucluated, when the horizontal scan line of the polygon is traversed, the edge of the texture should also be reached.

Back to previous page | Next Page

 
 
Letters from Terra | Updated 15th December 2004 | By Jonathan Ayling