Hello forum
I’m having a problem when using transparent images as plane textures. It seems like Unity can’t handle the z-index of the planes when they they are masked, sometime the ones in the back jump to the front and vice versa.
I can make the problem go away if I use the “cutout transparent” shader, but then the edges aren’t antialiased and that is a shame.
Is there a way to get this problem solved?
I think this thread brings up all the problems you’re experiencing:
http://forum.unity3d.com/viewtopic.php?t=13473
Thanks for your reply. I read your link, but I’m not sure that I understand it all completely… Just to sum it up:
It is not possible to have overlapping planes that use transparent shaders and have them render correctly?
It really depends… right out of the box overlapping semi-transparent objects will always have sorting issues.
However, if, you’re only using semi-transparent geometry for static elements like windows, water, etc, it is possible to manually force the sorting of these objects by making custom shaders that manipulate the rendering queue.
For instance:
Tags {"Queue"="Transparent"}
Will render before:
Tags {"Queue"="Transparent + 1"}
So it’s possible to manually sort the objects if you know that object A will always be in front of object B. I did a bit of this for the sewer demo on Unity’s example page if you want to see an example of this.
Ethan
hi thanks again.
I have looked at the sewer project, but I’m not sure where it is that you set the z-index. Is it done in script or in the editor?
Look at the shader used on the transparent objects, some of them are not the same i would reckon.
ok I think i got it… I need to make my own shader which has the codeTags { "Queue" = "Geometry+1" }
Exactly, that would make the object draw after all objects in the Geometry Queue but before all objects in the Transparent Queue. I’m sure you found this in the Reference Docs, but for people who come across this thread later on the documentation for this can be found at:
http://unity3d.com/support/documentation/Components/SL-SubshaderTags.html
it seems like I’m only able to make a cutout transparent shader, and then I’m back to where I started. How can I make a transparent shader with antialiased edges? Can you maybe point me in the right direction?
Post a picture of what you mean because I think we’re starting to talk about 2 separate issues
Have you tried the Vegetation 2 Pass Shader? This does a cutout pass and then a transparent pass to “soften” the edges.
yes the vegetation shader was actually what I was after. I modified it a little so I can force the z-index and it looks really good.
But it seem like my new shader doesn’t handle lightning the same way as the old (transparent diffuse)…
It would be nice to be able to open that shader so I could see the difference, but unfortunately it doesn’t seem to be anywhere on my computer.