Director 3D > Surfaces, Shaders and Textures

Basic creation and control of surfaces/textures

The number of shaders that a model is the same as the number of meshes in the model. Each mesh therefore only supports ONE shader. The best example of this is a box (if you cannot see a "water" type texture on the box below, right click over it and select "Restart" - this is a problem caused if the movie starts while the texture is still loading - more advanced "loading" Lingo scripts can deal with this):

By default a box/cube has 6 meshes – one for each side. Each of these meshes has a shader, which means that each side of the box can be treated as a different material (e.g. a side made from metal, a side made from wood, a side made from glass, etc).

First you need to either create a new texture object or make a reference to an existing texture object.

The Lingo syntax for creating a new texture object is as follows:

newTxtr = member("<which3dMember").newTexture("nameOfTexture", #fromcastmember, member("whichBitmap"))

Here is the custom handler routine we use in the example above - called "Texturize":

This "texturize" custom handler provides a concise method of creating a new texture, shader and applies these to a given model in a given scene.

To set up a shader called "water", we call a texture image from the (image) castmember - water, and apply it to the cube:

texturize("test", "cube", "water", "watershader", rgb(50,25,4), rgb(150,50,10), rgb(255,255,255))

< Previous | Next >

July 2003