Flat Transparent Shader?? (Shader n00b)

I’m looking for a transparent shader that avoids the issues of depth. What I’m finding is that when I apply a standard transparent shader to a complex object, the shader tries to fade all surfaces, but can’t figure out the true depth and location of all surfaces, and this leads to very odd visual errors. My needs are more simple. If I could find a shader that took the solid face to camera and then made that transparent - almost as a transparent billboard of the view, that would work fine for me.

Any suggestions on where to start.

Does such a shader exist?

Is there a direction someone can point me in?

Or is there a way to get around the issue of whatever algorithm is bein used to calculate transparency in the standard transparent shaders when applied to complex 3d objects?

I think you’d need to do a grab pass, render the model then fade the grabpass back on top.

Which would only be possible in Unity Pro.

I have pro.

Grab-pass.

I’ll look into that.

I’ll take hints, suggestions and pointers! But that’s a place to start.

This sounds like it will add a render pass each frame? I suppeose that’s still better than having confused depth issues.

There may be other, smarter ways around it (some messing around with depth testing or something) but I’m not sure of any.

You might look at the particle shader source too. The particle shaders do correct transparent depth sorting.

http://www.unifycommunity.com/wiki/index.php?title=AlphaVertexLitZ

That’s a simple shader, but the concept applies to any other. Just render into the depth buffer first.

Great! I’ll give Aras’ shader a try. I really don’t mind the “x-ray” look if it would render the “x-ray” with the proper depth. I’ll report back when I get back on the box.

Initial experiments show that this works well. I have already experimented with code that swaps shaders to transparent just before the start of a fade, as one of the big problems with transparent shaders is what it looks like on a complex object with the alpha solid at 1.0f. I may keep this, so non-fading object won’t need to be processed twice and they will only need the two passes applied during the fade…

Thanks all for the help.