3D Lingo Dictionary > T-Z > textureTransformList

 

textureTransformList

Syntax

shaderReference .textureTransformList[textureLayerIndex]
member(whichCastmember).shader(ShaderName).textureTransformList[textureLayerIndex]
member(whichCastmember).shader[shaderListIndex].textureTransformList[textureLayerIndex]
member(whichCastmember).model(modelName).shader.textureTransformList[textureLayerIndex]
member(whichCastmember).model(modelName).shaderList[shaderListIndex]. textureTransformList[textureLayerIndex]

Description

3D standard shader property; this property provides access to a transform which modifies the texture coordinate mapping of a texture layer. Manipulate this transform to tile, rotate, or translate a texture image before applying it to the surface of models. The texture itself remains unaffected, the transform merely modifies how the shader applies the texture.

To tile the image twice along its horizontal axis, use textureTransformList[whichTextureLayer].scale(0.5, 1.0, 1.0). Scales in Z will be ignored since images are 2D in nature. Care must be taken to avoid 0.0 scales (even in Z), as that will negate the effect of the entire texture.

To offset the image by point(xOffset,yOffset), use textureTransformList[whichTextureLayer].translate(xOffset,yOffset,0.0). Translating by integers when that texture layer's textureRepeat property is TRUE will have no effect, because the width and height of the texture will be valued between 0.0 and 1.0 in that case.

To apply a rotation to a texture layer, use textureTransformList[whichTextureLayer].rotate(0,0,angle). Rotations around the Z axis are rotated around the (0,0) 2D image point, which maps to the upper left corner of the texture. Rotations about X and Y will be ignored since images are 2D by nature.

Just as with a model's transform, textureTransform modifications are layerable. To rotate the image about a point(xOffset,yOffset) instead of point(0,0), first translate to point(0 - xOffset, 0 - yOffset), then rotate, then translate to point(xOffset, yOffset).

The textureTransformList is similar to the shader wrapTransformList property with the following exceptions.

It is applied in 2D image space rather than 3D world space. As a result, only rotations in Z, and translations and scales in X and Y, are effective.

The transform is applied regardless of the shaderReference.textureModeList[index] setting. The wrapTransform, by comparison, is only effective when the textureMode is #wrapPlanar, #wrapCylindrical, or #wrapSpherical.

Example

This statement shows the textureTransform of the third texture in the first shader used by the model gbCyl3.

put member("scene").model("gbCyl3").shader.textureTransformList[3]
-- transform(1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000)

This statement halves the height and width of the fifth texture used by the shader gbCyl3. If the textureRepeatList[5] value of gbCyl3 is set to TRUE, four copies of the texture will be tiled across the shader.

member("scene").shader("gbCyl3").textureTransformList[5].scale = vector(0.5, 0.5, 1)

This statement rotates the fourth texture used by the shader gbCyl3 by 90° from vector(0, 0, 0).

member("scene").shader("gbCyl3").textureTransformList[4].rotation = vector(0, 0, 90)

These statements rotate the third texture used by the shader gbCyl3 by 90\xb0 around its center, assuming that textureList[3] is a 128x128 sized texture.

s = member("scene").shader("gbCyl3")
s.textureTransformList[3].translate(-64,-64,0)
s.textureTransformList[3].rotate(0,0,90)
s.textureTransformList[3].translate(64,64,0)