- Home /
Transparent shader with Z-buffer and interlacing objects
Hi. I've a shader problem.
I'm doing an application than renders human organs where the user can rotate the camera around the body and can change the alpha level of each organ independently.
I do not use Unity transparent shader because it doesn't write to the zbuffer (some organ like the alimentary canal have parts that overlay each other (and I want to show the organ as a whole with transparancy)) -> so i used 2 passes in the shader (like this : http://www.unifycommunity.com/wiki/index.php?title=AlphaVertexLitZ). It works fine when I display only one object.
The problem is that when I want to display several transparent objects, when I change the camera orientation, some parts are not displaying. Changing manually the render queue is not a solution because it's the camera (controlled by the user) that determines which object are displayed first. It's particulary annoying with veins and arteries because some parts are inside an organ and other parts are external.
I found several topics in the forum talking about this (here and also here) but haven't found a solution adapted to my problem.
So I don't know how to help the algorithm to display things back to front to solve this depth sorting problem without manually using render queue and ? Any hints ? Thanks by advance.
Tom
Answer by Waz · Jun 30, 2011 at 01:14 PM
You could break your meshes up into smaller pieces such that they could be sorted. Seems cumbersome though.
Thanks, we thought about this as a last resort solution. We'll give it a try. I assume this is a computer graphics limitation (transparency with zbuffer with interlacing objects). It's not me but the graphic artist that will not be enjoyed by this solution ;) (nevertheless I'll still have to adapt some code to make other features work again).
Answer by Waz · Jun 30, 2011 at 01:20 PM
Have you tried other shading styles, such as varying the alpha with the angle to the camera (like rim lighting). That can often show internal structure better than normal flat transparent shading, while still not writing to Z buffer. After all, you're not trying to render reality.
Like this shader does.
Thanks again :), i'll try it tomorrow (I'm implementing another feature now and I my brain doesn't like more than one "program$$anonymous$$g thread").
Any solution found to this dude? I'm also having the same problem. If I have an object with transparency using this shader and an another object using that same shader but sligthly behind the first object, it won't show even if the first object has transparency.