Mewbits
(Mewbits)
January 23, 2017, 6:56pm
4
So I think what you want is for your material to selectively render the nearest translucent surface.
This method is limited, for example, the nearest translucent surface won’t only occlude internal translucent surfaces of your model, it will occlude any translucent surface behind it that’s using the same opacity function. So if one transparent character is standing behind another, the further one will be occluded.
In all the translucent materials used by parts of these characters, you need to Allow Custom Depth Writes. The mesh components must have Render CustomDepth Pass enabled. Make the Opacity Mask Clip Value very small.
Only the nearest surface is written to CustomDepth. Depth is orthographic, so pixels at the edge of the screen are given relatively high values compared to pixels at the edge. CustomDepth is converted to back to WorldPosition. This position is pushed away from the camera by a tolerance factor, scaled by distance, so that errors in the CustomDepth texture don’t cause the mesh to disappear at longer distances. If the distance from the camera to this position, is less than the distance from the camera to the surface’s WorldPosition, the base opacity is multiplied by 0.
I think I misunderstood the description earlier, because I thought it would have my desired results. However, it only works with seperate meshes with the same material, not within a singular mesh, so the eyes and teeth arms etc, will still be seen through the mesh. Is there a way for translucency to ignore the same mesh?
Here is what it looks like with the custom depth material:
Here is the desired look (edited in photoshop):