Transparent shader with depth writes

Hi guys,

I spent the afternoon trying to find out how to make a shader that do a similar thing than this:

I added a second pass to the bumped specular, another surface shader with vertex shader (that scale the model up). So I have this model upscaled with alpha but it is semi-transparent and some surfaces overlay as the left figure in:

alt text

I tried to use an extra path to calculate the depth but nothing help I have always some overdrawing artifacts and I would like to have a uniform solid color or a gradient at best, like the right figure but impossible.

Any ideas how I could avoid two surfaces to overlap and display nicely like in oxide demo?

Thanks guys.

Found a solution thanks to this thread:

I posted an answer to this question (with a comprehensive shader) here.