Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Prim + Texture with Alpha Channel = Problem

Miriel Enfield
Prim Junkie
Join date: 12 Dec 2005
Posts: 389
02-08-2006 12:21
I'm in the process of making a prim skirt, and I'm using cylinders and textures with alpha channels. Right now I'm using two cylinders, one big one with a bit cut away in the front, and a slightly smaller one inside it. The majority of each texture is supposed to be completely opaque -- I'm just using a little bit of black in the channel to reflect the folding at the bottom of the skirt.

The problem is that I can see through the cylinders to some degree. Here's a link to a picture of this: you can see the outline of my legs, and behind them, the inside of one of the cylinders.

Am I doing something wrong? Is there a way around this? Right now I'm thinking I should insert more prims, ones without partly transparent textures, behind the current two.

Thanks.
_____________________
Chip Midnight
ate my baby!
Join date: 1 May 2003
Posts: 10,231
02-08-2006 13:30
Two things you should make sure of... first make sure the portions that are supposed to be fully opaque have a pure white alpha. Second, make sure you don't have any transparency set for the texture under edit texture. Other than that you should be able to make it work the way you want to.
_____________________

My other hobby:
www.live365.com/stations/chip_midnight
Miriel Enfield
Prim Junkie
Join date: 12 Dec 2005
Posts: 389
02-08-2006 13:56
I've literally double checked both of those things: the white parts are 255/255/255, and the transparency is 0. I've even put other clothing textures on similar hollowed prims as a test -- textures I know don't have alpha channel issues, because I wear them around regularly -- and the same problem is popping up.
_____________________
Joy Honey
Not just another dumass
Join date: 17 Jun 2005
Posts: 3,751
02-08-2006 14:00
Miriel, what is the texture saved as? It looks to be a non-alpha saved as 32 bit TGA, try saving it as 24 bit TGA.
_____________________
Reality continues to ruin my life. - Calvin

You have delighted us long enough. - Jane Austen

Sometimes I need what only you can provide: your absence. - Ashleigh Brilliant
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
02-08-2006 14:55
If both surfaces (overdress and under-dress) have alpha chanel information, you may be running into the 'alpha-sort bug'. A possible cure is to ensure that the underskirt is 24-bit .tga, so it has no alpha chanel info. Additional layers under the two skirts won't help. It's the interferance between the two layers on top that is driving the rendering engine nuts.

You see this a lot if you have two transparent or partially transparent layers that overlap. For example, if the leaves of a tree, which are on an alpha-mapped layer, get between you and a wall that has an alpha-mapped window, you can see gaping holes in the wall where the leaves should be. Ive also seen it where a translucent screen is in the same line of sight as an alpha-mapped window. The rendering gets really strange.

I think you'll have to forgo the visual scalloping on the underskirt layer.
Robin Sojourner
Registered User
Join date: 16 Sep 2004
Posts: 1,080
02-08-2006 15:07
Hi Miriel! Welcome to the Wonderful World of Alpha Sorting!

It's not anything that you are doing wrong.

It's an inherent problem with all textures that posses an alpha channel in SL, even if that channel is completely white (totally opaque.) Whenever you have a texture with an alpha in front of another texture with an alpha, you're very likely to see the one in back in front of the one that's in front. (Did you follow that? :D )

This is used by people who do the flowers and trees and fires you see to their advantage; but the rest of us wish it would stop.

However, it's not going to.

The work-around is to have a prim without an alpha between the two. In your case, that would mean to have a prim with a 24 bit texture as the main portion of the overskirt, and another prim for the bottom edge, that would carry the Alpha. Do the same thing on the inner skirt, and the problem should be negligable, and visible only at the bottom edge.

Or go without the scalloped edges, so neither prim has an alpha channel.

But yeah, it's annoying, huh? If it didn't do this, we could make houses with half the prims we have to use, and all kinds of other neat effects. But Chosen says it's a problem with OpenGL and transparency in a lot of programs. (We don't have it in LightWave, but there are other OpenGL issues there, so it's a wash, I think.)

Sorry that I couldn't be more help.
_____________________
Robin (Sojourner) Wood
www.robinwood.com

