Potentially a big question, but it seems like it should be simple enough. I have an object in my game composed of multiple parts (connected GameObjects with their own renderers). I want to make this entire object semi-transparent, without seeing the parts of the object through itself.
Here's an example of what I have so far:
There are two cubes, with another stretched cube connecting them. The sphere in the background is just to show an object in the background. Notice how you can see the ends of the connecting cube inside the other cubes. That's what I don't want. I only want the front-most faces of the overall "composite object" to be visible. I want inner faces of the object to be occluded, while keeping the object as a whole semi-transparent.
Turning on "depth write" almost sort of works, but it gives me this:
I've searched for hours to try and figure out how to implement this. This is the closest thing I've found, but it's for URP, and I can't figure out how to translate it over to HDRP. I've run into talk about creating shaders, but at this point I've never touched shader design (on any platform), and can hardly begin to figure out how I would accomplish this.
I feel like I can't be the first person to have this problem in this setup. Can anyone outline for me how to get the transparency I need, specifically in Unity's High Definition Render Pipeline?
EDIT:
Trying the suggestion from:
Fade in rendering mode doesn't work as intended
I've duplicated the object and applied the following shader to one of the overlapping copies.
Shader "Unlit/DepthReserve"
{
Properties
{
}
SubShader
{
Tags { "RenderType" = "Opaque" "Queue"="AlphaTest+1" }
LOD 100
Blend Zero One
Pass
{
}
}
}
This very nearly works, but it results in some strange glitching. Watch how the background object erratically pokes through the transparent one when I move the camera.
If there's a way to fix that, this method (as hacky a workaround as it is) could work for me.