Now, I’m sure the source of this problem is my lack of understanding, but… I never seem to be able to get partial transparency to work correctly for me. I’ve had this problem a lot over time with other tools, but currently I’m using 3D Coat to texture my objects. The object in question today has a semi-transparent dome. If I apply any of the Transparent family of shaders, the whole object seems to suffer from transparency. If I use the Transparent Cutout family, I get the right feel, but (as expected) the semi-transparent parts are gone.
I’ve opened the textures up in GIMP, and the alpha channel looks correct. To ensure this, I added a layer mask to my texture and painted white onto the alpha channel to make sure the areas were filled. Nothing… sigh
Would any of you kind and wise graphics folks know of an approach I’m (obviously) missing.
Maybe you can post an image of your problem? I’m not entirely sure I understand your problem correctly, but from the description it sounds like you are applying a transparent shader to an object that is fairly complex and mostly solid - is this correct? Doing this using the cutout alpha shaders will work as expected, because the object is written into the depth buffer so pixels behind solid pixels will not be visible through to the other side. The downside is sharp, often aliased edges with no partial transparency*.
If you switch to alpha blended, which has “soft” edges, you might get polygons rendered through each other in a seemingly wrong way. The reason for this is that the alpha blended shaders do not write to the depth buffer, and because of this, the order of which the polygons are rendered matters (which in turn depends on how they are organized within the model). Unity can only use the depth buffer for sorting on a per-pixel basis, other that that it does it on a per-model basis (AFAIK) - it does not do it per-polygon.
If you need soft alpha on parts of your model, you better split up your model into two parts, one which is solid, and one which has translucent areas. Also note that these translucent areas benefit from being mostly convex (no dents), so that no polygons will overlap each other and thus potentially overdraw each other.
*There is a common workaround for this, and I think Unity uses it for their grass shader. First the grass is rendered using an alpha tested shader, and then rendered using an alpha blended shader on top of that to smooth out the edges. While not 100% artifact free, this often works well enough for stuff like foliage and hair.
Correct, this is a fairly complex object (a space ship with pilot). The edges in my case still seem smooth, I’m assuming because of the normal map, which I used to smooth the edges. (I’ll try and post an image later) The issue I run into isn’t the standard z-fighting (3D Coat does give me some of that when I look at certain angles of the cockpit). In this case Unity renders a side view fine, but if I turn or rotate the model you can see through the bottom or top of non-transparent parts of the model.
If I understand you correctly, making a small number of poly faces semi-transparent “confuses”(?) the matter (sorry… coder trying to keep up with the dark art of 3D rendering here ).
Ok, (this at least I think I understand) and I thought of taking this approach, I just haven’t gotten around to trying it yet. For my sanity’s sake, and overall performance, can I make a file (JAS, OBJ, FBX) that has 3 semi-transparent models, and apply a single UV/texture?
grass?!? HAIR!!! Ok, let’s take a step back :shock: I’ll render grass and trees well, when the Unity tree tool is completely … well… me proof (now you’ve heard it UT guys, if I can make that d*mned tree tool build and render a good tree, ya all can retire :lol:). Seriously, I"m not skating anywhere near that kind of detail. I’ll be sitting pretty if I can just simulate anything that looks like glass.
Thanks for all your insight, hopefully some day I’ll know enough about these shaders/renderers/graphics/etc… to completely understand what you’ve said here (or, better, I’ll be in a position to hire someone who can completely understand what you said here :lol: ).
In a vain effort to answer another posters question (I thought I knew that one ). I accidently applied the Nature->Vegetation Two Unit Pass shader, and it rendered the object the correct way (at least what I was looking for)!!!
Now, 2 questions…
what’s the overhead of this shader compared with Transparent (whatever) shaders?
It most likely renders the object twice, once with the alpha testing - where it writes pixels to the depth buffer so they are correctly ‘sorted’ (the one where it works but there is only on/off alpha, no half-way translucency), and once with alpha blending. At least this is what I think it does, I have not used it myself.
Because it renders the full alpha pixels into the depth buffer, then fills in with the alpha blended pixels afterwards. If you have no places you can see directly through your ship, this is probably why it works for you.
If I’m not horribly mistaken, this would be the grass/hair shader I mentioned above.
I tried Googling for some illustrated explanations on the issue, and the best one I could come up with in short time was this, from this very forum right here: http://forum.unity3d.com/viewtopic.php?t=13473
Transparent polygons have been a headache since the dawn of real-time graphics, and there is still put a lot of research into solving it.