wave-harmonic / crest

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

Ocean tile culling incorrect with large dynamic waves #849

Open daleeidd opened 3 years ago

daleeidd commented 3 years ago

Describe the bug Ocean tiles are getting erroneously culled close to camera when large dynamic waves are used.

Screenshots / video a

Versions Latest. BIRP

To Reproduce In the threeboats.unity scene, follow behind the large ship as per screenshot once the wake is large enough.

Additional context Reported on Discord by @nitroman123. I am guessing displacement reporting is not adequate for this scenario? Opening issue here so I don't lose it.

huwb commented 3 years ago

Thanks for logging.

Yeah we don't know how much dynamic waves will offset the surface in advance, so it's possible for tiles to displace outside the bounds and appear missing. The tile bounds are fairly conservative but still possible to break it.

A cool thing to do would be to take the final displacement texture and compute the actual tile bounds from it, rather than uniformly expanding bounds on every direction like we do now. Perhaps by computing a lower res min/max displacement texture. To use it our tile culling would need to be gpu based I guess (unless it can be read back to the CPU some frames later and used there). So that's a different thing. But mentioning as it would be nice to remove all the code around disp reporting! And expanding our bounds on all directions, rather than computing actual accurate bounds, is really inefficient.

Another option could just be to allow bounds to be expanded by a further amount. Like add a max wave amplitude param to the dyn waves settings.

nitroman123 commented 3 years ago

Sry for not posting it my self just found it yesterday.