Difference between revisions of "Category:LSL Alpha"

From Second Life Wiki
Jump to navigation Jump to search
m (→‎Examples: misuse of 'opaque' and percentages)
m (Replaced <source> with <syntaxhighlight>)
 
(9 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{LSL Header|ml=*}}
{{LSL Header|ml=*}}
The term "Alpha" refers to how opaque or transparent an object (or, in this case, a prim) is. In Second Life, the alpha property is set by the scripting functions [[llSetAlpha]], [[llSetLinkAlpha]], [[llSetPrimitiveParams]], and [[llSetLinkPrimitiveParams]]. These functions use a [[float]] value. When set to '''0.0''', the object/prim is fully invisible. When set to '''1.0''', the object is non-transparent.
The term "Alpha" refers to how translucent an object (or, in this case, a prim) is. In Second Life, the alpha property is set by the scripting functions [[llSetAlpha]], [[llSetLinkAlpha]], [[llSetPrimitiveParams]], and [[llSetLinkPrimitiveParams]]. These functions use a [[float]] value. When set to '''0.0''', the object/prim is fully transparent. When set to '''1.0''', the object is opaque.
Sometimes, [[Resident]]s refer to a transparent [[texture]] as ''alpha texture''. This is not to be confused with this prim property. See [[llSetTexture]] and [[TEXTURE_TRANSPARENT]] instead.
Sometimes, [[Resident]]s refer to a transparent [[texture]] as ''alpha texture''. This is a texture with an alpha map, not to be confused with this prim property. See [[llSetTexture]] and [[TEXTURE_TRANSPARENT]] instead.


==Build Mode==  
==Build Mode==  
In Build Mode, the alpha is represented by a percentage, ranging from '''0%''' to '''90%'''.  
In Build Mode, the alpha is represented by a percentage, ranging from '''0%''' to '''100%'''. Take extra care when moving viewer transparency settings to scripts and back. In the editor a higher number is more transparent, while in scripts a higher number is less transparent.
('''Note''': The '''90%''' cap is for viewers that have been officially released by Linden Labs)
 
==Examples==
==Examples==
Below are examples on how one may set the alpha of an object.  
Below are examples on how one may set the alpha of an object.  
{|cellspacing="0" cellpadding="6" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; background-color: #F8F8FF; border-collapse: collapse"
{|cellspacing="0" cellpadding="6" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; background-color: #F8F8FF; border-collapse: collapse"
!style="background-color: #D2D3FF" | Function
!style="background-color: #D2D3FF" | Function
!style="background-color: #D2D3FF" | LSL Example
!style="background-color: #D2D3FF" | LSL Example & Description
!style="background-color: #D2D3FF" | Description
|-
|-
| [[llSetAlpha]]
| [[llSetAlpha]]
| <lsl>llSetAlpha(1.0, ALL_SIDES);</lsl>
| <syntaxhighlight lang="lsl2">llSetAlpha(1.0, ALL_SIDES);</syntaxhighlight> This will set the object's sides' alpha to opaque, or '''0%'''.
| This will set the object's sides' alpha to opaque, or '''0%'''.
|-
|-
| [[llSetLinkAlpha]]
| [[llSetLinkAlpha]]
| <lsl>llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);</lsl>
| <syntaxhighlight lang="lsl2">llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);</syntaxhighlight>
| This will set link-set's alpha to fully transparent, or '''100%'''. ('''Note''': The Viewers released by Linden Labs are unable to set the alpha of an object to fully transparent without a script; the limit is caped at '''90%''')
This will set link-set's alpha to transparent, or '''100%'''.
|-
|-
| [[llSetPrimitiveParams]]
| [[llSetPrimitiveParams]]
| <lsl>llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, llGetColor(ALL_SIDES), 0.5]);</lsl>
| <syntaxhighlight lang="lsl2">llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, llGetColor(ALL_SIDES), 0.5]);
| This will set the object's alpha to translucent, or '''50%'''.
// Using llGetColor this way may not give the desired result (it returns the average color)</syntaxhighlight>
This will set the object's alpha to translucent, or '''50%'''.
|-
|-
| [[llSetLinkPrimitiveParams]]
| [[llSetLinkPrimitiveParams]]
| <lsl>llSetLinkPrimitiveParams(LINK_SET, [PRIM_COLOR, ALL_SIDES, llGetColor(ALL_SIDES), 0.5]);</lsl>
| <syntaxhighlight lang="lsl2">llSetLinkPrimitiveParams(LINK_SET, [PRIM_COLOR, ALL_SIDES, llGetColor(ALL_SIDES), 0.5]);
| This will set the link-set's alpha to translucent, or '''50%'''.
// Using llGetColor this way may not give the desired result (it returns the average color).</syntaxhighlight>
This will set the link-set's alpha to translucent, or '''50%'''.
|-
| [[llSetLinkPrimitiveParamsFast]]
| <syntaxhighlight lang="lsl2">llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_COLOR, ALL_SIDES, llGetColor(ALL_SIDES), 0.5]);
// Using llGetColor this way may not give the desired result (it returns the average color).</syntaxhighlight>
This will set the link-set's alpha to translucent, or '''50%'''.
|-
|-
|}
|}


{{LSLC|}}{{LSLC|Face|*Alpha}}
{{LSLC|}}{{LSLC|Face|*Alpha}}

Latest revision as of 11:08, 17 April 2022

The term "Alpha" refers to how translucent an object (or, in this case, a prim) is. In Second Life, the alpha property is set by the scripting functions llSetAlpha, llSetLinkAlpha, llSetPrimitiveParams, and llSetLinkPrimitiveParams. These functions use a float value. When set to 0.0, the object/prim is fully transparent. When set to 1.0, the object is opaque. Sometimes, Residents refer to a transparent texture as alpha texture. This is a texture with an alpha map, not to be confused with this prim property. See llSetTexture and TEXTURE_TRANSPARENT instead.

Build Mode

In Build Mode, the alpha is represented by a percentage, ranging from 0% to 100%. Take extra care when moving viewer transparency settings to scripts and back. In the editor a higher number is more transparent, while in scripts a higher number is less transparent.

Examples

Below are examples on how one may set the alpha of an object.

Function LSL Example & Description
llSetAlpha
llSetAlpha(1.0, ALL_SIDES);
This will set the object's sides' alpha to opaque, or 0%.
llSetLinkAlpha
llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);

This will set link-set's alpha to transparent, or 100%.

llSetPrimitiveParams
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, llGetColor(ALL_SIDES), 0.5]);
// Using llGetColor this way may not give the desired result (it returns the average color)

This will set the object's alpha to translucent, or 50%.

llSetLinkPrimitiveParams
llSetLinkPrimitiveParams(LINK_SET, [PRIM_COLOR, ALL_SIDES, llGetColor(ALL_SIDES), 0.5]);
// Using llGetColor this way may not give the desired result (it returns the average color).

This will set the link-set's alpha to translucent, or 50%.

llSetLinkPrimitiveParamsFast
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_COLOR, ALL_SIDES, llGetColor(ALL_SIDES), 0.5]);
// Using llGetColor this way may not give the desired result (it returns the average color).

This will set the link-set's alpha to translucent, or 50%.