Posts Tagged ‘tutorial’

Animated Textures – Tutorial 1

Saturday, September 19th, 2009

With the recent release of the Animated Steampunk Textures pack, this would be a good time to do some tutorials on animated textures, so here we go…

This is the first of a three-part tutorial about using animated textures in Second Life. There three parts, because there are three different ways of animating textures, each with their own use. Two of them make use of the LSL function, llSetTextureAnim, which is the usual way of animating textures. The third way uses a timer and offsets to manually animate the texture — it is a lot less efficient, but can occasionally be useful.

In this first part, however, I’ll look at the simplest and easiest way of animating a texture, using the ‘smooth scroll’ option. This simply moves the texture across the surface of the prim, and doesn’t need a specially designed texture — any texture can be scrolled, although some will obviously work better than others!

A common use of this is to create a flowing water animation, and that’s the example I’ll use here, especially as suitable textures are available from the built-in Library in every Second Life avatar’s inventory.


Rez a simple cube, and apply a water texture to it — the Water – ripple layer 1 texture in the Library\Textures\Waterfalls folder should work well. Resize it into something fairly long and flat (5 x 2 should be effective).

On the Contents tab of the Build window, click the ‘New Script’, and wait for it to appear in the Contents list (if SL is being laggy this might take a few seconds). Double-click to open it.

Replace the existing code with the following:

        llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, 0, 1, 1, 1, 1, 0.12);

Save the script, and the texture will start scrolling. Assuming that you haven’t rotated the prim, this will scroll the top surface.

Ok, now you’ve seen it in action, let’s look at the parameters.

The first parameter is a set of flags which specify how the texture should be animated. You can string together several flags (as in the above example) by using the ‘|’ symbol (technically an ‘OR’ operator). Note that some combinations don’t make sense.

You can check the LSL Wiki page for details of what each flag means, but in the example we are switching the animation on (rather important!), and we are saying that we want a ‘SMOOTH’ animation, which means that the texture will simply be scrolled across the surface of the prim (actually, this is not quite an accurate description of what SMOOTH does, but I’ll explain it in more detail in the next article).

Finally we are specifying ‘LOOP’, which means that the animation will keep going continuously.

Instead of LOOP we could have specified PING-PONG, which reverses the animation when it reaches the end. In the case of a smooth animation, it will scroll the texture for the entire length, then reverse direction and scroll it back again.

If you want to stop an animation, simply set this parameter to 0. All the other parameters are irrelevant in this case.

The next parameter — 0 in this example — is the face of the prim that the animation should be applied to. All the other faces will be static. However, if you use ALL_SIDES for this parameter, all the faces of the prim will animate.

Unfortunately, it isn’t possible to animate some but not all of the faces — it’s either 1 face or all faces.

A couple of final notes. You’ll notice that the Repeat and Flip options for textures don’t have any effect on animated textures. Rotate, however, does.

That will do for now. In the next article, I’ll take a look at the traditional animated texture, which uses a sequence of frames like an animated movie.

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.

Tutorial 2: Repeat, Offset

Friday, May 8th, 2009

In the previous tutorial I gave you a guide to getting textures on to your prims. In this tutorial, I’ll show you how to change the appearance of the applied textures.

Let’s start with the simplest, but most frequently-used options — the Repeat options. These allow you to set how many times the texture will repeat across each face (or the selected face) of the prim.

Here are two boxes with the same texture, the first one with both repeats set to 1, and the second to 3 each. The most common use for this is where you have a simple, small texture which you want to use to cover a large area.

Simple Repeat Example

Simple Repeat Example

What happens when you resize the prim that the texture is on? The answer depends on whether you have the ‘stretch textures’ box ticked or not. If you tick this box, and then resize the prim, this is the result:

Stretch Example

Stretch Example

If the ‘stretch textures’ box is unticked, you get the following:

No-Stretch Example

No-Stretch Example

This might seem a surprising result. It is because textures are centered on the prim face, rather than being anchored to the top-left. However, this leads very neatly on to the next feature — Offset.

The texture offset fields are near the bottom of the build dialog. The offset amount is a fraction of the size of the texture, so an offset of 1.00 will have not effect — the texture is moved by it’s complete width or height.

Because textures are centered on prim faces, offsets should be thought of as offsets from the middle. In our example above, we want to shift the texture by half it’s height, to align it to the top of the prim, like so:

Simple Offset Example

Simple Offset Example

There is another way of setting the repeat for textures, which works in a slightly different way, and can sometimes be very useful. This is the ‘repeats per meter’ setting.

To show the effect, let’s have an example:

This archway looks fine from the front, but the texture on the sides is wrong. This is because the texture is set to repeat 1 x 1 horizontally and vertically. The sides of the arch are narrower, so the texture gets ‘squashed’. Now, it would be possible to fix this by changing the repeats on the side (by selecting the side texture only — see the previous tutorial to find out about ‘select texture’).

Squashed Texture Example

Squashed Texture Example

However, there is an easier way, using ‘repeats per meter’. Setting this to 1.0 (in this case), and then clicking the ‘Apply’ button will size the texture so that it repeats every 1.0 meters. Because the prim in this case is 1m x 0.5m, the front and back will remain unchanged, but the texture on the sides will now display correctly:

