Posts Tagged ‘transparency’

Victorian Interiors – Set 1, Take 2

Tuesday, April 27th, 2010

An explanation and an announcement

Charity Tearfall posted a brief, complimentary review of the Victorian Interior textures on XstreetSL (thanks!), but suggested that it would be good if the windows were transparent.

Well, she’s right, it’s always useful for windows to be transparent!

Unfortunately, and as you are probably aware if you are a resident, Second Life has certain ‘issues’ with transparency, especially if one transparent texture is in front of another (and especially if they are slightly at an angle). There’s more about this in a previous blog post of mine, if you want the gory technical details. (Scroll down that post to read about “the dreaded Z-order bug”).

These days the situation has been made worse by the fact that many (most?) of the recent hairstyles in Second Life make use of transparency. I’m sure you’ve seen the odd effects which happen when these hairstyles get in front of windows or other transparent prims.

For that reason I’ve started avoiding transparency whenever I can.

But other builders in Second Life might (and obviously do!) have different views on this. So for them I’ve released a second version of the Victorian Interiors texture set, this time with transparent windows.

As usual, you will find it in-world at the Templar Creations store:

Templar Creations Main Store

You’ll also find it on XStreetSL, here:

Victorian Interiors – Set 1 – with Transparent Windows

And if you are in search of the original set, with opaque windows, you’ll find that here:

Victorian Interiors – Set 1

I hope that’s transparent enough…

Transparently Obvious

Monday, June 8th, 2009

Montague: Carruthers, look at this. Observe it closely.

Carruthers: There appears to be nothing there, Montague.

Montague: So it would appear, my dear Carruthers, but appearances can be deceptive…

I briefly looked at transparency in the third of my Texture tutorials, but it’s a subject which deserves a more in-depth look, because in spite of the title of this blog entry, there are aspects of transparency in SL which are far from obvious.

There are two ways to apply transparency to a prim (or to one face of a prim). The simplest is to use the Transparency setting on the Texture tab, the second is apply a texture which has transparency.

Let’s start with the Transparency setting, which is the simpler way. Select a prim, or a prim face, and set the Transparency to something other than 0. The prim will become partially transparent.

In theory, you can set the transparency to 100%, but you will find that SL will set it back to 90% if you do (it is possible to have 100% transparency using a script, but it is easier to use a transparent texture).

If you have applied the transparency to an entire prim, the result will probably be what you expect. Suppose however, you apply transparency to just one side of a cube — the result might not be what you expect:

Simple transparency

Simple transparency

This is because SL does not draw the inside of prims, even when you make one side of the prim transparent. If you are creating windows for a building, you will find that this can cause you some difficulties, but that’s a subject for another blog entry.

Applying transparency to an entire prim, or the entire side of a prim, can be useful, but not very flexible. It’s much more useful to be able to have a texture which contains a mixture of non-transparent and transparent (or maybe semi-transparent) sections.

To do this needs a special texture, and also means that I need to introduce you to…

…The Fiendish Alpha-Plane!

Carruthers: Great heavens, Montague, the evil Count Nefarious has escaped again!

Montague: On the contrary, Carruthers, he has merely boarded the fiendish Alpha Plane, which has the property of rendering everything within it utterly invisible.

Carruthers: Astonishing, Montague!

Montague: Transparently obvious, my dear Carruthers.

Yes, well, let us leave Montague and Carruthers in pursuit of the villainous Count, and turn our attention to the afore-mentioned Alpha-Plane.

If you want to avoid the painful technical details, all you need to know is that the alpha-plane applies levels of transparency to individual pixels in a texture. You can now skip the next section. If want to know more details, read on.

Geek Stuff

If you already understand all about alpha transparency (why are you reading this article?), I’m aware that what I’m about to say is somewhat simplified!

Every computer-generated image consists of a set of pixels. Think of them as a mass of dots in an electronic version of Pointillism. Each individual pixel has  a numeric value that determines how much red, how much green, and how much blue should be applied to the paint mixture for that particular dot.

The value for every pixel, then, can be broken down into three separate numbers, for Red, Green, and Blue.

The so-called Alpha-Plane adds a fourth value. The fourth value represents the amount of transparency for the pixel, in other words, the amount by which anything ‘behind’ the pixel will be visible (what happens is that the colours of the pixels ‘behind’ the texture are blended to a greater or lesser extent with the red, green, and blue values of the texture pixel).

A value of 0.0 means that the pixel is completely opaque, and nothing behind it can be seen. A value of 1.0 means that it is completely transparent (and effectively invisible).

Using the Alpha Plane

The alpha-plane allows you to have different levels of transparency in one texture, ranging from completely transparent to completely opaque. To create a transparent texture needs the help of a graphics package, of course. I can’t go into detail on this, because I am only familiar with a small number of graphics packages, and this does not include the ubiquitous Photoshop. Every program tends to handle transparency differently, but you should be able to find plenty of tutorials for your package of choice.

Personally, I use the Gimp, which is both free and powerful. Transparency is relatively straight-forward, though there are multiple ways to do it. Make sure that the image you are working on has an Alpha channel (in Gimp 2.4 you can create an Alpha channel from the Layer | Transparency | Add Alpha Channel menu option). Alternatively, you can create a new layer or image and specify it as transparent. Once your image or layer has an alpha-channel you can create a transparent section by selecting an area and then using the Edit | Clear menu option. You can also use the Layer | Transparency | Color To Alpha menu option, which applies graduated transparency to pixels of a selected colour — this can be very useful for creating windows — select the area that should be glass, and use this option to make it partially transparent.

