Jump to content

ALPHA PROBLEM


ermanart
 Share

You are about to reply to a thread that has been inactive for 170 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi Everyone. 

I have transparency problems in a subject that you will see in the pictures below. There is no problem in the first picture. But the object looks wrong when the camera angle changes. As in the second picture. Please Help.

Sample_01Sample_02

 

Link to comment
Share on other sites

That's alpha sorting (sometimes called the "alpha glitch"). It's a rather common problem in SL, but it's not an SL issue per se.  It's a factor in any environment that uses OpenGL. You have three choices:

1. Do not use 32-bit textures at all unless you really need transparency.  It's a waste of system resources and can create the sorting problem if you have two textures reasonably close to each other.

2. Use Alpha Masking instead of Alpha Blending unless you are trying to create partial transparency (translucency). Alpha masking is more efficient anyway and will not result in a sorting issue.

3. Avoid overlapping alpha blending 32-bit textures as much as possible and keep your fingers crossed.

  • Like 4
  • Thanks 2
Link to comment
Share on other sites

Rolig had the answer to this particular case of course: never upload textures with an alpha channel unless they really need transparency.

But since she mentioned the alpha glitch, there is a trick that sometimes work but not many people seem to know about.

The alpha glitches occurs because the viewer has problems deciding which of the two transparent surfaces is closest to the camera. If they are far away from each other, there won't be any problems, if they are close, you get alpha glitch. So keep the surfaces well apart and the problem is solved. But there is one catch that often causes problem but can also occasionally be taken advantage of: the viewer doesn't calculate the distance from the surface but rather from the center of the object it's part of. Your pictures show that very clearly. In the first picture, the center of the log pile is closer to the camera than the center of the vegetation so it looks right. In the second picture however, the center of the vegetation mesh (or prim?) is closest and it is shown in front of the log.

There are several ways to shift an object's center away from the visible parts. With prims we can use pathcut or slice, with sculpts we can move all the vertices towards one edge in a image editor and with meshes we can add invisible "balance triangles".

A good example is the classic semitransparent curtain behind a semitransparent window. that combination is always tricky since the two surfaces will always be very close to each other. Add an extra triangle with a separate face to the curtain mesh, postion that triangle so it ends up well inside the room and far away from the window and texture it with a full transparent texture and alpha masking. Job done!

Edited by ChinRey
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

This is an intriguing solution. I don't need to worry about alpha sorting much myself these days, so it hadn't occurred to me that adding an extra triangle to a mesh object might work.  I'll have to try that one.

As with so many things we do in SL (and RL, for that matter), our choice of strategies is rarely as simple as we would like.  There are tradeoffs in almost any situation. Adding that extra triangle might solve an alpha sorting problem at the cost of modifying the object's bounding box or L.I., for example, or affect the way that the object moves. You'd have to evaluate whether any of those potential downsides is worth worrying about on a case by case basis. If it turns out that the effects are insignificant, at least you kept them in mind.  Your best tools in design are imagination, awareness, and a large toolbox of strategies.

  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...

ChinRey's suggestion is a clever trick, but I can't stress enough that if your texture doesn't use an alpha channel, make sure it does not have one when you save it for uploading. Whether or not SL renders the alpha channel (as Rolid pointed out, you can disable it in the edit panel) it does add to the file size of the texture, which means it will eat up more VRAM.

Most content in SL eats up  so much more VRAM than it needs that it's fair to say that most performance issues in SL come down to VRAM bloat. Not uploading textures with useless alpha channels is one good way to reduce that in your own content.

 And if you do need the alpha channel, try to use masked whenever possible. Not only does it get rid of the alpha sorting glitch, but it's far easier to render than the default "blended" mode. A lot of sim creators have seen a very noticeable framerate boost in their sims simply by setting all of the alpha textures they use to masked and reserving "blended" for limited cases (ie: water and light effects).

Edited by Penny Patton
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 5 years later...

Ok, I realise I'm reviving a very very old thread here, but I figured that's probably better than creating a new thread for what appears to me to be the same issue i'm currently having.

So, I'll try and keep this simple.  I am trying to retexture a windscreen of a car in SL.  In this instance, all the windows of the car are a single face, using one texture.  The texture has the shapes of each window in it, with each shape being a semi-transparent green/black colour, against a 100% transparent base, that has been uploaded by the creator as a png file.

I am trying to paint a design onto the windscreen that's fully opaque - so no transparency at all, the idea being that when the texture is used on the car, you can't see thru the windscreen at all.

So, the issue is, when I apply this texture, i get the dreaded alpha clashing problem, where the rear or side windows become visible through the front windscreen, even though the windscreen part is 100% opaque.  It doesn't matter what format I use to save the texture, it still has this problem.  The default texture somehow doesn't, even though technically if you look front to back, you'd be looking at two semi-transparent sections, one behind the other.

I don't understand how there is no clash with two semi-transparent areas against each other, but there is a clash with one opaque and one semi-transparent areas.  So far, from what I've tested, my only conclusion is that because the default window "parts" are all the same colour, they might actually be clashing, but it's not noticeable due to them being the same colour, where as my windscreen design is totally different colours.  I'll also add that using the alpha-mask option solves the issue, but of course either renders the semi-transparent parts full opaque, or fully transparent, depending on what the alpha mask cut-off is.

I've added the pic below to show the texture - the white area is where my design is (actual design is hidden though)

Is this the typical unsolvable alpha issue or have I had a brain-fart and forgotten something?

problemalpha.png

Link to comment
Share on other sites

14 hours ago, Eowyn Southmoor said:

So, the issue is, when I apply this texture, i get the dreaded alpha clashing problem, where the rear or side windows become visible through the front windscreen, even though the windscreen part is 100% opaque.

Alpha blending is set per texture, not per pixel, so having opaque details on an alpha blended texture will be subject to the same old alpha sorting issues. At least some viewers have a "fake masking" trick: if there are sufficiently few pixels that aren't fully transparent or fully opaque, a blended texture is rendered in masked mode instead, but that's also limited to the entire texture, not just individual pixels.

14 hours ago, Eowyn Southmoor said:

I don't understand how there is no clash with two semi-transparent areas against each other, but there is a clash with one opaque and one semi-transparent areas.  So far, from what I've tested, my only conclusion is that because the default window "parts" are all the same colour, they might actually be clashing, but it's not noticeable due to them being the same colour, where as my windscreen design is totally different colours.

That's my guess as well, alpha blending 2 identical colors with different alpha will always look the same, no matter which is on top, and you can get away with minor differences without really noticing. On the left: 2 alpha blended textures, top layer plain green, bottom layer gradient green to black, correct apparent order. On the right, camera nudged a fraction of a degree: top isn't noticeably glitched, but bottom part starts to stand out due to the shading differences.

image.png.c84383f17b7e77a2b302f4fb6a800acf.png

 

Link to comment
Share on other sites

@Frionil Fang Thanks for your reply, and you've pretty much confirmed my own testing. I had basically given up on the idea until about half an hour, where i had a bit of an idea.

Behind the windscreen I've rezzed a single prim, shaped to fit it as best as possible. On all faces of that prim I've set a blank texture at 100% transparency, with the exception of the face that points towards the windscreen - that is set to 0% transparency. Doing it like this, when looking from rear to front, the windows all look fine and you can see out, but now looking from front to back, the alpha clashing issue is solved because the texture behind my modified windscreen is just a standard blank texture.  Silly workaround but it works :)

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 170 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...