Jump to content
You are about to reply to a thread that has been inactive for 72 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Posted

So have this script and the colours are just not changing i assume maybe the new PBR system or whatever is messing with it? it's for an object that only has all sides no extra faces

 

// Linear interpolation function
vector lerp(vector start, vector end, float t)
{
    return start + (end - start) * t;
}

// Color transition palette (green -> yellow -> orange -> red)
list colorPalette = [
    <0.0, 1.0, 0.0>,    // Green
    <1.0, 1.0, 0.0>,    // Yellow
    <1.0, 0.5, 0.0>,    // Orange
    <1.0, 0.0, 0.0>     // Red
];

integer currentColorIndex = 0;
integer nextColorIndex = 1;
float transitionTime = 0.4;  // Time (in seconds) to complete one color transition
float elapsedTime = 0.0;

default
{
    state_entry()
    {
        llSetTimerEvent(0.1); // Start the timer to update every 0.1 seconds
    }

    timer()
    {
        // Calculate the transition percentage
        float percentage = elapsedTime / transitionTime;

        // Get the current and next color vectors
        vector currentColor = llList2Vector(colorPalette, currentColorIndex);
        vector nextColor = llList2Vector(colorPalette, nextColorIndex);

        // Interpolate between the two colors
        vector interpolatedColor = lerp(currentColor, nextColor, percentage);

        // Apply the color to the prim (face 0 in this case)
        llSetPrimitiveParams([PRIM_COLOR, -1, interpolatedColor, 1.0]);

        // Increment the elapsed time
        elapsedTime += 0.1;

        // If we've reached or passed the transition time, move to the next color
        if (elapsedTime >= transitionTime)
        {
            // Reset the elapsed time
            elapsedTime = 0.0;

            // Update the current and next color indices
            currentColorIndex = nextColorIndex;
            nextColorIndex = (nextColorIndex + 1) % llGetListLength(colorPalette); // Loop back to the start
        }
    }
}
 

Posted

PBR materials can't be tinted with PRIM_COLOR, it applies only to classic materials.

If your object has a proper material set (as in, the textures don't come from PBR overrides) this should work for changing the color for both classic and PBR materials at the same time. Replace your existing llSetPrimitiveParams line.

llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_COLOR, -1, interpolatedColor, 1.0,
	PRIM_GLTF_BASE_COLOR, -1, "", "", "", "", llsRGB2Linear(interpolatedColor), "", "", "", ""]);

See PRIM_GLTF_BASE_COLOR on the wiki for details; you must use llsRGB2Linear on the color for PBR to make them match with classic ones.

  • Thanks 1
You are about to reply to a thread that has been inactive for 72 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...