Retained
Mode: Texturing
By: Jack Hoxley
Written: May 2000
Download:
RM_Texture.Zip
(108kb)
This is the part that makes a
3D scene and at the same time confuses the programmer (sometimes). Texturing
can go from simple through to incredibly complex.
Texturing is the process of adding
an image or picture to an object in 3D-space with the intention of making it
look more life like or more detailed. Typically these textures are generic patterns,
such as a brick wall, concrete road section etc... When applied to the object
correctly it gives the impression that the object is that item (a brick wall
for example).
There are various things that
you should bare in mind when drawing and programming their use:
SIZES
Textures must have dimensions of 2^n. The following list are
the ones that you should use; although the scale is infinitely long it is not
advisable to make textures bigger than 256x256.
2; 4; 8; 16; 24; 32; 48; 64; 72; 96; 128; 256; 512 etc.... (There are others
that fit into the middle of these, but this list should be suitable). The dimensions
of the texture dont have to be the same (ie, 128x128) they can be different:
128x256 or 16x512...
Textures need to be limited, they all take up memory - so the less the better.
Also, bigger textures will be processed slower than small ones, so only make
them as big as they need to be.
LIGHTING
Lighting affects the final colour of a textured primative. If the texture
is blue and the light is red you will get an overall purple colour. Remember
this if you find that you're textures aren't appearing quite right. Also, the
default colour of the object will interfere with the overall colour; if the
primative (without textures) is pink the texture will be a slight shade of pink.
To get over this particular effect, make the primative's base colour white.
RENDER STYLE
The way the texture is rendered is very important as it affects the speed and
visual quality of the image. There are three different ways of rendering textures
in retained mode; Nearest - this is the fastest but also the worst looking.,
Linear - this looks good and is slightly slower, MipMaping - this is much more
complicated, but has little speed decrease for better detail. It involves changing
the textures detail the further away from the camera it is; ie, a long way-away
it is very low resolution, very close up it will use a high resolution texture.
This is done by storing X amount of textures drawn by you; each one the next
size down from the previous one (128-64-32-16-8-4-2 etc...) and Direct3D switches
them as it sees fit.
I suggest that you download the
source code for this tutorial from t he top of the page, or from the downloads
page. It will be much easier for you to see the code working than reading
it from the internet.
|