- Home /
Transparency shader problem
I have looked through:
http://answers.unity3d.com/questions/37029/shader-layer-overlapping-problem
as well as:
http://answers.unity3d.com/questions/11821/weird-shader-problem
and
http://answers.unity3d.com/questions/32202/alpha-channel-for-selective-transparency
and tried to use the tutorial at:
http://unity3d.com/support/documentation/Manual/HOWTO-alphamaps.html
The problem is using a .png texture with transparency in a material on an imported .fbx mesh from blender, when changing that material's shader to any form of transparency/diffuse, diffuse bump diffuse, etc, I am having the issue where parts of the model behind other parts are showing through, even though that area should not have any transparency (only the hair planes are intended to be using the alpha to fade out).
My main question is, is this something I, the texture artist, am able to fix (I've tried the steps in the alpha tutorial, saved it out 4 different times in-case I was or was not supposed to hide certain layers, but had no success), will this fall to the 3D model artist, or to our programmer? I am not familiar with shaders, and I am not sure our programmer has a lot of experience with them yet.
Here is an actual screenshot of what is happening (the teenager's model is all I'm concerned with in this picture, I know there is also a fuzzy box I was toying with laying around).
http://i27.photobucket.com/albums/c166/Riaayo/Time%20And%20Again/Transparency_Problems.jpg
Any pointers in the right direction, or some help with the alpha tutorial if I have somehow done it wrong, would be extremely appreciated. I apologize if this question feels to familiar to the others that are similar, but as I am not the sole person trying to solve the problem, I am trying to figure out where the best solution lies, and whom it lies under (Modeler, Texture Artist or Programmer).
for checking all those other places first; not everyone with 1 reputation gives the impression that they've really tried to help themselves. I think you forgot to add that link to the teenager model, though.
Thank you! And oh jeese, wow... I took the time to photo-bucket the screen-shot and everything, and as you said, completely forgot to put the url there. Fixed now (the url missing, that is).
The shader we're using is simply Unity's default "Transparent/Diffuse" and the "Transparent/Bumped Diffuse" shader(s) (more importantly the first, really). I could have sworn I was able to see the default shader's code before, but I'm not able to edit the shader so I can't get the code out of it. Is the default transparent shader a sort of newbie trap so to speak, in terms of not working properly? I'm not familiar with shader code, nor is our programmer, so at the moment we do not have a custom shader we are using for it. I apologize if this is not helpful ): ($$anonymous$$aterial is visible in the SS)
Answer by Stephan-Tanguay · Oct 26, 2011 at 10:45 PM
If your having this issue with character models or you only require vertex lighting I highly recommend the following shadder!
AlphaVertexLitZ Shadder http://www.unifycommunity.com/wiki/index.php?title=AlphaVertexLitZ
Fixed the issues I was having, hope it does the same for others.,
Is there a mirror for this? unifycommunity.com seems to be dead.
They moved domains here's the new link: http://wiki.unity3d.com/index.php/Transparent_Alpha_Vertex_Lit_With_Z
Answer by TexeL · Feb 15, 2011 at 06:30 PM
Here is similar problem ...
Aras' answer in that thread is exactly the answer that belongs here: "No, it is not possible to solve it adequately.", and "Split your object into almost-convex parts, each with its own mesh". Only then can the transparency sorting try its best and solve many/most of your rendering artefacts.
Answer by Maarten · May 03, 2011 at 09:33 AM
Can you try to use a Transparent/Cutout/Diffuse shader? Then you can change the alpha cutoff
Answer by DFLY · Oct 02, 2011 at 10:32 AM
I have the same problem. But I have mad a few observations (please someone correct me if I am wrong).
First the transparency problem only appears to happen if an object that also has transparent textures is behind the first object. If the object behind is a diffuse (not transparent) texture the problem does not seem to happen.
Second the transparency problem seems to be distance related. Once the transparent object is over a specific distance away from the object behind, the problem stops.
I don't have a solution yet. By my workaround is to turn off the transparency when not needed.
eg.
function Solidify() {
var children : Renderer[];
children = GetComponentsInChildren.<Renderer>();
for (var i : Renderer in children) {
var childMaterial : Material[];
childMaterial = i.materials;
for (var j : Material in childMaterial) {
j.shader = Shader.Find ("Diffuse");
Debug.Log ("Child Material = " +j);
Debug.Log ("render = " + j.shader); /*GetTexture("_MainTex"));*/
}
Hope this helps. I also hope someone can come up with a better solution.( I suspect the problem is quite deep and related to OpenGL or some such thing.)
This is exactly the issue I am having (http://answers.unity3d.com/questions/352271/shader-causes-triangles-to-dissapear-in-u4-worked.html) it only started when I upgraded to Unity 4, it was working fine in Unity 3.5. I did just refresh my Windows 8 install which might have installed a different direct X or it could be unity 4 or something, but yes, I can confirm a lot of the same things. Layered transparencies are an issue. distance between objects and from camera are an issue. happens will all the transparent shaders, built in or self made really annoying.
Would be nice to get a fix on where the problem is
I am having the same issue, took me quite a while to find this thread as i didn't actually understand the problem at first, does any one know a solution?
Answer by JonnyHilly · May 07, 2014 at 06:16 PM
old thread, but worth an answer. The problem is your mesh is unsorted, it tries to draw all polygons, but does not sort them before drawing. with a diffuse object, the z-buffer takes care of this... with an alpha object, the z-buffer is ignored, so the polygon draw order is not sorted, so further polygons may draw on top. There is a way to solve this... the shader mentioned above does it... it renders 2 passes... one to set the z-buffer, then another to draw the object. AlphaVertexLitZ Shader shader
If you search around, there are some similar diffuse & vertexlit shaders that do the same thing, though I haven;t found a bump one yet.