Here are a couple of examples:

Transparent Window, Example 1

Transparent Window, Example 1

Transparent Window, Example 2

Transparent Window, Example 2

Unfortunately, having created your transparent texture, and applied it to your Second Life build, you might find that you have another problem to deal with, namely…

…the Dreaded Z-Order Bug

Carruthers: Great heavens, Montague! The beast appeared out of nowhere, and my bullets have no effect — the horrid thing does not seem to be where it appears to be.

Montague: Precisely, Carruthers. It is the dreaded Zorder Bug, which cannot be slain — one must simply hope to evade it.

Construct two flat prims, and apply a texture with transparency to both of them. For best effect, make them 3m or 4m tall and wide. Place them at right-angles to one another (as if they were the corner of a wall). Now walk round them.

You will probably notice that at certain positions the prims display incorrectly, seemingly interpenetrating one-another.

The problem is most pronounced when you have two transparent objects which are one in front of the other or, worse, interpenetrating each other, as in this example:

Z-Order Bug Example

Z-Order Bug Example

These days, a lot of hair textures use partially transparent textures, and you might have noticed the very odd effect which happens when someone with one these hairstyles walks in front of a transparent window.

This is known as the Z-Order bug (a reference to the way in which the computer renders the prims onto the display). It is not a bug in Second Life itself, but is rather a bug in the OpenGL system which Second Life uses for the 3D display. Simplistically, the graphics system cannot work out which prim should be displayed in front of another when they both have transparency.

(You won’t generally won’t come across this effect in 3D games which use OpenGL, because the level-designers are usually careful to avoid situations where the bug would show itself. In Second Life, however, you are the designer!)

If you have two adjoining prims which display this bug, one fix (assuming that you have to have both prims with a transparent texture) is to insert a prim in between them with a non-transparent texture. For example, if you have a wall corner, try putting a non-transparent column at the intersection. This sometimes cures the problem.

Having two transparent prims, one in directly in front of the other, however, is not fixable like this. The only thing you can do is to try to avoid this situation.

And Finally

If you want complete transparency, Linden supply a transparent texture, which you will find in the Textures section of the library in your inventory. It’s worth using this rather than creating your own, because it is more likely to be in viewers’ cache, for quicker loading.

Of course, completely transparent objects can be a bit difficult to work with, and easy to lose! Fortunately, there is a menu option which can help: View | Highlight Transparent — this gives all transparent objects a garish red glow, making them easy to spot.

Tutorial 3: More Options

Saturday, May 16th, 2009

One underused area of the texture dialog is the ‘Bumpiness’ dropdown. This adds ‘depth’ details to your texture. The effect on an existing texture is often subtle, but can be useful to add a touch of additional realism.

Here’s an example. The box on the right has the Darkness bumpmap applied to it:

Bumpmap example

Bumpmap example

However, you can use bumps on a face which doesn’t have any texture applied to it. This can give useful effects which will display more quickly, because there is no texture to be downloaded from the server.

Here’s an example using the woodgrain bumpmap (with some colouring applied):

Woodgrain example

Woodgrain example

For an even better effect, add some shininess — you will find this in the dropdown below the ‘Color’ box. It adds varying degrees of reflectiveness to the texture.

Combining colour, bumpmaps, and shininess can create interesting results without the need to have an actual texture file. For instance, the following speaker box uses no texture files at all:

Speakerbox example

Speakerbox example

Finally, let’s take a quick look at the group of three options at the top-right of the Texture tab: Transparency, Glow, and Full-Bright.

Transparency, glow, and full-bright in the Build dialog

Transparency, glow, and full-bright in the Build dialog

Transparency is fairly obvious — the higher this value, the more transparent the object is. This is not the only way to make a prim (or a prim face) transparent (it can also be done using a texture), but it is the simplest.

One unexpected result (if you are new to building things in Second Life, and if you are new to 3D graphics), is what happens if you make a single face transparent. Do you get to see the inside of the object? Well, no. Second Life doesn’t actually draw the inside of prims, so if you make a face transparent, you will see right through the prim.

Moving on to Glow, this was introduced a relatively short time ago, and probably counts as one of the most abused graphic features in Second Life. Part of the problem lies in the fact that different graphic cards seem to render glow differently, so that what looks like a perfectly acceptable glow on one computer might appear like a blazing sun on another.

With that in mind, the sensible thing is to keep glow values low. Beware of anything higher than about 0.2. For most effects, values as low as 0.01 or 0.02 often give the best results.

Combining glow and transparency can yield some very nice ‘light’ effects:

Light example

Light example

Finally, Full-Bright. It might not be immediately obvious what this does, especially if you apply it during Second Life ‘daytime’. Simply, this will ignore the effect of Second Life lighting (sun, moon, or local lights), and will always display the texture at it’s actual colour values. Full-bright objects look as if they are illuminated at night, so this is a useful option for lights.

Let’s apply this to our ‘light’ from the previous example. Here’s a version without full-bright, and then with:

Full-bright example

Full-bright example

That concludes this initial series of tutorials on textures. I haven’t covered all the features on the texture tab, and there are still lots of other things to find out about textures, but if you are new to building objects in Second Life this should have given you enough to start with.