Repeats Per Meter Example

Repeats Per Meter Example

Ok, I think that will do for this tutorial. Happy texturing!

Tutorial 1: Applying Textures

Friday, March 20th, 2009

As textures are Templar Creation’s main product, it seems appropriate to have some tutorials about using them. This is the first in a series which will start with the basics, and eventually progress on to advanced uses of textures.

To begin at the beginning…

I’ll assume that you already know the basics of constructing prims, and at least know how to open the Build dialog and get to the various tabs.

To start this tutorial, open the Build dialog, and rez a simple cube. We’ll use this to go through the different ways of applying textures.

Once you’ve rezzed the cube, close the Build dialog (you’ll find out why in a minute).

Let’s start by actually locating some textures in your inventory. The Inventory is divided into two basic sections – “My Inventory”, and “Library”. The “My Inventory” section holds everything that you have bought or uploaded yourself. The “Library” section holds things which are supplied for free by Linden Lab.

Both sections include “Textures” folders, which are, not surprisingly, the first place to go looking for textures. They aren’t the only places, though. It’s perfectly possible to move textures into other folders. More importantly, and perhaps a little less obviously, snapshots can also be used as textures.

It’s worth noting that when you upload an image from your computer (from the File | Upload Image menu option), it will always go into your Textures folder. Of course, you can move it from there once it has been uploaded.

So, let’s use one of these textures. It’s actually possible to apply a texture without opening the Build dialog. Simply drag the texture from your inventory onto the cube — this will immediately apply the texture on to whichever side of the cube you dropped it.

Obviously, this will only work on prims that belong to you (and for which you have modify permissions).

That’s the quickest and simplest way of applying a texture, and is sometimes quite useful. Usually, though, you will want to do more than just apply a texture to a single side of a prim, so let’s move on to the more normal ways of applying textures.

Right-click the cube, and select “Edit”, to open the Build dialog.

Select the “Textures” tab (it’s the last one).

There are multiple options and controls on this tab, but for the moment we will simply concentrate on the texture image itself. If you’ve followed the previous step for applying a texture, you’ll notice that it has “Multiple” printed over it, to tell you that this prim has more than one texture applied.

Click the image, and a texture selection dialog will appear:

Texture Selection Dialog

Texture Selection Dialog

On the left is a picture of the current texture, along with some buttons. Click the “Blank” button — your cube will turn white. If you click the “Default” button, the cube will be textured with the familiar plywood texture.

There is also a “None” button. I’ve never seen this enabled, and have no idea what it does…

On the right you should see a list of the textures in your inventory. This will go through your entire inventory, finding every copiable texture (the texture has to have copy permissions for you to be able to use it). If you have a lot of textures and/or SL is being laggy, this can take a while to fill.

If you click on one of the listed textures, it will be displayed in the texture image box. If the ‘Apply Immediately’ box is ticked (which it is by default), the texture will also be applied to the prim — this is a useful way of quickly checking what different textures will look like. Click “Select” to make the texture permanent (well, until you change it again!), or “Cancel” to revert to the original texture.

Finally, for yet another way to select a texture, you can click the pipette button that you will see below and to the right of the “Default” and “Blank” buttons. You can then click on any other visible prim, and the texture will be picked up from that prim (provided that is it copiable).

For now, however, click the “Default” button, so that you end up with a plywood cube.

Another way of applying a texture is to drag it from your inventory and drop it on to the texture image in the Build dialog. This tends to be a bit more tedious and awkward than using the Texture Selection dialog.

Back on the Build dialog, to the right of the texture image is a “Color” image. This will be white at the moment. Click on it, and a color selection dialog will appear:

Color Selection Dialog

Color Selection Dialog

If you have ever used paint programs, this will probably seem quite familiar, and I won’t go into details about it.

Select a color.

Your cube will still have the plywood texture, but will now be colored. You can do this with any texture, so it is quite possible to generate different-looking textures from one basic texture.

For example, here is a basic, greyscale “drape” texture, with different colors applied:

Colored Drape Examples

Colored Drape Examples

Now, suppose you want to have different textures on different sides of the cube. Of course, you can use the drag method that we saw above, but this is rather tedious and inflexible. A better way is to use the “Select texture” radio button which you will see on the top half of the Build dialog.

Select Texture Button

Select Texture Button

Click this button, then click on one side of the cube. A symbol will appear on the cube, showing you which part is currently selected:

Selected Face Example

Selected Face Example

If you now click the texture image on the Build dialog and select a new texture, it will only be applied to that side.

You can select multiple sides at once. Hold down the Shift key on your keyboard as you click on the sides you want to select.

In theory, you can also do this with multiple prims, and apply a texture to the sides of several prims at once. In practice, I have found that SL does not handle this very well at all, and it is probably best to stick to one prim at a time.

There is one more way of applying a texture, which is by using a script. This is something you might do if you want the texture to change in reaction to some event, but is well beyond the scope of this tutorial. I shall probably cover this in a later, more advanced tutorial.

That was quite a hefty first tutorial. I’ll be back later with the next one, when I’ll talk about the Repeat, Rotate, and Offset parameters.