Difference between revisions of "PRIM POINT LIGHT"

From Second Life Wiki
Jump to navigation Jump to search
m
m (condensed example script)
Line 1: Line 1:
<onlyinclude>{{#if:
<onlyinclude>{{#if:
{{#vardefine:light_const|{{LSL Const|PRIM_POINT_LIGHT|integer|23|c=Used to {{GetSet|{{{1|}}}|get|set|/}} the prim's point light configuration}}}}
{{#vardefine:light_const|{{LSL Const|PRIM_POINT_LIGHT|integer|23|c=Used to {{GetSet|{{{1|}}}|get|set|/}} the prim's point light configuration}}}}
{{#vardefine:p_radius_desc|ranges from 0.1 to 20.0}}
{{#vardefine:p_radius_desc|ranges from 0.1 to 20.0}}
{{#vardefine:p_falloff_desc|ranges from 0.01 to 2.0}}
{{#vardefine:p_falloff_desc|ranges from 0.01 to 2.0}}
{{#vardefine:p_intensity_desc|ranges from 0.0 to 1.0}}
{{#vardefine:p_intensity_desc|ranges from 0.0 to 1.0}}
}}</onlyinclude>{{#if:
}}</onlyinclude>{{#if:
{{LSL_Function/boolean|boolean}}
{{LSL_Function/boolean|boolean}}
{{LSL_Function/color|color}}
{{LSL_Function/color|color}}
}}{{LSL Constant
}}{{LSL Constant
|inject-2={{LSL PrimitiveParam Categorize|Prim}}
|inject-2={{LSL PrimitiveParam Categorize|Prim}}
Line 41: Line 36:
* Lights with a high intensity have a wash-out effect when overlapping. Keep this in mind when using multiple lights. '''''Never''' create an abundance of lights to get around the 6 light maximum in basic lighting'', as viewers with advanced lighting will be washed out and may suffer from client lag.
* Lights with a high intensity have a wash-out effect when overlapping. Keep this in mind when using multiple lights. '''''Never''' create an abundance of lights to get around the 6 light maximum in basic lighting'', as viewers with advanced lighting will be washed out and may suffer from client lag.
* There are no LSL functions that allow you to set projector values (texture, FOV, focus, and ambiance).
* There are no LSL functions that allow you to set projector values (texture, FOV, focus, and ambiance).
|examples=
|examples=
<lsl>
<lsl>
// simple light source demonstrator
integer isLightTurnedOn;
// 8feb07 "tetsumo kuri"
// thanks to squee janitor for line to dissect
 
integer light_s = TRUE;     //  "_s" for status


default
default
{
{
    state_entry()
    {
      //  llSetText("click me",<1,0,0.6>,.5);  // in case you like labels
    }
     touch_start(integer total_number)
     touch_start(integer total_number)
     {
     {
        if ( light_s )
//      toggle isLightTurnedOn between TRUE and FALSE
         {
         isLightTurnedOn = !isLightTurnedOn;
            light_s = FALSE;


            // fullbright doesn't have anything to do with light in NEW(2006?) lighting model
        if (isLightTurnedOn)
            // setting fullbright does look good though
        {
             llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,FALSE]);
             llSetPrimitiveParams([
             
                PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
            llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE,   // if this is false, light is off,
                PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 1.0, 10.0, 0.6]);
                                    <0.0,1.0,0.0>,1.0, 10.0, 0.5]); // rest of params don't matter
         }
         }          
         else
         else
         {
         {
             light_s = TRUE;
             vector COLOR_ORANGE  = <1.000, 0.522, 0.106>;
            //llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,TRUE]);  //leave fullbright commented for now
 
            llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,
             llSetPrimitiveParams([
                                    <1.0,0.7,1.0>,  // light color vector range: 0.0-1.0 *3
                PRIM_FULLBRIGHT, ALL_SIDES, TRUE,
                                    1.0,            // intensity    (0.0-1.0)
                PRIM_POINT_LIGHT, TRUE, COLOR_ORANGE, 1.0, 10.0, 0.6]);
                                    10.0,          // radius      (.1-20.0)
                                    0.6 ]);         // falloff      (.01-2.0)
               
            // this could have been done in one line, like this   
             //llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,FALSE,PRIM_POINT_LIGHT,TRUE,<1.0,1.0,0.5>,20,1.0,0.5]);
            //      ... but thats kinda hard to take in...     
         }
         }
        //llSay(0, " Click!");
     }
     }
}
}
</lsl>
</lsl>
|constants=
|constants
{{LSL ConstRow|CHANGED_SHAPE}}
|functions=
|functions=
{{LSL DefineRow||[[llSetPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetLinkPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetLinkPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetLinkPrimitiveParamsFast]]|}}
{{LSL DefineRow||[[llGetPrimitiveParams]]|}}
{{LSL DefineRow||[[llGetPrimitiveParams]]|}}
|events=
{{LSL DefineRow||[[llGetLinkPrimitiveParams]]|}}
{{LSL DefineRow||[[changed]]|}}
|events
|location
|location
|cat1=Light
|cat1=Light

Revision as of 11:50, 8 January 2014

Description

Constant: integer PRIM_POINT_LIGHT = 23;

The integer constant PRIM_POINT_LIGHT has the value 23

PRIM_POINT_LIGHT is used to configure the point light configuration of the prim

llSetPrimitiveParams

[ PRIM_POINT_LIGHT, integer boolean, vector color, float intensity, float radius, float falloff ]
• integer boolean TRUE enables, FALSE disables
• vector color color in RGB <R, G, B> (<0.0, 0.0, 0.0> = black, <1.0, 1.0, 1.0> = white)
• float intensity ranges from 0.0 to 1.0
• float radius ranges from 0.1 to 20.0
• float falloff ranges from 0.01 to 2.0

When used with llSetPrimitiveParams & llSetLinkPrimitiveParams & llSetLinkPrimitiveParamsFast

llGetPrimitiveParams

llGetPrimitiveParams([ PRIM_POINT_LIGHT ]);

Returns the list [ integer boolean, vector color, float intensity, float radius, float falloff ]

• integer boolean TRUE enables, FALSE disables
• vector color color in RGB <R, G, B> (<0.0, 0.0, 0.0> = black, <1.0, 1.0, 1.0> = white)
• float intensity ranges from 0.0 to 1.0
• float radius ranges from 0.1 to 20.0
• float falloff ranges from 0.01 to 2.0

Caveats

  • Viewers that do not have advanced lighting enabled can only render 6 lights at a time and projectors will be rendered as omnidirectional light sources. (OpenGL limitations allow for 8 light sources, SL appears to reserve one each for the Sun and Moon.)
    • Viewers that do have advanced lighting enabled can render as many lights as their graphics card allows; it is not hard-limited by the viewer.
  • Lights with a high intensity have a wash-out effect when overlapping. Keep this in mind when using multiple lights. Never create an abundance of lights to get around the 6 light maximum in basic lighting, as viewers with advanced lighting will be washed out and may suffer from client lag.
  • There are no LSL functions that allow you to set projector values (texture, FOV, focus, and ambiance).
All Issues ~ Search JIRA for related Bugs

Examples

<lsl> integer isLightTurnedOn;

default {

   touch_start(integer total_number)
   {

// toggle isLightTurnedOn between TRUE and FALSE

       isLightTurnedOn = !isLightTurnedOn;
       if (isLightTurnedOn)
       {
           llSetPrimitiveParams([
               PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
               PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 1.0, 10.0, 0.6]);
       }
       else
       {
           vector COLOR_ORANGE  = <1.000, 0.522, 0.106>;
           llSetPrimitiveParams([
               PRIM_FULLBRIGHT, ALL_SIDES, TRUE,
               PRIM_POINT_LIGHT, TRUE, COLOR_ORANGE, 1.0, 10.0, 0.6]);
       }
   }

} </lsl>

Deep Notes

Search JIRA for related Issues

Signature

integer PRIM_POINT_LIGHT = 23;