In the past months after i disabled the Automatic Alpha Masking option in deferred by default a bunch of people messaged me about "strange" rendering issues. Of course i knew exactly immediately what they were talking about and i feel it is getting too tedious to explain this over and over again to each and every person, which is the reason i'm going to write this.
First things first. What is the problem? It is this:
Notice how the cubes form an abstract art like impossible image. Notice how the right most cube is in front of the bottom one while at the same time behind it. Notice how the top cube is behind all of the other cubes whereas it is actually on top of them, the cube is casting a shadow too, you can see it coming through. So what is this? It is called z-fighting, more specifically in this case it is alpha sorting (the issue, not the alpha mode).
The renderer has issues deciding whether a given face is in front or behind another due to them using alpha rendering rather than normal solid rendering. I can't explain to you why this is a thing (regardless of if you use DirectX or OpenGL) but my personal assumption from what i know about rendering is that alphas are not included into the depth map. The depth map is (as you may have seen if you used the depth mode in the snapshot floater) a greyscale image that contains depth information for the renderer to sort objects and do all kinds of neat things. Since alphas are not included in it, the renderer has no solid way of telling which face comes in which order so it has to make guesses and and that's when this alpha sorting issue will happen.
To counter this, there are many many MANY things both the developers and the creators can do, generally the best idea which most games as of today follow is simply avoiding blend alpha as much as possible because and this is the thing, this ONLY happens with alpha blending, not with alpha masking. Alpha masking is a 1 bit alpha channel (either on or off, invisible or not) thus it can be handled like any solid surface without much problem unlike 8 bit alpha which is alpha blending.
So why not make everything alpha masking? Well... see... as much as i would like to, this is the issue. You can't just set everything to alpha masking and BAM everything is fixed, each texture is unique and needs a unique alpha masking cutoff value to go along with it so the renderer knows at how much transparency it should simply use invisible rather than visible. Even worse, some textures simply can't use it because they need the alpha blending such as if you want a color grading overlay or say transparent textures like water or other fluids. In these cases we must use alpha blending.
This will inevitably cause different alphas to clash with each other and cause alpha sorting if looked at from certain angles. Myself as furry i had this issue happen long ago very often. Every single club had a transparent floor, transparent particle clouds for fog and transparent laser lights and such all over and guess what happens if you tail is a flexi alpha blending surface? You guessed right, it's gone. It will be sorted behind all the other stuff... in between... sometimes in front and everything in between that. It's a well known issue and i'm pretty sure you have seen this happen somewhere already.
But this isn't everything, alpha surfaces are not subject to most graphical effects that use depth such as Screen Space Ambient Occlusion (SSAO) and Depth of Field. In the latter case the renderer has to reside to some dirty hack by forcing all alphas internally to solid surfaces (without masking cutoff) and using those into a new depth map with those included, the result is Depth of Field going off on places it shouldn't. Here's an example of this:
Notice how the alpha glow effect is handled as solid surface, blocking and overwriting the depth to go further resulting in depth of field looking kinda broken. The same happens with particles too.
In the case of SSAO, which simply doesn't work on alpha surfaces, you'll have to look closer. It is highly possible that in any other Viewer other than my own you most likely won't notice the absence of SSAO as SSAO is by default extremely weak and almost not distinguishable from the same scene without it. Here's an example with top being alpha, bottom being masked:
Lastly shadows. Shadows from and and on alpha surfaces have all kinds of issues. For once they don't get the soften light pass which means they are pixelated rather than blurred and softened. Shadows cast from alpha surfaces have similar issues, they appear less precise and break faster than solid shadows. See these examples, top being alpha, bottom being masked:
So why all this? What are you trying to tell me Niran? I know what alpha sorting is and if i didn't i now know about it, what's the deal? The deal is many many textures in Second Life contain an alpha channel when they shouldn't which will flag any surface you use them on as alpha blending automatically which will cause all of the above mentioned issues. What's worse, Linden Labs made a feature called Automatic Alpha Masking (Deferred) and Automatic Alpha Masking (Non Deferred) for deferred (advanced lighting model) and without it respectively, these options are a hack employed before Materials was introduced, which gives us the ability to control whether we want to use masking or blending for alphas. The issue with these hacks is that they are just that, dirty hacks from pre-Materials times that are still in effect by default, they do a piss poor job at actually masking surfaces they are applied to and they hide the fact that your texture has an alpha channel and a whole host of graphical issues coming with it. To elaborate: Automatic Alpha Masking does stop quite a few surfaces from doing the alpha sorting, given they are solid textures but with an alpha channel included (which shouldn't be included), thus stopping the alpha sorting issue to appear on them but.. this only goes for simple objects and surfaces. Enter meshes. Shadows are still pixelated, SSAO doesn't work on it, lighting is off and so on. Here is an example comparison between Automatic Alpha Masking (top) and manual masking (bottom) on meshes:
Notice how the purple light on the left doesn't have any impact on the automatic one but clearly shows up as it is supposed to on the manually masked one. Notice how shadows are soft. Notice how the entire body looks much more part of the world, i dare to say "more realistic". This is with the hack enabled, yet its still broken.
So what to do about it now? First you have to ask yourself 2 questions. Can i edit the texture? If yes, do it. Remove the alpha channel if its not needed, this is always the number one priority fix. Fixing the texture means less resources wasted for you and everyone else as well as having the issue fixed once and for all. You can do this in GIMP by selecting the "Layers" menu at the top and going down to the "Transparency" sub menu, in it you'll find the option to remove the alpha channel. Optionally you can save the texture as JPEG if you are really unsure. JPEG doesn't know alpha and don't worry, SL converts all textures to a trash JPEG format anyway, no loss compared to PNG upload. If you can't edit the texture, ask the second question, can i edit the object? If so, select the prim or the single surface you want to change, go into edit mode (right click - edit) and select the "Texture" tab. Here you should find a dropdown menu that will be reading "Alpha Blending" by default, click it and change it to "None" if you are absolutely not using the alpha channel for anything.
Select "Alpha Masking" if you need alpha to cut off body parts or holes into said body parts for instance, then change the Mask Cutoff to a value that compliments the texture and makes it look good, usually something around 70-80 is a good value. I did so with my hair and it looks much better.
Textures that are made to be used for Alpha Masking obviously look even better. If you make textures always try to avoid using blending as much as possible, try to design your textures around masking. A great example of great masking usage is this Skadi Sergal:
Notice how it uses masking for the tail fluff, arm fluff, leg fluff, mane, ear fluff, chest fluff and pretty much any sort of details that resemble hair and it looks cute and fancy.
Because all these things are so horribly broken and Automatic Alpha Masking being the only thing that tries to hide it from the user i decided to disable Automatic Alpha Masking and show you the world as it really is. Broken.
But why are you doing this Niran? Why would you do this when all Viewers aren't doing it? Because i believe that hiding the issue won't help us fix it. Other Viewers are simply pussies, they fear backlash from their users, they don't have the willpower and energy to put up with you and explain to you what the issue is and how to fix it because they see you as completely retarded, on top of that, i've met quite a few extremely ignorant people who simply brush it off as Viewer bug and "not their cup of tea". Guess what, they are horribly wrong. It IS their cup of tea, THEY fucked up in their texture and it is THEIR responsibility to fix it. Only few will however and this is why i'm telling you so you can fix it yourself... if you got modding rights. I don't care if you complain at me that messy alpha is messy. I'll tell you that alpha is messy and that there are better ways to fix it than enabling a hack which merely fixes the sorting issue half of the time.
But hold on Niran... what about those poor people who bought no mod stuff? They can't just edit the mesh/object. Well... while that is correct all i can say is. Complain. Complain complain complain, not at me of course, at the creator who dares to sell you broken no mod stuff and if they want to get rid of you by finding excuses why not to allow mod permissions, send them to me, i'll give them a lecture when and where to use .... not use mod permissions. They will either listen or be ignorant, in the latter case you should stop buying their stuff and you should tell anyone and everyone to do the same, bad content creators are one thing, ignorant, improvement resistant creators are a whole nother thing. Don't support them. Instead you could buy one of those nice avatars for which you probably pay less. Support creators who put real effort into their products, who create good content, who are interested in improving Second Life with meaningful content, not some quick cash grab garbage.
To end this post, i've recently helped someone fix their Kemono and boy i was in for some fun, i ended up going through each and every face, making it invisible to see what it is, then set it to masking if its solid and blending if its an overlay. This cost me half an hour. I hate to say it but if you can't do it, i'm willing to help you and do it for you. Here are comparison pictures of before (top) and after (bottom):
Oh right. If you absolutely have to because there is absolutely no way around it. You can re-enable the Automatic Alpha Masking hack by going into Dragon - Develop - Rendering - Automatic Alpha Masking (deferred) and/or (non-deferred). I don't recommend doing it unless absolutely necessary, you'll be lying to yourself! Pink Glasses! Pink Glasses!
Got any questions? Did i miss anything? Tell me, i'd gladly like to know how to improve this ugly mess of a wall of a text.