Blend transparency effect on objects on a certain layer with background, but not with each other

Hi there!

alt text

The problem I have is that I’m trying to figure out the best way to implement a “Hologram Layer” effect with some specific requirements:

  1. Two sorts of object, holographic and non-holographic. Holographic objects are slightly transparent, and non-holographic objects aren’t.
  2. Holographic objects should not blend with other holographic objects - that is, they should occlude each other, as if they were rendered to a layer that was separately transparent (not independently transparent).
  3. Near non-holographic objects should occlude holographic objects, but far ones should be seen through holographic objects.

These two images illustrate the effect I’m trying to get.

I’ve tried a couple of solutions so far, but have not succeeded in getting either one to work.

  1. Transparent fragment shader, but with some kind of stenciling. I’m not that good with shaders, and as far as I know, there’s not a way to stencil out fragments in terms of Z order? Please let me know if I’m wrong.
  2. Screen space layers, with two different rendering cameras and post/screen space effects. One renders the holographic layer, and one renders everything else. However, even when set to the same depth level, the holographic camera renders everything over the top, meaning that objects that would have occluded them get rendered behind. I’ve then tried using depth textures to manually occlude stuff, but I think this could be too involved/waste of time.

This seems like an easy enough effect to achieve. It’s been difficult to find solutions and advice online for this specific effect.
Thank you in advance for the advice!

  • Rachel

By far the easiest (though depending on your preferences not the prettiest) way to do this would be a shader using dithering transparency.