Download

Custom depth buffer causing objects to draw in front of other objects

Hey so, sorry in advance for this newbie question. I have searched and found a lot of similar results to this issue, but from people who are trying to achieve the effect intentionally - the problem we’re having is that our game uses cel shaded style elements for some things, as well as physically based lighting for other things, and they don’t seem to play well together.

The toon elements need to have their Custom Depth box checked to have the post process shader affect them, but now those objects seem to draw a silhouette in front of objects without Custom Depth. Depending on the distance between the player and the non toon shaded object, the objects behind it will pop in and out of visibility, as the attachments show (purple box has Custom Depth off, the desks have Custom Depth on).

We need to combine physical lighting with toon elements, where inevitably some physically shaded elements will be in front of toon shaded elements - if someone could explain a fix, or just as importantly explain why this occurs, it would be much appreciated :slight_smile:

depth_buffer_01.jpg&stc=1&d=1419005971
depth_buffer_02.jpg&stc=1&d=1419005976
depth_buffer_03.jpg&stc=1&d=1419005980