Wednesday, June 26, 2013

New alphas, a crash course

The new Materials feature has added in a number of new features- one being more control over alphas.  We've only been asking for the ability to use 1 bit alpha masks since....the introduction of the stupid alpha flicker issue so, that's, what, 7 years?  I don't even remember.  It's been a long time.  But we have them now, finally.

In the Texture panel in Build, there are more dropdowns and thingies now.  Right now, we are interested in Materials, Texture (diffuse).  Under that, Alpha mode, and the dropdown there gives us options, huzzah.  Note: make sure you've selected a texture face with an alpha (transparency).  No alpha, no options.

None just turns off the alpha channel, as if you uploaded a solid texture, no alpha channel at all.

Alpha blending is the default for textures with an alpha channel.  This means an 8 bit alpha mask, gradual alpha transparencies with gradients, the old potential alpha flicker issue.  They added an option in the Develop menu that would turn this "off" (make them 1 bit) for all alphas that were also set to 0% transparency a few viewer iterations ago, Develop>Rendering>Automatic Alpha Masks (non-deferred).  THAT IS STILL THERE.  THIS CAN SCREW STUFF UP.  If that is checked, which it appears to still be by default, even if you have it SET to use 8 bit transparency, it won't- if it doesn't feel like it.  Here's the fun part, kids, it used to always just set it to 1 bit, now it seems to decide for you, and it may not decide the way you want to.  To force it to use 8 bit transparency, up the Transparency % to 1%.  It's such a small bit you won't see it, but it will force it to use the alpha properly.  Why is this a deal?  Because any gradual transparencies will no longer be gradual.  It will be on or off, sharp edges, no transparent glass or soft edges or shadows- when it decides you shouldn't have them.  This is also a deal because it's set on the viewer side, NOT server side- so while you can set it in your viewer to show things the way you want, that doesn't guarantee what other people will see.  And because it's viewer side, there's no way to really know where the cutoff is for everyone (especially once you get into the whole mac vs. windows vs. linux thing).  Bright side?  It does actually seem to be smart about it now, whereas before it just destroyed everything.

But!  Now we have another problem.  Full bright no longer consistently works on alpha blended textures- even ones the deferred rendering makes solid.  For some people, it is never full bright, ever.  For me?  It is sometimes, and then not others, which is extra fun!  Generally it is renders fullbright to begin with (but doesn't even always start out full bright), it will cease to once I select it, and stay that way until I reload the object entirely (tp out and back in, relog, etc.- toggling the Automatic Alpha Masks also seems to go back and forth between full bright and not, turning non-deferred on kills full bright).  If you have alpha cutout vendors, this is a problem.  One that you will want to fix by using Alpha masking instead- but you sacrifice all gradual transparencies once you use that.

Alpha masking is 1 bit transparency.  This means everything is on/off, no gradient transparency.  Thankfully, it isn't entirely pixel by pixel based, but will smooth out your angled lines on the cuts- just like Automatic Alpha Masks (non-deferred).  Things that already used this are the avatar- alpha masks, and the edges of the system skirt when you had anything with a transparency- and system plants.  Upside to this?  No more alpha flicker!  That's why we've wanted it forever!  Also it's a little easier on the system in general, so it's a good idea to use it if you can get away with it anyway, but your alpha edges will be harsher, and smoothed angles still may not be actually straight, but may be lumpy.  Still, full bright with alpha masking seems to work properly for everyone!

There is a slider under Alpha masking for Mask cutoff.  This defaults to 0.  Defaulting to 0 is stupid.  That is just the same as setting it to None for the Alpha mode, it's solid.  What you will almost always want is 127, that is the center of the range.  Lower means more will be solid, higher means less will- if you have a haloing problem with your alphas, you'll probably want to set that number higher, possibly as close to 255 as you can without moth eating chunks in the middle unevenly.  And you'll want to learn ways to avoid that haloing issue, see my previous post for some tips on that (though for solid cutouts, which is what you need here, taking pictures huge with antialiasing off, and shrinking after you've cut them out from the background will work, so long as you fill the empty background with something like the solidify filter with your alpha channel in an actual channel).

The last option is Emissive mask.  This also turns your texture entirely solid.  Full bright also completely destroys this option, because what it does is choose WHAT to make full bright.  The solid parts of your texture will be fullbright- the transparent parts will be rendered with the surrounding lighting!  It does not do gradual transparencies well/at all, and you can't adjust what it sees as solid/bright, so make sure you have a VERY clean mask before using.  This and None are the least backwards compatible- it will just show the regular alphaed out texture if you are using a viewer without materials, both currently show no alpha, but also no emissive fullbright area, on a materials viewer with Advanced Lighting Model off.


Tiffy Vella said...

One very satisfying thing I found to do with this is to fix the existing (moddable) trees in my garden. The alpha masking with 127 cutoff works well on some of the older trees already out there, and it's great to be able to remove the alpha fighting between the crossed-over leaves.

Lord DoomRater said...

So I discovered a very annoying issue with Alpha Masking.... using it on a sculpted prim recalculates its land impact! So suddenly that one prim group of trees I have has a land impact of 2 per tree group. What's the point of using the new settings if they make the land impact go up...? In all honesty, why doesn't it make the land impact go down? It can be more efficiently rendered now!

Allegory Malaprop said...

Lord DoomRater:

It's to do with meshmath. New modes = new calculations, and sculpts get grandfathered in to old math by default. They are less efficient than mesh (for a variety of reasons), we just get the bonus IF you don't do anything to switch the math over- using a new mode (specular, normals, transparency), linking it to a mesh, or playing with Physics (Physics None is great, and efficient, but will drop you into meshmath). Look at the More Info information in Build with things selected to know how meshmath will calculate them, it's based on a variety of factors, Display is the one that will bump sculpts up regardless. You can game it to some degree by linking in more prims to your linkset with minimal Display (like legacy prims that DON'T have complex physics or if they do, physics are set to None). Physics can be games by removing things from the Physics calculations by setting Physics None, and Server, well, there's no real getting around Server (other than planning complicated linksets to trade off with Display), as that's .5/prim + .25/script, rounding.