May 18, 2011

Alpha sorting and masking in Second Life

Oooooh, sounds fascinating doesn't it? Yeah right! You're probably saying to yourself -- WTH Snick??  What's this got to do with fashion or anything else in my Second Life experience?? Let me try to explain.

Second Life Alpha Masking and Sorting Illustration
Have you ever noticed when looking at an object in SL that you can't quite tell what part of the object is in front or in back? Here's a quick illustration I made in SL to show you.

Alpha sort demo

This is supposed to look like two disks crossing each other. C is how it should look. A & B show how it actually looks in Second Life from two different angles.

I made the object using two flat, square prims with a filled circle texture applied to the front and back faces. The circle texture has an "alpha mask" which effectively hides the unwanted parts of the image. 

Second Life renders the masked part of the image as transparent. Without the mask, the square corners would typically show as white. (D shows how the texture itself looks in Photoshop. The dotted line is the outline of the mask.)

What's happening in A & B is that Second Life can't decide which part of the object should be in front and which should be in back. So you get that weird flashing look where parts of the object normally in back will suddenly jump in front depending on your viewing angle. You'll see this problem in everything from prim trees to prim skirts and outfits. Even worse, try standing in a building with lots of windows. Sometimes it will look like objects that are physically OUTSIDE the building will look like they are inside and vice versa.

We need answers!

So why am I writing about this? Simple. Linden Lab has known about this issue since forever; they seem to have the ability to MOSTLY solve it; and yet, they haven't done so. A simple case in point is that Linden trees do NOT show the sorting problem YET Linden trees use alpha-masked textures. I won't bore you with all the technical details (frankly, I don't fully understand them myself), but I will point you to the JIRA issue that was created almost 3 years ago. I got involved in the issue because it affected my fashion designs and dammit, I wanted it fixed!


Three years and still NO Lindens assigned to work on it. Three years and numerous solutions offered by residents but no action. In fact, reading between the lines from some posts by Lindens participating in the JIRA discussion make it sound like one of their proposed fixes could be worse than the original problem.

So if you'd like your Second Life builds, outfits and general experience to be better, please view the JIRA issue above, log in and VOTE for it. You can also drop in a comment such as "Fix this now." Maybe then the Lindens will take it seriously.

3 comments:

  1. I did so. My very first build in SL 4 years ago suffered from this.

    ReplyDelete
  2. Actually this issue is more of not giving us the tools. Every game engine out there will have this problem but the designer know these limit and build accordingly. But they have a whole slew of texture tools. SL is really lacking a materials editor of some sort. Like the game Unreal the material editor allows you to choose how to handle a simple texture. With a hand full of textures an unlimited number of effects and new materials can be made without having to make new textures.

    For example if you have a shadow map for a sculpt and a wood grain texture. you first have to combine the two in some image editor then upload it back into SL. The materials editor would allow you to layer the two textures and also allow you to adjust the method of blending and how much blending to be done. It allowed you to change out base texture without having to re-upload a new texture. It would be great if SL had Materials and not just plain old slap a texture on an object.

    you can see here how one little texture can have so much done to it. I would not expect SL to have something this complex but some nice blending would be nice. http://udn.epicgames.com/Three/MaterialsCompendium.html#How to Think About Color When Creating Materials

    ReplyDelete
  3. Hi Anonymous, if you read the JIRA, you'll find that the solutions offered include being allowed to flag your texture upload as a 1-bit alpha rather than as a gray-scale alpha or being able to set the texture on the object face as a 1-bit alpha at design time. 1-bit alphas CAN be sorted more or less correctly - Linden trees use 1-bit alphas and don't have the sorting problem. So in a sense, yes it's a tool issue but the fix is pretty simple according to the smart people in the JIRA thread!

    ReplyDelete

All thoughts are welcome.