0
\$\begingroup\$

This is a further question from my last, originally I was trying to change the way the depth map is rendered per-pixel. However, through more testing, I've found that actually it has nothing to do with the shader, It's to do with the depth buffer. It's completely broken.

Here are a couple of things that are broken that someone may be able to help with:

SSAO doesn't work, as well as any post processing effect that uses the depth texture

SSAO: enter image description here

Depth of Field enter image description here

You may notice that DOF works, which is true, but it blurs the whole image as though it has no depth, it blurs all objects the same amount no matter where they're placed in the scene.

Also, when checking the depth map through the frame debugger, I noticed some strange things:

First of all its all white (it used to be grey until I changed a setting which I forgot) enter image description here

And then, even more strange, the depth texture appears to be 16x16px. I have no clue why, shouldn't it be 1920x1080? enter image description here

Even the built-in Unity shaders don't seem to effect the depth mask. I've tried multiple different custom wrote shaders. Including ones that write to the Z-Buffer themselves but nothing has worked. Something tells me it's to do with the project using a 2D Renderer. But I don't know. If anyone can help that would be appreciated, I have been stuck on this for weeks.

I have also tried enabling the depth texture in the URP Asset: enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ Do you want to delete your previous question, since it turns out it was based on a misdiagnosis of the underlying problem? \$\endgroup\$
    – DMGregory
    Commented Jan 31 at 15:43
  • \$\begingroup\$ The documentation says the depth buffer is enabled by default, but I've found many threads on the Unity forums saying that DOF doesn't work in 2D. This is probably a limitation of the 2D renderer; you could solve either by switching to the 3D renderer or by faking DOF (if objects that should be blurry are always the same distance from the camera, you can blur their sprites in an image editor - otherwise, you'll have to use shaders). \$\endgroup\$
    – Kevin
    Commented Feb 1 at 19:04
  • \$\begingroup\$ I think I'll probably just switch to 3D later on, I need it to be able to change, so faking it wouldnt really work \$\endgroup\$
    – Pow
    Commented Feb 1 at 19:05

0

You must log in to answer this question.

Browse other questions tagged .