# Textures & Materials

> Everything on a prim face: textures, colors and alpha, Blinn-Phong and PBR materials, media.

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`](/constants/PRIM_TEXTURE/), [`PRIM_NORMAL`](/constants/PRIM_NORMAL/) and [`PRIM_SPECULAR`](/constants/PRIM_SPECULAR/); PBR transforms are set with the `PRIM_GLTF_*` rules or [glTF overrides](/functions/llSetLinkGLTFOverrides/).

Shape, light, glow and other prim properties live under [Prims](/features/prims/); texture animation under [Effects](/features/effects/).

## Concepts

- Textures: [set one by inventory name or key](/functions/llSetTexture/), [on any prim](/functions/llSetLinkTexture/), and [read it back](/functions/llGetTexture/)
  - Adjust [repeats](/functions/llScaleTexture/), [offset](/functions/llOffsetTexture/) and [rotation](/functions/llRotateTexture/); the [mapping mode](/constants/PRIM_TEXGEN/) sets how repeats are measured
- Colors are vectors from 0.0 to 1.0, [set per face](/functions/llSetColor/)
  - [Alpha](/functions/llSetAlpha/) runs from 0.0 (invisible) to 1.0
  - The [alpha mode](/constants/PRIM_ALPHA_MODE/) sets how transparent textures are drawn
- Blinn-Phong materials: [normal](/constants/PRIM_NORMAL/) and [specular](/constants/PRIM_SPECULAR/) maps, [shininess and bump presets](/constants/PRIM_BUMP_SHINY/) add surface detail to the legacy system
  - [Full bright](/constants/PRIM_FULLBRIGHT/) and [glow](/constants/PRIM_GLOW/) change how a face is lit
- PBR materials: [apply a material asset](/functions/llSetRenderMaterial/) to faces, or [override parts of it](/functions/llSetLinkGLTFOverrides/) (base color, alpha, metallic, roughness, emissive) without replacing it
  - [Check whether a face uses PBR](/functions/llIsLinkGLTFMaterial/)
- [Reflection probes](/constants/PRIM_REFLECTION_PROBE/) control what PBR surfaces reflect nearby
- [Frame animation and scrolling](/functions/llSetTextureAnim/) are covered under [Effects](/features/effects/)
- A face can [show a web page](/functions/llSetPrimMediaParams/); media settings control the URL, size, controls and who may interact
- The [`changed`](/events/changed/) event reports [color](/constants/CHANGED_COLOR/), [material](/constants/CHANGED_RENDER_MATERIAL/) and [media](/constants/CHANGED_MEDIA/) changes

## Functions and events

- `void` [`llSetTexture`](/functions/llSetTexture/) `(string texture, integer face)`
- `void` [`llSetLinkTexture`](/functions/llSetLinkTexture/) `(integer link, string texture, integer face)`
- `void` [`llSetColor`](/functions/llSetColor/) `(vector color, integer face)`
- `void` [`llSetAlpha`](/functions/llSetAlpha/) `(float alpha, integer face)`
- `void` [`llSetRenderMaterial`](/functions/llSetRenderMaterial/) `(string material, integer face)`
- `void` [`llSetLinkGLTFOverrides`](/functions/llSetLinkGLTFOverrides/) `(integer link, integer face, list params)`
- `void` [`llSetLinkPrimitiveParamsFast`](/functions/llSetLinkPrimitiveParamsFast/) `(integer link, list rules)`
- `integer` [`llSetPrimMediaParams`](/functions/llSetPrimMediaParams/) `(integer face, list params)`
- `event` [`changed`](/events/changed/) `(integer changes)`

## [PBR materials](https://wiki.secondlife.com/wiki/Category:GlTF)

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

## [Media on a prim](https://wiki.secondlife.com/wiki/Category:LSL_Prim_Media)

Media functions return a `STATUS_*` code ([`PrimMediaError`](/constants/groups/PrimMediaError/)) detailing success or failure.

## Scripting Details

- `void` [`llSetTexture`](/functions/llSetTexture/) `(string texture, integer face)`: Applies the Blinn-Phong diffuse texture to face of the prim.
- `void` [`llSetLinkTexture`](/functions/llSetLinkTexture/) `(integer link, string texture, integer face)`: Applies texture (UUID or inventory name) to face of the linked prim link.
- `string` [`llGetTexture`](/functions/llGetTexture/) `(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).
- `void` [`llScaleTexture`](/functions/llScaleTexture/) `(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.
- `void` [`llOffsetTexture`](/functions/llOffsetTexture/) `(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.
- `void` [`llRotateTexture`](/functions/llRotateTexture/) `(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.
- `vector` [`llGetTextureScale`](/functions/llGetTextureScale/) `(integer face)`: Returns a vector containing the texture scales of face in the X and Y components (Z is unused).
- `vector` [`llGetTextureOffset`](/functions/llGetTextureOffset/) `(integer face)`: Returns a vector containing the texture offsets of face in the X (horizontal U) and Y (vertical V) components (Z is unused).
- `float` [`llGetTextureRot`](/functions/llGetTextureRot/) `(integer face)`: Returns a float representing the texture rotation angle (in radians) on face.
- `void` [`llSetColor`](/functions/llSetColor/) `(vector color, integer face)`: Sets the Blinn-Phong diffuse RGB color of face. If face is ALL_SIDES, applies the color to all faces.
- `vector` [`llGetColor`](/functions/llGetColor/) `(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.
- `void` [`llSetLinkColor`](/functions/llSetLinkColor/) `(integer link, vector color, integer face)`: Sets the Blinn-Phong diffuse RGB color of face on the linked prim link.
- `void` [`llSetAlpha`](/functions/llSetAlpha/) `(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).
- `float` [`llGetAlpha`](/functions/llGetAlpha/) `(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.
- `void` [`llSetLinkAlpha`](/functions/llSetLinkAlpha/) `(integer link, float alpha, integer face)`: Sets the Blinn-Phong alpha (transparency) of face on the linked prim link.
- `void` [`llSetRenderMaterial`](/functions/llSetRenderMaterial/) `(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.
- `void` [`llSetLinkRenderMaterial`](/functions/llSetLinkRenderMaterial/) `(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.
- `string` [`llGetRenderMaterial`](/functions/llGetRenderMaterial/) `(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).
- `integer` [`llIsLinkGLTFMaterial`](/functions/llIsLinkGLTFMaterial/) `(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.
- `void` [`llSetLinkGLTFOverrides`](/functions/llSetLinkGLTFOverrides/) `(integer link, integer face, list params)`: Sets or removes individual GLTF override parameters specified by params on face of the linked prim link.
- `void` [`llSetTextureAnim`](/functions/llSetTextureAnim/) `(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.
- `void` [`llSetLinkTextureAnim`](/functions/llSetLinkTextureAnim/) `(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.
- `integer` [`llSetPrimMediaParams`](/functions/llSetPrimMediaParams/) `(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.
- `list` [`llGetPrimMediaParams`](/functions/llGetPrimMediaParams/) `(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.
- `integer` [`llClearPrimMedia`](/functions/llClearPrimMedia/) `(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.
- `integer` [`llSetLinkMedia`](/functions/llSetLinkMedia/) `(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.
- `list` [`llGetLinkMedia`](/functions/llGetLinkMedia/) `(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.
- `integer` [`llClearLinkMedia`](/functions/llClearLinkMedia/) `(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

- [`llSetLinkPrimitiveParamsFast`](/functions/llSetLinkPrimitiveParamsFast/) — Blinn-Phong face rules
  - [`PRIM_TEXTURE`](/constants/PRIM_TEXTURE/) — Diffuse texture, repeats, offsets and rotation
  - [`PRIM_TEXGEN`](/constants/PRIM_TEXGEN/) — Mapping mode ([`PrimTexgen`](/constants/groups/PrimTexgen/)): [default](/constants/PRIM_TEXGEN_DEFAULT/) or [planar](/constants/PRIM_TEXGEN_PLANAR/)
  - [`PRIM_COLOR`](/constants/PRIM_COLOR/) — Color and alpha, from 0.0 (clear) to 1.0 (solid)
  - [`PRIM_ALPHA_MODE`](/constants/PRIM_ALPHA_MODE/) — [Blend](/constants/PRIM_ALPHA_MODE_BLEND/), [none](/constants/PRIM_ALPHA_MODE_NONE/), [mask](/constants/PRIM_ALPHA_MODE_MASK/) with a cutoff, or [emissive](/constants/PRIM_ALPHA_MODE_EMISSIVE/) ([`AlphaMode`](/constants/groups/AlphaMode/))
  - [`PRIM_NORMAL`](/constants/PRIM_NORMAL/) — Normal map with its own repeats, offsets and rotation
  - [`PRIM_SPECULAR`](/constants/PRIM_SPECULAR/) — Specular map plus color, glossiness and environment
  - [`PRIM_BUMP_SHINY`](/constants/PRIM_BUMP_SHINY/) — Shininess ([`PrimShiny`](/constants/groups/PrimShiny/)) and bump preset ([`PrimBump`](/constants/groups/PrimBump/))
  - [`PRIM_FULLBRIGHT`](/constants/PRIM_FULLBRIGHT/), [`PRIM_GLOW`](/constants/PRIM_GLOW/) — Full-bright rendering and glow intensity
- [`llSetLinkPrimitiveParamsFast`](/functions/llSetLinkPrimitiveParamsFast/) — PBR face rules
  - [`PRIM_RENDER_MATERIAL`](/constants/PRIM_RENDER_MATERIAL/) — The material asset on a face
  - [`PRIM_GLTF_BASE_COLOR`](/constants/PRIM_GLTF_BASE_COLOR/) — Base color, alpha mode ([`GLTFAlphaMode`](/constants/groups/GLTFAlphaMode/)), alpha cutoff and double-sided; colors in linear space
  - [`PRIM_GLTF_NORMAL`](/constants/PRIM_GLTF_NORMAL/) — Normal map
  - [`PRIM_GLTF_METALLIC_ROUGHNESS`](/constants/PRIM_GLTF_METALLIC_ROUGHNESS/) — Occlusion, metallic and roughness
  - [`PRIM_GLTF_EMISSIVE`](/constants/PRIM_GLTF_EMISSIVE/) — Emission tint in linear space
  - [`PRIM_REFLECTION_PROBE`](/constants/PRIM_REFLECTION_PROBE/) — Make the object a reflection probe ([`ReflectionProbeType`](/constants/groups/ReflectionProbeType/)): [box](/constants/PRIM_REFLECTION_PROBE_BOX/), [dynamic](/constants/PRIM_REFLECTION_PROBE_DYNAMIC/) or [mirror](/constants/PRIM_REFLECTION_PROBE_MIRROR/)
- [`llSetLinkGLTFOverrides`](/functions/llSetLinkGLTFOverrides/) — individual overrides ([`GLTFOverride`](/constants/groups/GLTFOverride/)), such as [`OVERRIDE_GLTF_BASE_COLOR_FACTOR`](/constants/OVERRIDE_GLTF_BASE_COLOR_FACTOR/), [`OVERRIDE_GLTF_METALLIC_FACTOR`](/constants/OVERRIDE_GLTF_METALLIC_FACTOR/), [`OVERRIDE_GLTF_ROUGHNESS_FACTOR`](/constants/OVERRIDE_GLTF_ROUGHNESS_FACTOR/) and [`OVERRIDE_GLTF_EMISSIVE_FACTOR`](/constants/OVERRIDE_GLTF_EMISSIVE_FACTOR/)
- [`llSetPrimMediaParams`](/functions/llSetPrimMediaParams/) and [`llSetLinkMedia`](/functions/llSetLinkMedia/) — media settings ([`PrimMediaParam`](/constants/groups/PrimMediaParam/))
  - [`PRIM_MEDIA_CURRENT_URL`](/constants/PRIM_MEDIA_CURRENT_URL/), [`PRIM_MEDIA_HOME_URL`](/constants/PRIM_MEDIA_HOME_URL/) — Current and home URL
  - [`PRIM_MEDIA_AUTO_PLAY`](/constants/PRIM_MEDIA_AUTO_PLAY/) — Play when a resident can view it
  - [`PRIM_MEDIA_PERMS_INTERACT`](/constants/PRIM_MEDIA_PERMS_INTERACT/) — Who may interact ([`PrimMediaPerm`](/constants/groups/PrimMediaPerm/))
  - Navigation controls: [standard](/constants/PRIM_MEDIA_CONTROLS_STANDARD/) or [mini](/constants/PRIM_MEDIA_CONTROLS_MINI/) ([`PrimMediaControl`](/constants/groups/PrimMediaControl/))
- [`changed`](/events/changed/) — [`CHANGED_COLOR`](/constants/CHANGED_COLOR/), [`CHANGED_TEXTURE`](/constants/CHANGED_TEXTURE/), [`CHANGED_RENDER_MATERIAL`](/constants/CHANGED_RENDER_MATERIAL/), [`CHANGED_MEDIA`](/constants/CHANGED_MEDIA/)

## Constant groups

Constant groups: [PrimTexgen](/constants/groups/PrimTexgen/) (2), [AlphaMode](/constants/groups/AlphaMode/) (4), [PrimBump](/constants/groups/PrimBump/) (18), [PrimShiny](/constants/groups/PrimShiny/) (4), [GLTFOverride](/constants/groups/GLTFOverride/) (8), [GLTFAlphaMode](/constants/groups/GLTFAlphaMode/) (3), [ReflectionProbeType](/constants/groups/ReflectionProbeType/) (3), [PrimMediaParam](/constants/groups/PrimMediaParam/) (15), [PrimMediaControl](/constants/groups/PrimMediaControl/) (2), [PrimMediaPerm](/constants/groups/PrimMediaPerm/) (4), [PrimMediaError](/constants/groups/PrimMediaError/) (8)

## Related

See also: [LSL Texture (Second Life Wiki)](https://wiki.secondlife.com/wiki/Category:LSL_Texture), [LSL Color (Second Life Wiki)](https://wiki.secondlife.com/wiki/Category:LSL_Color), [LSL Alpha (Second Life Wiki)](https://wiki.secondlife.com/wiki/Category:LSL_Alpha), [GlTF (Second Life Wiki)](https://wiki.secondlife.com/wiki/Category:GlTF), [Effects](/features/effects/), [Prim Media](/categories/prim_media/), [Media](/categories/media/), [LSL Prim Media (Second Life Wiki)](https://wiki.secondlife.com/wiki/Category:LSL_Prim_Media), [Guide: texture coordinates from pixels](/guides/texture-coordinates/)
   (planned: Guide: Blinn-Phong and PBR offsets, repeats and rotation)
   (planned: Guide: PBR materials and glTF overrides)

## Related features

- [Prims](/features/prims/)
- [Effects](/features/effects/)

## Categories

- [Prim Appearance](/categories/prim_appearance/)
- [Prim Media](/categories/prim_media/)
- [Media](/categories/media/)

---

From lsl.dev: https://lsl.dev/features/textures/
