Difference between revisions of "Invisiprim"

From Second Life Wiki
Jump to navigation Jump to search
m (llSetTexture linked)
(Performed major revision work and updated some out-of-date information. Also added an example script for making)
Line 1: Line 1:
{{Help|Glossary=*|Object=*}}
{{Help|Glossary=*|Object=*}}
''Note: The new alpha layer feature of Viewer 2.0 has replaced the use of invisiprims to hide parts of the avatar. See [[Invisiprim#Criticism|Criticism]] below.''
[[Image:Avatar_behind_invisiprim.jpg|thumb|right|150px|Avatar behind an invisiprim]]
[[Image:Avatar_behind_invisiprim.jpg|thumb|right|150px|Avatar behind an invisiprim]]
An '''Invisiprim''' is a [[prim]] with a special [[texture]]. This texture is transparent and has the effect to hide all items with an alpha layer, located behind the object with the invisi-texture. This includes water, clouds, particles and the whole default avatar parts. Prims with an invisitexture are ''not'' highlighted through the ''Highlight Transparent'' feature of the viewer (located in the ''View'' menu).  
An '''Invisiprim''' is a [[prim]] with a special [[texture]]. The texture appears transparent and has the effect to hide all items with an alpha layer which are being seen through the object with the invisi-texture. This includes water, clouds, particles and any part of the default avatar (including clothes, but not attachments unless they have alpha textures). Prims with an invisitexture are ''not'' highlighted through the ''Highlight Transparent'' feature of the viewer (located in the ''View'' menu).  


Invisiprims are often used by creators of [[furry]] or other non-human avatars, to hide parts of the human default avatar.
Invisiprims are often used by creators of [[furry]] or other non-human avatars, to hide parts of the human default avatar.


The texture can only be set via script (see [[llSetTexture]]) and its [[key]] is 38b86f85-2575-52a9-a531-23108d8da837
There are two invisi-textures, which can only be set using a script (see [[llSetTexture]] or the example script below). Their [[key|keys]] are "38b86f85-2575-52a9-a531-23108d8da837" and "e97cf410-8e61-7005-ec06-629eba4cd1fb". Either texture can be used; they function identically.
 
== How invisiprims work ==
When a viewer sees that the texture key of a prim's face is set to one of the two texture keys above, instead of drawing the actual texture it renders that face of the prim as though it had a completely transparent texture. Additionally, and most importantly, any part of any [[alpha]] texture that is being seen through the invisiprim will not be rendered. However, alpha textures in front of the invisiprim will still be drawn.
 
Since the texture on avatar skins are rendered as alpha textures, invisiprims can be used to make any body parts they cover invisible. Water is also an alpha texture, so invisiprims can be used to "punch holes" in the water, which could be used for example to create depressions in terrain that descend below sea level but do not appear to contain water.
 
Other objects with alpha textures are the particle clouds (but not [[Windlight]] clouds), all other particles, and any normally opaque texture with transparency set either in the editor or by the [[llSetAlpha]] call. All of these will disappear behind an invisiprim.
 
Invisiprims are affected by the shiny, bumpmapping and transparency settings. Setting an invisiprim to be shiny will make it appear as a semi-transparent, shiny prim. The invisiprim becomes more opaque as shininess is increased, however it still hides alpha textures seen through it. Setting bumpmapping will also reveal the prim as the bumpmap is overlayed on the transparent surface. Again, it appears semi-transparent and continues to hide alpha textures.
 
Setting the textures of an invisiprim to anything other than opaque will cause the invisi-texture to lose its special properties. Instead, the actual texture is revealed. (This is either a grey-to-transparent gradient, or a sort of cloudy white shape on a transparent background, depending which key is used. These textures also appear in the texture preview window.)
 
== Criticism ==
As noted above, invisiprims are primarily used on avatars to hide parts of the avatar [[mesh]]. However, due to the nature of its effects the texture not only hides the human bodyparts, but also any parts of the surrounding environment that happen to be seen through it, creating an unwanted |x-ray effect". Mostly due to this effect, the ability to add [[alpha layer|alpha layers]] to the default avatar was requested in {{Jira|VWR-812}}, to replace invisiprims on avatars. A design proposal for this feature can be viewed [[User:Brent Linden/VWR-812 Design Proposal|here]]. As a result, alpha layers have been implemented and are available in Viewer 2.0.
 
== Example Script ==
Below is a simple script for making an invisiprim. Create a new script in your inventory and paste the code below into it. Then drag the script onto a prim to turn it into an invisiprim.
 
<lsl>
default {
    state_entry() {
        // Make this prim an invisiprim.
        llSetPrimitiveParams([PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_NONE, PRIM_BUMP_NONE,
        PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0, PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT,
        PRIM_TEXTURE, ALL_SIDES, "e97cf410-8e61-7005-ec06-629eba4cd1fb", ZERO_VECTOR, ZERO_VECTOR, 0.0]);
       
        // Delete ourselves from the prim; we are no longer needed.
        llRemoveInventory(llGetScriptName());
    }
</lsl>
 
For coders who wish to understand how this works, the same code as above is reproduced below, thoroughly commented to show what the code is doing. Note that the code below is not a complete script.


== Critic on Invisiprims ==
<lsl>
Since the texture not only hides the human bodyparts, but also parts of the surrounding (unwanted x-ray effect), the ability to add alpha layers to the default avatar was requested in {{Jira|VWR-812}}, to replace invisiprims. A design proposal for this feature can be viewed [[User:Brent Linden/VWR-812 Design Proposal|here]].
invisiprim() {
    // Here we explain the whys and wherefores of making an invisiprim.
   
    // We use an llSetPrimitiveParams call to set a lot of options at once.
    llSetPrimitiveParams(
   
    // Turn off bump mapping and shiny. If either of these options are on,
    // they will have their usual effects, causing the invisiprim to be seen
    // even though the special effects of hiding alpha textures continues.
    [PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_NONE, PRIM_BUMP_NONE,
   
    // Set the color and alpha to white and full opacity, respectively.
    // Color has no effect on the invisiprim, but the prim must be FULLY opaque,
    // or the special effect is lost.
    PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0,
   
    // For completeness we set mapping to default, even though it has no effect.
    PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT,
   
    // Now we set the actual texture, which makes this an invisiprim. We set it on
    // all sides, but there is nothing stopping you setting it only on certain faces.
    // We also set repeat and offset to zero.
    PRIM_TEXTURE, ALL_SIDES, "e97cf410-8e61-7005-ec06-629eba4cd1fb", ZERO_VECTOR, ZERO_VECTOR
   
    // The same code that appears here is reproduces below, but without the comments.
    ]);
}
</lsl>

Revision as of 10:50, 5 April 2010

Note: The new alpha layer feature of Viewer 2.0 has replaced the use of invisiprims to hide parts of the avatar. See Criticism below.

Avatar behind an invisiprim

An Invisiprim is a prim with a special texture. The texture appears transparent and has the effect to hide all items with an alpha layer which are being seen through the object with the invisi-texture. This includes water, clouds, particles and any part of the default avatar (including clothes, but not attachments unless they have alpha textures). Prims with an invisitexture are not highlighted through the Highlight Transparent feature of the viewer (located in the View menu).

Invisiprims are often used by creators of furry or other non-human avatars, to hide parts of the human default avatar.

There are two invisi-textures, which can only be set using a script (see llSetTexture or the example script below). Their keys are "38b86f85-2575-52a9-a531-23108d8da837" and "e97cf410-8e61-7005-ec06-629eba4cd1fb". Either texture can be used; they function identically.

How invisiprims work

When a viewer sees that the texture key of a prim's face is set to one of the two texture keys above, instead of drawing the actual texture it renders that face of the prim as though it had a completely transparent texture. Additionally, and most importantly, any part of any alpha texture that is being seen through the invisiprim will not be rendered. However, alpha textures in front of the invisiprim will still be drawn.

Since the texture on avatar skins are rendered as alpha textures, invisiprims can be used to make any body parts they cover invisible. Water is also an alpha texture, so invisiprims can be used to "punch holes" in the water, which could be used for example to create depressions in terrain that descend below sea level but do not appear to contain water.

Other objects with alpha textures are the particle clouds (but not Windlight clouds), all other particles, and any normally opaque texture with transparency set either in the editor or by the llSetAlpha call. All of these will disappear behind an invisiprim.

Invisiprims are affected by the shiny, bumpmapping and transparency settings. Setting an invisiprim to be shiny will make it appear as a semi-transparent, shiny prim. The invisiprim becomes more opaque as shininess is increased, however it still hides alpha textures seen through it. Setting bumpmapping will also reveal the prim as the bumpmap is overlayed on the transparent surface. Again, it appears semi-transparent and continues to hide alpha textures.

Setting the textures of an invisiprim to anything other than opaque will cause the invisi-texture to lose its special properties. Instead, the actual texture is revealed. (This is either a grey-to-transparent gradient, or a sort of cloudy white shape on a transparent background, depending which key is used. These textures also appear in the texture preview window.)

Criticism

As noted above, invisiprims are primarily used on avatars to hide parts of the avatar mesh. However, due to the nature of its effects the texture not only hides the human bodyparts, but also any parts of the surrounding environment that happen to be seen through it, creating an unwanted |x-ray effect". Mostly due to this effect, the ability to add alpha layers to the default avatar was requested in VWR-812, to replace invisiprims on avatars. A design proposal for this feature can be viewed here. As a result, alpha layers have been implemented and are available in Viewer 2.0.

Example Script

Below is a simple script for making an invisiprim. Create a new script in your inventory and paste the code below into it. Then drag the script onto a prim to turn it into an invisiprim.

<lsl> default {

   state_entry() {
       // Make this prim an invisiprim.
       llSetPrimitiveParams([PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_NONE, PRIM_BUMP_NONE,
       PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0, PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT,
       PRIM_TEXTURE, ALL_SIDES, "e97cf410-8e61-7005-ec06-629eba4cd1fb", ZERO_VECTOR, ZERO_VECTOR, 0.0]);
       
       // Delete ourselves from the prim; we are no longer needed.
       llRemoveInventory(llGetScriptName());
   }

</lsl>

For coders who wish to understand how this works, the same code as above is reproduced below, thoroughly commented to show what the code is doing. Note that the code below is not a complete script.

<lsl> invisiprim() {

   // Here we explain the whys and wherefores of making an invisiprim.
   
   // We use an llSetPrimitiveParams call to set a lot of options at once.
   llSetPrimitiveParams(
   
   // Turn off bump mapping and shiny. If either of these options are on,
   // they will have their usual effects, causing the invisiprim to be seen
   // even though the special effects of hiding alpha textures continues.
   [PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_NONE, PRIM_BUMP_NONE,
   
   // Set the color and alpha to white and full opacity, respectively.
   // Color has no effect on the invisiprim, but the prim must be FULLY opaque,
   // or the special effect is lost.
   PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0,
   
   // For completeness we set mapping to default, even though it has no effect.
   PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT,
   
   // Now we set the actual texture, which makes this an invisiprim. We set it on
   // all sides, but there is nothing stopping you setting it only on certain faces.
   // We also set repeat and offset to zero.
   PRIM_TEXTURE, ALL_SIDES, "e97cf410-8e61-7005-ec06-629eba4cd1fb", ZERO_VECTOR, ZERO_VECTOR
   
   // The same code that appears here is reproduces below, but without the comments.
   ]);

} </lsl>