Sets or removes individual overrides applied to a PBR texture on a face

Syntax

void llSetLinkGLTFOverrides( integer link, integer face, list params );

Parameters

integer link
Link number (0: unlinked, 1: root prim, >1: child prims and seated avatars) or a LINK_* flag
integer face
face number or ALL_SIDES
list params
List of overrides and override values.

If face is ALL_SIDES then the function works on all sides.

Constants

FlagDescription
LINK_ROOT1refers to the root prim in a multi-prim linked set[1]
LINK_SET-1refers to all prims
LINK_ALL_OTHERS-2refers to all other prims
FlagDescription
LINK_ALL_CHILDREN-3refers to all children, (everything but the root)
LINK_THIS-4refers to the prim the script is in

Parameters

parametervaluetypedescription
OVERRIDE_GLTF_BASE_COLOR_FACTOR1vectorSet the tinting color used for the base color. Color is specified in linear RGB. Use llsRGB2Linear to convert colors from Blinn-Phong to PBR.
OVERRIDE_GLTF_BASE_ALPHA2floatSets the alpha for the face(s). Only impacts the rendering when the alpha mode is set to PRIM_GLTF_ALPHA_MODE_BLEND.
OVERRIDE_GLTF_BASE_ALPHA_MODE3integerSet the alpha mode on the face(s). Must be one of the valid blend modes
GLTF Alpha Modevaluedescription
PRIM_GLTF_ALPHA_MODE_OPAQUE0Ignore the alpha value and render the material as opaque.
PRIM_GLTF_ALPHA_MODE_BLEND1Render the material with transparency determined by the alpha value. Blending is done in linear color space. As is the case for Blinn-Phong as well, this mode suffers from depth sorting and performance issues. Use alpha mask instead when possible.
PRIM_GLTF_ALPHA_MODE_MASK2Render the material as fully opaque where the alpha value is greater than the alpha cutoff, and otherwise render the material as fully transparent.
OVERRIDE_GLTF_BASE_ALPHA_MASK4floatSets the alpha cutoff level on the face(s) when alpha mode is set to mask.
OVERRIDE_GLTF_BASE_DOUBLE_SIDED5integerIf set to TRUE then the texture on the face(s) will be rendered as double sided.
OVERRIDE_GLTF_METALLIC_FACTOR6floatAdjusts the metallic factor on the specified face(s). Value should be between 0 and 1.
OVERRIDE_GLTF_ROUGHNESS_FACTOR7floatAdjust the roughness factor on the specified face(s). Value should be between 0 and 1.
OVERRIDE_GLTF_EMISSIVE_FACTOR8vectorSet the tint used for the emissive texture on the face(s). Note that this is specified in linear RGB.

Passing an empty string ("") as the override value will clear that override.

Caveats

Examples

Toggle alpha on\off

integer toggle;
default
{
    touch_start(integer num_detected)
    {
        toggle=!toggle;
        llSetLinkGLTFOverrides( LINK_THIS, 0, [
            OVERRIDE_GLTF_BASE_ALPHA_MODE, PRIM_GLTF_ALPHA_MODE_BLEND,
            OVERRIDE_GLTF_BASE_ALPHA, toggle]);
    }
}

Notes

Link Numbers

Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.

When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating all avatars first.

Counting Prims & Avatars

There are two functions of interest when trying to find the number of prims and avatars on an object.

integer GetPrimCount() { //always returns only the number of prims
    if(llGetAttached())//Is it attached?
        return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
    return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}

See llGetNumberOfPrims for more about counting prims and avatars.

Errata

If a script located in a child prim erroneously attempts to access link 0, it will get or set the property of the linkset's root prim. This bug (BUG-5049) is preserved for broken legacy scripts.

See also

Functions

Articles

Footnotes

  1. LINK_ROOT does not work on single prim objects. Unless there is an avatar sitting on the object.