Shader with ZWrite On not writing to the depth buffer

I have a Transparent shader that usually wouldn’t write to the depth buffer, except I want to outline it and because it is transparent i need to use edge detection using the Depth Buffer, so I changed ZWrite to On and ZTest to Always so it would keep its transparency, and while the shader displays the same as before, when I read the depth buffer it does not appear to be writing to it, so I cant find any edges (with another shader in a Blit function).
Shader Originally (ZWrite Off): 7248842--873407--upload_2021-6-17_17-27-21.png
Shader w/ ZWrite On: 7248842--873410--upload_2021-6-17_17-28-13.png
DepthBuffer Originally: 7248842--873413--upload_2021-6-17_17-28-55.png
DepthBuffer w/ Zwrite On: 7248842--873416--upload_2021-6-17_17-29-28.png

I don’t seem to understand the Depth Buffer correctly, as I’m not sure whats going on or how to fix it.

You’re not seeing the object because what you’re looking at isn’t the depth buffer, that’s the camera depth texture. The camera depth texture is rendered before the main camera view is rendered by rendering shadow caster pass of all opaque objects in the scene to a depth buffer that is then copied to a texture. That depth buffer is not reused for rendering the main view, but the camera depth texture is set as a global texture that can be sampled for things like soft particles or post processing.

For what you’re looking to do there are two issues; Only opaque objects will be rendered to the camera depth texture, and the ZWrite setting for your forward pass has no effect on if it shows in the camera depth texture or not.

The only way to get a transparent object’s depth into the camera depth texture is to use a command buffer to render your mesh into the depth texture at the appropriate time. Also be warned doing so will cause any directional light shadows to “break” where your transparent object is as they use the camera depth texture and now the depth for those pixels aren’t for the opaque objects you see through it. And similarly any object behind your transparent object will cease to have outlines for the same reason.