Posted in General, Second Life

The Art of Prim Reduction (and changing pictures with the click of your mouse)

[Originally posted on 14-Apr-2012, updated 20-Jun-2017]


I’ve been trying to reduce my prim count at my home in SL, and one of the things I figured I could improve on is the pictures hanging on my wall. I’ve got 4 walls of pictures, and each has 3-5 pictures on it, each one on its own prim. So I could see some good savings there.

But how to reduce that number?

Well, a picture is just a texture on a prim. And a wall is also just a texture on a prim. So why not combine the two? Bake the pictures onto the texture of the wall itself.

However, unless you really are pinching every single prim, I think it is better to spend an extra prim per wall and create a transparent veneer onto which you bake your pictures. Think of it as a single picture frame prim that happens to contain multiple pictures. I will refer to this as a “veneer prim” or “veneer” for the rest of the article as it covers the wall just like a wood veneer. However, as I will shortly explain, it is actually preferable for it to be smaller than the wall itself but that doesn’t alter the fact that it is a veneer of sorts.

So what’s wrong with baking the pictures directly onto the wall? Well, in many cases you may not have access to the texture of the wall itself. There are ways round that, of course, but I won’t discuss or condone any of them. But if you ask the creator of your house nicely for the texture, and explain nicely why you want it, they might send it to you.
But even if you do have the texture, most walls tile their texture multiple times per face. Unless your wall uses a single high resolution texture that is repeated precisely once per face then it’s unlikely that baking it directly onto the wall texture will work.
The other thing we need to bear in mind is that the maximum allowable size of a texture is 1024×1024 pixels, as defined on the Limits page of the Second Life Wiki.
So as the size of your wall or veneer prim increases, so the resolution of your pictures is going to fall and you will lose detail. This is called Pixel Density, and you want to maximise this as much as possible, and you therefore want to make your veneer prim as small as possible, since for a given number of pixels the density is proportional to the area. Don’t worry if you don’t get what I mean, it will probably become clear as we progress.

Finally, considerations of texture repeats and Pixel Density aside, it’s just downright tricky and dangerous to directly change wall textures as you run a real risk of accidentally painting your whole house with your new texture since walls are almost always part of a Link Set.
I did exactly that and it was pretty annoying to suddenly find your entire house covered with copies of your pictures as if it had been gift wrapped! And even worse when you find that ‘Undo’ doesn’t include textures. I had to delete my house and rez from a backup to undo that – making sure I copied the exact position and rotation of the current house so I could apply it to the new one (a useful technique to remember, incidentally).

So I will make no further mention of working directly with the wall textures and will leave that as an “exercise for the reader” should you really want to do that.

Creating the veneer prim

Create a new prim using the build tool, making sure you create a box. Don’t worry about it looking like a block of wood just yet.

We want to size & position this prim so that it just covers the wall, just like a wood veneer. However, due to the Pixel Density issue I mentioned earlier, you want it to be as small as possible. Pictures very rarely go right up to the ceiling, so you can gain some vertical resolution by making this prim shorter than the wall. Likewise pictures very rarely go right down to the floor, especially when furniture is present, so you can reduce the height still further by making the bottom edge higher than the floor. Finally, pictures very rarely go right to the edge of a wall, so you can reduce the width too.

To give you an idea of the dimensions you require for your veneer prim, you may want to get the dimensions of your target wall. Your wall will almost certainly be part of your house, so you will need to edit your house and select ‘Edit Linked Parts’, and then click on your target wall to get the dimensions of that particular prim. Don’t change anything on your wall and definitely don’t click anything called ‘unlink’!
If you followed my advice in my article “Oh no! I deleted half my house! (and other disasters)” and locked your house, then you will need to unlock it long enough to get the dimensions as all the edit boxes for the size, position and rotation are greyed out and blank when an object is locked. Be sure to lock it again after!
Please also refer to that article if you are unsure as to what I mean by getting the dimensions.
You might find it more convenient to copy all of the values for size, position and rotation from the wall first, say into a text document, rather than switching back and forth between the wall and the new prim. It’s up to you.

Of course, you don’t have to do any of that; you can just do it by eye if you wish.

Apply each of the rotation values to the new prim so that it is correctly oriented with the target wall, and size it appropriately as discussed above.

You don’t want to set all 3 position values of the new prim to the exact position as the wall, as if you do and then accidentally deselect it, you may lose your new prim inside the wall and be unable to select it again.
Instead you want to position the prim so that it is slightly proud. In other words, it just protrudes from the wall, but only by a small amount; if you make it protrude too much then your picture will appear to hover in mid-air in front of the wall, and if you make it flush then it will have interference patterns with the texture of the wall.

You may also want to adjust the thickness of the new prim to a smaller value than the wall. It’s not really necessary though.

Now go to the texture tab and set the transparency to 100% and also click on the texture swatch and search for ‘transparent’. You should then see the ‘Default Transparent Texture’ in the library which you can select.

