PBR Colour data is lost when setting PBR overrides
tracked
Kristy Aurelia
Reproduction steps:
- Rezz a box
- Put this script into it:
integer AlphaState = 1;
default
{
state_entry()
{
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_RENDER_MATERIAL, ALL_SIDES, "2d45cf07-04ac-64a1-daa7-83f4992f759b"]);
}
touch_end(integer num_detected)
{
list faceData = llGetLinkPrimitiveParams(0, [PRIM_GLTF_BASE_COLOR, 0]);
llOwnerSay("Colour Received: \"" + llList2String(faceData, 4) + "\"");
if (AlphaState == 1)
{
faceData = llListReplaceList(faceData, [0.0, PRIM_GLTF_ALPHA_MODE_BLEND], 5, 6);
AlphaState = 0;
}
else
{
faceData = llListReplaceList(faceData, [1.0], 5, 5);
AlphaState = 1;
}
llSetLinkPrimitiveParamsFast(0, [PRIM_GLTF_BASE_COLOR, ALL_SIDES] + faceData);
}
}
- The script will turn this box golden
- Touch the box once, observe received colour value being "" and the box vanishing
- Touch the box again, observe received value being "<1.000000, 1.000000, 1.000000>" and the box being silver
Expectation:
One of the following should happen:
- Box should remain gold, and colour value remain ""
- Colour value should always be <1.0, 0.89, 0.616> and not ""
Environment
SL Main grid sim with: Second Life Server 2024-01-19.7590161929
Log In
Maestro Linden
tracked
Maestro Linden
under review
Maestro Linden
Thanks for the report Kristy Aurelia. I think I see the issue: if a PRIM_GLTF_BASE_COLOR override update contains a changed
float alpha
value but attempts to keep vector color
unchanged with the -1 argument, vector color
is incorrectly set to a default tint of <1,1,1>. I believe the issue is specific to the alpha
-color
pair of parameters, as they are stored in the same field internally despite appearing as 2 distinct parameters in the LSL API.This is a modified version of the script with a bit more debug output. If the two commented-out
faceData
assignment lines replace the lines above them, such that alpha
remains at the default and only gltf_alpha_mode
is updated, then color
is correctly preserved as golden after each transition: integer AlphaState = 1;
string baseColor;
default
{
state_entry()
{
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_RENDER_MATERIAL, ALL_SIDES, "2d45cf07-04ac-64a1-daa7-83f4992f759b"]);
baseColor = llList2Json(JSON_ARRAY, llGetPrimitiveParams([PRIM_GLTF_BASE_COLOR, 0]));
llOwnerSay("Initial value: PRIM_GLTF_BASE_COLOR on face 0 now reads: "
+ baseColor);
}
touch_end(integer num_detected)
{
list faceData = llGetLinkPrimitiveParams(0, [PRIM_GLTF_BASE_COLOR, 0]);
llOwnerSay("Colour Received: \"" + llList2String(faceData, 4) + "\"");
if (AlphaState == 1)
{
faceData = llListReplaceList(faceData, [0.0, PRIM_GLTF_ALPHA_MODE_BLEND], 5, 6);
//faceData = llListReplaceList(faceData, [PRIM_GLTF_ALPHA_MODE_BLEND], 6, 6);
AlphaState = 0;
}
else
{
faceData = llListReplaceList(faceData, [1.0], 5, 5);
//faceData = llListReplaceList(faceData, [PRIM_GLTF_ALPHA_MODE_OPAQUE], 6, 6);
AlphaState = 1;
}
llOwnerSay("Setting [PRIM_GLTF_BASE_COLOR, ALL_SIDES] + " + llList2Json(JSON_ARRAY, faceData));
llSetLinkPrimitiveParamsFast(0, [PRIM_GLTF_BASE_COLOR, ALL_SIDES] + faceData);
string newBaseColor = llList2Json(JSON_ARRAY, llGetPrimitiveParams([PRIM_GLTF_BASE_COLOR, 0]));
if(newBaseColor != baseColor)
{
llOwnerSay("After touch: PRIM_GLTF_BASE_COLOR on face 0 has changed to: "
+ llList2Json(JSON_ARRAY, llGetPrimitiveParams([PRIM_GLTF_BASE_COLOR, 0])));
}
else
{
llOwnerSay("After touch: PRIM_GLTF_BASE_COLOR is unchanged");
}
baseColor = newBaseColor;
}
}