AlchemyViewer / Alchemy

Alchemy is a Second Life compatible viewer striving to be at the forefront of stability, performance, and technological advancement in the open-source metaverse viewer field.
https://www.alchemyviewer.org
GNU Lesser General Public License v2.1
26 stars 14 forks source link

[Bug]: Colour Picker LSL mode incorrectly reports gamma-corrected colour #104

Open Jenna-Huntsman opened 2 weeks ago

Jenna-Huntsman commented 2 weeks ago

Environment

Alchemy Test 7.1.9.57822 (64bit) Release Notes

You are at 67.1, 97.1, 17.3 in Mi Tesoro Island located at simhost-0ef7ab5905a34cba4.agni SLURL: http://maps.secondlife.com/secondlife/Mi%20Tesoro%20Island/67/97/17 (global coordinates 201283.0, 358497.0, 17.3) Second Life Server 2024-07-22.10048683488 Release Notes

CPU: AMD Ryzen 7 5800X3D 8-Core Processor (3552.28 MHz) Memory: 31992 MB Concurrency: 16 OS Version: Linux 6.10.6-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Aug 19 14:09:30 UTC 2024 x86_64 Graphics Card Vendor: AMD Graphics Card: AMD Radeon RX 6900 XT (radeonsi, navi21, LLVM 18.1.6, DRM 3.57, 6.10.6-200.fc40.x86_64)

OpenGL Version: 4.6 (Core Profile) Mesa 24.1.6

Window size: 3840x2083 Font Size Adjustment: 96pt UI Font: Default Monospace Font: Default Chat Font: SansSerif Script Font: Monospace UI Scaling: 1.5 Draw distance: 128m Bandwidth: 3000kbit/s LOD factor: 2.125 Render quality: 5 Texture memory: 16384MB Texture cache: 2361MB / 2621MB (90.1% used) Disk cache: 4095MB / 4096MB (100.0% used)

RestrainedLove API: RLV v3.4.3 / RLVa v2.5.0.57822 libcurl Version: libcurl/7.54.1 OpenSSL/1.1.1w zlib/1.3.1.zlib-ng nghttp2/1.62.1 J2C Decoder Version: OpenJPEG Runtime: 2.4.0 Audio Driver Version: OpenAL, version 1.1 ALSOFT 1.23.1 / OpenAL Community / OpenAL Soft: OpenAL Soft Dullahan: 1.14.0 CEF: 118.4.1+g3dd6078+chromium-118.0.5993.54 Chromium: 118.0.5993.54 LibVLC Version: 3.0.21 Voice Server Version: Vivox 4.10.0000.32327.5fc3fe7c.571099

Compiler Version: GCC 140201 Packets Lost: 1/265072 (0.0%) August 24 2024 11:07:18

Description

Alchemy's colour picker in LSL mode incorrectly reports the gamma-corrected colour, however LSL (linear) RGB is not gamma corrected. Gamma correction should be removed from the colour picker while in LSL mode, so the colours set in the picker will match colours set via a script.

Reproduction steps

  1. Open colour picker, switch to LSL mode and select a colour.
  2. Copy the colour into an LSL script and use the script to set the prim colour to the colour reported by the LSL mode colour picker
  3. Observe that the script will set the prim to another colour.
DarlCat commented 2 weeks ago

This might be related, could you see if clicking on the color again uses the correct color you expect @Jenna-Huntsman ? In this video I am clicking on each saved color twice and the values adjust on the second click. https://github.com/user-attachments/assets/f463a523-1857-4f8b-b24f-4587bc34eee7

Jenna-Huntsman commented 2 weeks ago

This might be related, could you see if clicking on the color again uses the correct color you expect @Jenna-Huntsman ? In this video I am clicking on each saved color twice and the values adjust on the second click. https://github.com/user-attachments/assets/f463a523-1857-4f8b-b24f-4587bc34eee7

I've just tried this, and yes, the value does change.

I may have also figured out that this is limited to PBR materials, as this script demonstrates that the LSL value is reported correctly for Blinn-Phong materials, but incorrect for PBR materials.

vector colPicker = <0.381,0.319,0.319>; //Colour reported by colour picker in LSL mode
vector colLin = <0.11994, 0.08300, 0.08300>; //Expected color.

default
{
    state_entry()
    {
        llSay(0, "Actual: " + (string)colPicker + "\nExpected: " + (string)llsRGB2Linear(colPicker));
        llSetPrimitiveParams([
            PRIM_COLOR,ALL_SIDES,colPicker,1,
            PRIM_GLTF_BASE_COLOR,ALL_SIDES,"","","","",llsRGB2Linear(colPicker),0.970,"","",""
        ]);
    }
}