Can DBuffer decals be customised to render on translucent surfaces?

Is there a way to render decals on translucent surfaces (eg: glass)? I’m aware that it is not possible when the target surface does not output its depth to the depth buffer, but I was wondering if using the ‘custom’ depth buffer is a viable alternative. I believe this question has been asked before on the forums, but I’m afraid none of the previous posts provided a definitive answer.

Following is an illustration of the problem I’m trying to solve. The image below shows two objects that both receive the same Dbuffer decal. The first has an opaque material, while the second is translucent.


As shown in the image below, both objects have been tweaked to output their depth to the custom depth buffer. The question is - is there some way to use this information in the decal material, the decal response or in the decal system itself to override the depth buffer whenever custom depth is present?

The only alternative solution I have so far is to render a flat plane just above the surface of the object. Custom depth can be accessed within the material to mask the decal texture so that it only appears on the target surface.


The solution needs to be fine tuned however as it doesn’t work well when another object overlaps the target surface.


Any alternate solutions to this problem would be much appreciated. Thank you.