|
|
(31 intermediate revisions by one other user not shown) |
Line 1: |
Line 1: |
| [[Put Profile Image here.|thumb|Jenna Huntsman]] | | #REDIRECT [[User:Quinn Elara]] |
| | |
| = Intro =
| |
| | |
| I'm a hobbyist scripter.
| |
| | |
| = Projects =
| |
| | |
| == LSL ==
| |
| | |
| My Marketplace Store.
| |
| | |
| = Code Snippets =
| |
| | |
| == sRGB EOTF ==
| |
| Note that when converting a colour from regular LSL space (sRGB) to linear space for use in a light, it's likely quicker and cleaner to use the internal function [[llsRGB2Linear]]. This is mostly a function that can be used for fun to manipulate the gamma space of colours.
| |
| {{LSL_Function
| |
| |mode=user
| |
| |func=srgb_eotf
| |
| |p1_type=vector|p1_name=color
| |
| |p2_type=float|p2_name=gamma
| |
| |return_type=vector
| |
| |return_value=returns the given gamma-encoded color to non-gamma-encoded (linear) color.
| |
| |func_desc=
| |
| Converts a gamma-encoded color value to linear space. Useful when dealing with lights (as these expect a non-gamma-encoded color).
| |
| |spec=<source lang="lsl2">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));
| |
| }
| |
| | |
| float max(float x, float y)
| |
| { //Return the higher of 2 given values.
| |
| if( y > x ) return y;
| |
| return x;
| |
| }
| |
| | |
| vector mix(vector x, vector y, vector t)
| |
| {
| |
| vector ret;
| |
| ret.x = x.x*(1-t.x) + y.x*t.x;
| |
| ret.y = x.y*(1-t.y) + y.y*t.y;
| |
| ret.z = x.z*(1-t.z) + y.z*t.z;
| |
| return ret;
| |
| }
| |
| | |
| vector step(vector edge, vector x)
| |
| {
| |
| vector ret = <1,1,1>;
| |
| if(x.x < edge.x) ret.x = 0;
| |
| if(x.y < edge.y) ret.x = 0;
| |
| if(x.z < edge.z) ret.x = 0;
| |
| return ret;
| |
| }
| |
| </source>
| |
| |examples=<source lang="lsl2">
| |
| 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.
| |
| </source>
| |
| |cat1=Examples
| |
| }}
| |
| | |
| | |
| = Random Notes =
| |
| | |
| I be a placeholder. At least for now.
| |