Please be very careful that you do all this to your veneer prim and not the wall! In fact you should really lock your house as mentioned earlier to prevent exactly this kind of mishap.

Creating the texture

We now need to take a little trip into Real Life. I know, it’s scary. Don’t want to spend too long there as it can seriously affect your SL! But just look at the prim count on the trees and the resolutions in RL! ;o)

But just before we do, note the dimensions of the veneer prim and calculate the aspect ratio. So, for example, if the prim is 10m wide and 7m high, it has an aspect ratio of 1.42857:1 (which is calculated by dividing the bigger number by the smaller number).

So, to RL now, and you’ll need to fire up your favourite graphics editor, whether that be Photoshop, GIMP,, Paint Shop Pro, or whatever. I use GIMP because it’s powerful and free.

Create a new image which is 1024 pixels high and whose width is determined by the aspect ratio you calculated just now. So in the example I gave, the width is 1024 multiplied by 1.42857, which is 1463.

Import each picture you’re going to have on the wall as a separate layer, and then size & move them appropriately until you have everything how you want it. It’s important that each layer has a transparent background so that all the pictures layer up correctly. It’ll be pretty obvious if you’ve got that wrong.

Unless you want your pictures to look like posters, you may wish to add a bevelled frame to each picture. How you do that differs on different graphics programs and is beyond the scope of this tutorial. If you Google for how to add a frame to a picture you are sure to quickly find how to do it. With GIMP I use a Script-Fu called “Add Frame with Bevel” and tick the box which adds a wood texture to the frame and that works for me.


Save your picture as a PNG file or TGA, making sure you preserve transparency, and in the case of TGA you untick compression. Preserving transparency is important. Note that you should not save as a JPG (jpeg) file as that format does not support transparency.

Now, we need to get the texture back into SL.

Applying the texture

Fire up your SL Viewer and, when ready, upload the PNG or TGA file that you just saved. It will cost you L$10 to do this. It’ll probably end up in the Textures folder of your Inventory.

We’re almost there now. We just need to apply the texture to the veneer prim. However, before you do, you may want to take a backup of it first and also note its dimensions (size, position and rotation) in case you mess up and need to restore. Right-click on it and navigate to “Take a Copy” to take a copy of it.

So, select the veneer prim and then drag your texture from inventory onto the correct face. You can also use the texture picker from the prim itself, but you must choose the ‘Select Texture’ setting and then select the face, or it will apply the texture to all faces and you don’t want that.

If you get it wrong then it’s not the end of the world – assuming you took a backup. You *did* take a backup like I told you to, didn’t you?
Before deleting the one you messed up, note its position and rotation (if you didn’t already) then delete it and rezz your backup copy, then apply the position and rotation to it and it will snap to the exact same place. Or, if your Viewer supports it, use “Restore to Last Position” with the backup copy. Either works.

So if all went well, you should now see your pictures on your wall, whether it be directly (if you chose to do that) or with the veneer prim.
It could be that they are rotated or back to front, in which case you will need to play around with the Flip checkboxes and also the Offset values. Make sure that Repeats are set to exactly 1.0 per face otherwise it will be tiled.
Assuming you correctly calculated and applied the aspect ratio then the pictures should look correct and should not appear stretched or squashed.

Are we done now?

Well, we can be. You can finish here if you want. But if you stick around I will show you how to have it so you can change your pictures at the click of a button.

But wait! There’s more!

I’ve developed a script which allows you to set the texture on a prim, either by touch menu or voice command. Depending on settings in the script, the texture can be applied to just one or to all sides of a prim. Obviously we’re interested in applying to just one side.

Create a new script inside the veneer prim (if you’re applying this to the wall directly, you’ll probably want to unlink the wall from the rest of house or else clicking anywhere on your house will activate this script. So that is yet another reason not to work directly with the wall!). Rename the script to whatever you wish – it doesn’t really matter. Then replace the contents of the script with my script and then save and close it.

Repeat the steps from “Creating the texture” for as many as you wish and upload them as textures, and copy these textures into the same prim as the script (which will be the veneer prim in most cases).

By default the script will apply the texture to all faces, but we don’t want that. So to start off, make all faces transparent, either by saying “/45 set transparent” or by clicking the prim and selecting “(transparent)” from the menu.

We need to find which face to set, which is a little bit of trial and error. Say “/45 face 0” (that’s a zero not the letter ‘o’) and then “/45 idx 0” (again, that’s a zero). If the wrong face gets set, revert to transparent by saying “/45 set transparent”, then try “/45 face 1” and “/45 idx 0”, and so on until you hit the right face.

That’s it. We’re done. Have fun!

One thought on “The Art of Prim Reduction (and changing pictures with the click of your mouse)

Let me know what you think!

This site uses Akismet to reduce spam. Learn how your comment data is processed.