User:jenna Huntsman

From Second Life Wiki
Revision as of 03:39, 18 April 2022 by Jenna Huntsman (talk | contribs) (Created page with "thumb|Jenna Huntsman = Intro = I'm a hobbyist scripter. = Projects = == LSL == My Marketplace Store. = Code Snippets = == sRGB EOTF == {{LSL...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

thumb|Jenna Huntsman

Intro

I'm a hobbyist scripter.

Projects

LSL

My Marketplace Store.

Code Snippets

sRGB EOTF

Summary

Function: vector srgb_eotf( vector color, float gamma );

Converts a gamma-encoded color value to linear space. Useful when dealing with lights (as these expect a non-gamma-encoded color).
Returns a vector

• vector color
• float gamma

Specification

vector srgb_eotf(vector color, float gamma) //To convert from regular LSL colour to light colour, gamma value should be 2.4
{ //Conversion from gamma-encoded sRGB space to linear space. Credit: Jenna Huntsman, Christopher J. Howard
    vector low = color / 12.92;
    vector high = <llPow((color.x + 0.055)/1.055,gamma), llPow((color.y + 0.055)/1.055, gamma), llPow((color.z + 0.055)/1.055, gamma)>;
    return mix(low, high, step(<0.04045,0.04045,0.04045>, color));
}

Examples

vector LampCol = <1,0.74510,0.47451>; //3200 kelvin
llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POINT_LIGHT,1,srgb_eotf(LampCol,2.4),1,20,0,PRIM_GLOW,ALL_SIDES,1,PRIM_COLOR,ALL_SIDES,LampCol,1,PRIM_FULLBRIGHT,ALL_SIDES,1]);
//Set light source colour and prim colour to same colour; despite taking different input values.


Random Notes

I be a placeholder. At least for now.