"Second Life ... is an Internet-based virtual world ... and a libertarian anarchy..." Wikipedia
Rick Deckard
Cogito, ergo doleo.
Join date: 1 Apr 2005
Posts: 159
02-09-2006 09:53
You may want to give this a try. Instead of inserting more 24 bit-textured prims, try applying the alpha texture on the outer surface of the prims only and a 24 bit texture or no texture at all on the inner surface of the prims. It might work. I had a similar problem not too long ago. In my case, it was a dress with an alpha-textured prim overskirt and an alpha-textured regular underskirt (click the first link in my signature to see this particular dress). At the beginning, the two alphas were not mixing very well. But when I removed the alpha from the inner surface of the prim, everything was fine.
_____________________

Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
02-09-2006 11:28
From: Robin Sojourner
But Chosen says it's a problem with OpenGL and transparency in a lot of programs. (We don't have it in LightWave, but there are other OpenGL issues there, so it's a wash, I think.)

Robin, are you sure it doesn't happen in Lightwave? In Maya, believe it or not, you can actually turn this "bug" on and off at will, so you can model for applications that handle alpha sorting in different ways. I'm curious if Lightwave might have a similar toggle.

Anyway, Miriel, as Robin said, what you're seeing isn't a result of you doing anything wrong. Most 3D applications have this problem. When two 32-bit textures (32-bit means they have transparency) are placed so that they overlap in close proximity, the renderer has trouble determining which one to draw first. As a result, the one in back can end up superceding the one in front, depending on the camera angle. The surface most facing the camera usually gets priority. For round objects like hollow cylinders, the one in back (the inner surface) usually wins from any angle since it can be interpreted as curving toward the camera, while the outer surface is more easily interpreted as curving away from the camera.

The upside to this is certain objects, like plants and fire, for example, can be built to take advantage of the glitch. Put a flame texture on 2 or 3 criss-crossing planes, and you've got a fire that will appear to face the camera at all times. The one most facing you will always be visible, and the ones more oblique to your point of view will disappear.

My understanding of OpenGL is limited, but from what I've been told, correcting this "bug" is pretty easy. However, were it to be fixed, all object built in the way described above would break. So, it's an issue of dammned if you do and damned if you don't. Since pretty much all video games have the bug, I guess it makes sense that SL should to. It makes certain objects like your skirt problematic of course, but it also makes other ones possible.

The key is to learn to build around it. There are 5 things you can do here:
  1. You could simply make the skirt prim not hollow. There would be no inner surface, so there'd be no overlapping alphas to sort. If you want the skirt to be translucent, so you can see your legs through it, this your best option.


  2. Or, you could put a 24-bit texture on the inside. This would eliminate your wavy bottom on the inside surface, and replace it with a flat bottom, but with good shadowing, it could look quite nice.


  3. Or, you could do as Robin suggested, and put a second cylinder inside the first one, with a 24-bit texture on the inner one. This would effectively block the overlap for most of the skirt. I would suggest making the inner one slightly less tall than the outer one, so that it doesn't cover the bottom. This way, your wavy bottom could still be visible. You'd still have sorting problems at the bottom then, but the overall effect would be far less noticeable since it would be only in a small area.


  4. Or, you could bult the skirt in stages, with an upper part and a lower part. The upper stage would have a 24-bit version of your skirt texture, offset to show all but the very bottom of the image. The lower stage would have your 32-bit version on it, and would be offest to show just the wavy bottom part of the image. The effect would be similar to that of the third option. You'd have an alpha sort issue with the bottom part of the skirt, but the rest of it wouldn't be transparent, so the problem would be confined to a small area.


  5. Or, instead of using the texture to do the work, you could physically build the wavy skirt bottom out of prims, and use 24-bit texturing on the whole thing. This would be the most realistic solution, but the more prims you use, the more laggy your av will be, so it might not be worth it.


If it were me, I'd probably just use an opaque texture (24-bit), let it extend all the way to the bottom, and make it appear frilly with good shading. I realize that's probably not the answer you wanted, but unfortunately SL does have its limitations, and we always have to make choices based on those limitations in everything we build. To me, putting a wavy bottom on a big skirt is not worth the trouble for such a minor feature, but if you feel differently, then by all means play around with the options and see what you think works best.
_____________________
.

Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.
Miriel Enfield
Prim Junkie
Join date: 12 Dec 2005
Posts: 389
02-09-2006 15:43
Thanks, everyone. I was beginning to suspect it was some kind of bug.

From: Rick Deckard
You may want to give this a try. Instead of inserting more 24 bit-textured prims, try applying the alpha texture on the outer surface of the prims only and a 24 bit texture or no texture at all on the inner surface of the prims.

I already tried this, I think: I put the alpha channel texture on the outside, and the default blank texture on the inside. All that happened was that I could see the blank texture from the outside now, instead of the inside version of the alpha channel texture.
_____________________