Skip to content
lsl.devlsl.devLSL Dev

Textures & Materials

Each face of a prim has its own surface. The original (Blinn-Phong) system combines a diffuse texture, color, alpha, normal and specular maps. PBR materials, based on glTF, use base color, normal, metallic-roughness and emissive maps, and can be overridden per face.

The two systems are set separately. Blinn-Phong texture repeats, offsets and rotation are set with PRIM_TEXTURE, PRIM_NORMAL and PRIM_SPECULAR; PBR transforms are set with the PRIM_GLTF_* rules or glTF overrides.

Shape, light, glow and other prim properties live under Prims; texture animation under Effects.

Concepts

Functions and events

voidllSetTexture(string texture, integer face)
voidllSetLinkTexture(integer link, string texture, integer face)
voidllSetColor(vector color, integer face)
voidllSetAlpha(float alpha, integer face)
voidllSetRenderMaterial(string material, integer face)
voidllSetLinkGLTFOverrides(integer link, integer face, list params)
voidllSetLinkPrimitiveParamsFast(integer link, list rules)
integerllSetPrimMediaParams(integer face, list params)
eventchanged(integer changes)

PBR materials

Setting a render material clears most PRIM_GLTF_* properties on the face, except repeats, offsets and rotation.

Media on a prim

Media functions return a STATUS_* code (PrimMediaError) detailing success or failure.

Scripting Details

voidllSetTexture(string texture, integer face)
Applies the Blinn-Phong diffuse texture to face of the prim.
voidllSetLinkTexture(integer link, string texture, integer face)
Applies texture (UUID or inventory name) to face of the linked prim link.
stringllGetTexture(integer face)
Returns a string representing the Blinn-Phong diffuse texture on face (returns the inventory name if it is a texture in the prim's inventory, or its key UUID otherwise).
voidllScaleTexture(float u, float v, integer face)
Sets the diffuse texture horizontal u and vertical v scales (repeats) on the specified face of the prim. Setting face to ALL_SIDES updates all sides. Negative scale values flip the texture.
voidllOffsetTexture(float u, float v, integer face)
Sets the texture horizontal (u) and vertical (v) offsets for the chosen face. If face is ALL_SIDES, offsets all faces.
voidllRotateTexture(float angle, integer face)
Sets the texture rotation of face to the specified angle (in radians). If face is ALL_SIDES, rotates the texture on all faces.
vectorllGetTextureScale(integer face)
Returns a vector containing the texture scales of face in the X and Y components (Z is unused).
vectorllGetTextureOffset(integer face)
Returns a vector containing the texture offsets of face in the X (horizontal U) and Y (vertical V) components (Z is unused).
floatllGetTextureRot(integer face)
Returns a float representing the texture rotation angle (in radians) on face.
voidllSetColor(vector color, integer face)
Sets the Blinn-Phong diffuse RGB color of face. If face is ALL_SIDES, applies the color to all faces.
vectorllGetColor(integer face)
Returns the Blinn-Phong RGB color vector of face (values between 0.0 and 1.0). If face is ALL_SIDES, returns the mean average of all faces.
voidllSetLinkColor(integer link, vector color, integer face)
Sets the Blinn-Phong diffuse RGB color of face on the linked prim link.
voidllSetAlpha(float alpha, integer face)
Sets the diffuse texture alpha (opacity) of face. If face is ALL_SIDES, applies to all faces. Values are clamped between 0.1 and 1.0 (where 1.0 is fully opaque).
floatllGetAlpha(integer face)
Returns a float representing the Blinn-Phong alpha (transparency) of face. If face is ALL_SIDES, returns the mean average of all faces.
voidllSetLinkAlpha(integer link, float alpha, integer face)
Sets the Blinn-Phong alpha (transparency) of face on the linked prim link.
voidllSetRenderMaterial(string material, integer face)
Applies material (UUID or inventory name) to face of the prim. Note: This clears most PRIM_GLTF_* properties on the face except for repeats, offsets, and rotation.
voidllSetLinkRenderMaterial(integer link, string material, integer face)
Applies material (UUID or inventory name) to face of the linked prim link. Note: This clears most PRIM_GLTF_* properties on the face except for repeats, offsets, and rotation.
stringllGetRenderMaterial(integer face)
Returns a string representing the render material on face (returns the inventory name if it is in the prim's inventory, or its key UUID otherwise).
integerllIsLinkGLTFMaterial(integer link, integer face)
Checks the specified face on the linked prim link. Returns TRUE if the face material is a PBR render material, or FALSE if it uses Blinn-Phong diffuse textures.
voidllSetLinkGLTFOverrides(integer link, integer face, list params)
Sets or removes individual GLTF override parameters specified by params on face of the linked prim link.
voidllSetTextureAnim(integer mode, integer face, integer sizex, integer sizey, float start, float length, float rate)
Animates the texture on face of the prim by setting its scale and offset. mode defines options, sizex/sizey define frames, start defines the start frame/angle, length defines duration, and rate defines playback speed.
voidllSetLinkTextureAnim(integer link, integer mode, integer face, integer sizex, integer sizey, float start, float length, float rate)
Animates the texture on face of the linked prim link by setting the scale and offset according to mode. Parameters sizex/sizey define frames, start defines the start frame/angle, length defines duration, and rate defines playback speed.
integerllSetPrimMediaParams(integer face, list params)
Sets the media parameters specified by params on the designated face of the prim. Returns an integer STATUS_* flag detailing success or failure.
listllGetPrimMediaParams(integer face, list params)
Returns a list containing the media parameters of the specified face, retrieved in the order requested by params. Returns an empty list if no media exists on the face.
integerllClearPrimMedia(integer face)
Deletes the media and clears all parameters from the specified face. Returns an integer STATUS_* flag detailing the success or failure of the operation.
integerllSetLinkMedia(integer link, integer face, list params)
Sets the media parameters specified by params on face of the linked prim link without a script delay. Returns an integer STATUS_* flag detailing success or failure.
listllGetLinkMedia(integer link, integer face, list params)
Returns a list containing the media parameters of the specified face on the linked prim link, retrieved in the order requested by params.
integerllClearLinkMedia(integer link, integer face)
Deletes the media and clears all parameters from the given face on the linked prim. Returns an integer STATUS_* flag detailing the success or failure of the operation.

Additional

Constant groups PrimTexgen 2AlphaMode 4PrimBump 18PrimShiny 4GLTFOverride 8GLTFAlphaMode 3ReflectionProbeType 3PrimMediaParam 15PrimMediaControl 2PrimMediaPerm 4PrimMediaError 8

See also SL Wiki LSL TextureSL Wiki LSL ColorSL Wiki LSL AlphaSL Wiki GlTFFeature EffectsCategory Prim MediaCategory MediaSL Wiki LSL Prim MediaPage Guide: texture coordinates from pixelsPlanned Guide: Blinn-Phong and PBR offsets, repeats and rotationPlanned Guide: PBR materials and glTF overrides