3D Lingo Dictionary > T-Z > textureTransform |
![]() ![]() ![]() |
textureTransform
Syntax
member(whichCastmember
).shader(whichShader
).textureTransform member(whichCastmember
).model(whichModel
).shader.textureTransform member(whichCastmember
).model(whichModel
).shaderList{[index]}.textureTransform
Description
3D #standard
shader property; provides access to a transform which modifies the texture coordinate mapping of the first texture layer of the shader. Manipulate this transform to tile, rotate, or translate the texture before applying it to the surface of the model. The texture itself remains unaffected; the transform merely modifies how the shader applies the texture. The textureTransform
property is applied to all texture coordinates regardless of the textureMode
property setting. This is the last modification of the texture coordinates before they are sent to the renderer. The textureTransform
property is a matrix that operates on the texture in textureImage space. TextureImage space is defined to exist only on the X,Y plane.
To tile the image twice along its horizontal axis, use shaderReference.textureTransform.scale(0.5, 1.0, 1.0)
. Scaling on the Z axis is ignored.
To offset the image by point(xOffset,yOffset)
, use shaderReference.textureTransform.translate(xOffset,yOffset,0.0)
. Translating by integers when the shader'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 shaderReference.textureTransform.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 the X and Y axes are ignored.
Just as with a model's transform, textureTransform
modifications are layerable. To rotate the texture 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 textureTransform
is similar to the shader's wrapTransform
property with the following exceptions. It is applied in 2d image space rather than 3d world space. As a result, only rotations about the Z axis and translations and scales on X and Y axes are effective. The transform is applied regardless of the shaderReference.textureMode
setting. The wrapTransform
, by comparison, is only effective when the textureMode
is #wrapPlanar
, #wrapCylindrical
, or #wrapSpherical
.
Example
This statement shows the textureTransform
of the first texture in the first shader used by the model gbCyl3.
put member("Scene").model("gbCyl3").shader.textureTransform -- 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 first texture used by the shader named gbCyl3. If the textureRepeat
property of gbCyl3 is set to TRUE
, four copies of the texture will be tiled across the shader.
member("Scene").shader("gbCyl3").textureTransform.scale = vector(0.5, 0.5, 1)
This statement rotates the first texture used by the shader gbCyl3 by 90° from vector(0, 0, 0).
member("Scene").shader("gbCyl3").textureTransform.rotation = vector(0, 0, 90)
![]() ![]() ![]() |