wave-harmonic / crest

A class-leading water system implemented in Unity
MIT License
3.4k stars 475 forks source link

Depth Cache not populated - Exported Image is Black #1128

Closed klauskobald closed 3 months ago

klauskobald commented 11 months ago

Is there an existing issue for this?

Have you checked the documentation to resolve your problem?

Current Behavior

(This is a copy from Discord) I am investigating since yesterday why this is not working anymore. I am browsing thru my repo history and found out that after the update in February from 4.15 to 4.16 (unity 21.3.11) it is still working but after the update to unity 21.3.17 it breaks. The populate method is called and it does not throw any error, but the cache-map stays black. I cannot see any significant changes. Stepping thru with the debugger seems to reach the same code pieces as far I can see. I noticed that a new CustomMonoBehavior has been introduced which is also a base for depthcache script. I need help on how I could track this malfunction.

I made an update to 4.18 and it still does not work

I made a new scene. I found out that OceanDepthCache On Demand is not working. When I use On Start, it is creating the depth cache. BUT I need On Demand!

Expected Behavior

WaveCache working

Steps To Reproduce

new scene put objects like this:

image

Unity Version

2021.3.29

Crest Version

4.16, 4.18

Render Pipeline

Universal

Editor or Standalone

Editor (Play Mode)

Environment

- OS: Mac 13.1
- GPU:
- Graphics API: Metal
- Target Platform: Any

Anything else?

No response

klauskobald commented 11 months ago

Another interesting Behaviour: when I set to "OnDemand" and start the scene, the water stays flat - no waves. When I trigger Populate Cache the waves start but the depth cache is black. When set to "OnStart" populate creates the proper depth cache. When I change to On Demand during play populate cache does not work either.

klauskobald commented 11 months ago

"Force Always Update Debug" does not work either

daleeidd commented 11 months ago

Thanks for reporting. I had bug report on Discord about this but looks like Discord automatically closed it due to inactivity.

Depth priming currently breaks the ODC. Will eventually fix this. Workaround is to disable it or disable and use depth cache baking then re-enable

Since then I have worked out that it is related to both depth priming and SSAO. I reported this to Unity and they confirmed a few bugs on their end. They gave me a solution but I could not get this to work with the ODC.

Workaround for now is to use a baked depth cache and to disable SSAO and/or depth priming when baking.

klauskobald commented 11 months ago

My game is depending on a dynamic depth map. Wind direction is used to build underwater objects once in a while for generating areas with no waves. Can you please explain exactly how to disable/enable/populate during runtime? I tried but it does not work. I cannot find how to turn off depth priming - is there a switch? I cannot NOT ship prebaked maps!! I am currently building a terrain/harbour editor which depends on dynamic maps!

daleeidd commented 11 months ago

You have to disable depth priming and/or SSAO in URP settings. I do not think it can be done at runtime or at least I do not know how.

klauskobald commented 11 months ago

So, I turned off Priming - it was on Auto. They are writing, that on iOs and Android priming could lead to even more GPU load. With priming off, everything works.

daleeidd commented 6 months ago

For anyone landing here, please vote on Unity Issue Tracker: https://issuetracker.unity3d.com/issues/depth-is-not-rendered-in-a-depth-only-camera-which-is-set-up-by-a-custom-script

daleeidd commented 3 months ago

Fixed in Unity 2022.3.23f1: https://issuetracker.unity3d.com/issues/no-depth-output-in-play-mode-with-camera-dot-render-when-both-ssao-and-depth-priming-are-enabled