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.