wave-harmonic / crest

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

Multiple lakes support. #345

Closed PhillipZeratul closed 2 years ago

PhillipZeratul commented 5 years ago

Crest Ocean is so great, so we want to use it in all of our waters. But the problem is we have many lakes.

You said in the user guide that currently Crest is targeted towards large bodies of water. The water could be pushed down where it's not wanted which would allow it to achieve rivers and lakes to some extent.

When you say "pushed down" do you mean that Crest Ocean is still rendered in a big area, we just lower the transform so the part outside of the lake is occluded by terrain?

As we have multiple lakes with multiple water levels, this is not a good solution because they will all stack on top of each other.

So will you support localized bodies of water or if we want to customize Crest to enable this feature, where is a good starting point?

Thanks.

moosichu commented 5 years ago

Unfortunatley localised or stacked bodies of water is out of scope. Crest is currently built around the assumption of a single, global water level. An option could be to support multiple Oceans, but Crest unfortunately isn't architected this way (yet).

When you mean "stacked" lakes do you mean overlapping lakes or not? I'm happy to try and help if you could provide some more info.

huwb commented 5 years ago

To add.. 'Pushed down' meant apply a displacement to the water surface to push it downwards. Like the whirlpool pushes the water down to form its shape.

This is similar to how naughty dog pushed the water down outside of the rivers, see their talk "Rendering Rapids in Uncharted 4" http://advances.realtimerendering.com/s2016/index.html

However crest would still do a bunch of the computation "globally" (not just around the pond/river), and by default would generate surface geometry everywhere in front of the viewer as well.

On the latter, I think it would be possible to write demarcate the areas you want water with some kind of bounding boxes, and then turn off tiles of the ocean surface on the fly if they are not overlapping one of these areas, which would reduce the surface geometry.

Anyway thats what that comment meant. I guess a starting point would be to mess around with turning off tiles when you don't want them, and see how far that gets you.

PhillipZeratul commented 5 years ago

When you mean "stacked" lakes do you mean overlapping lakes or not? I'm happy to try and help if you could provide some more info.

Yes. I didn't get what 'Pushed down' meant before. We have a big terrain and many lakes on it, the lakes have different altitudes, for example, a lake on top of a mountain and a lake on lower ground. I originally thought that I should have many Ocean Renderers put at each lake surface, but since they all stretch out, they overlap on each other.

But as @huwb says, I probably should have one ocean renderer and some kind of displacement map that puts the water level at the right altitude for each lake and lower the part I don't want beneath terrain surface or maybe turn those tiles off.

I'll try this and see if it works.

huwb commented 5 years ago

One other thought - the system current compares the sea level with the terrain height to compute water depth. This depth is then used to attenuate waves and drive shallow water shading and generate shoreline foam.

This currently assumes a single, global sea level, an assumption which we're breaking if there are multiple lakes.

I think we could work around this.. one way would be to sculpt some rough geometry at the expected height of the water in the world, and we can use this geometry to seed the expected water height when populating the depth information. We can work with you on this, we also wanted this ability for our own experiments with rivers.

This doesn't have to be tackled immediately now, but if you see foam everywhere, or no waves, or very large waves, these may all be symptoms of the systems assumption of a global constant sea level.

moosichu commented 5 years ago

@huwb Yeah, this is one of the reasons I'm interested in the Unity terrain system, to see if we could use that in anyway to create that kind of data.

PhillipZeratul commented 5 years ago

one way would be to sculpt some rough geometry at the expected height of the water in the world, and we can use this geometry to seed the expected water height when populating the depth information.

@huwb It would be so nice if we can have a default water level and then some quad or mesh like geometry to override the altitude of the water level in that quad/mesh defined region.

PhillipZeratul commented 5 years ago

But on second thought, it would be better suited for lakes and rivers in games if the system is not designed to cover the whole scene in the first place.

I mean for oceans, this assumption is great and easy to use but for lakes and rivers, it would be better if we can define the areas for the water to spawn.

huwb commented 5 years ago

Yeah I'd agree. We hope to support this stuff better in the future, which would likely involve a redesign of some parts of the system which will take some time.

I think what you said about water level is possible, if you still plan to pursue this let us know.

PhillipZeratul commented 5 years ago

@huwb Definitely, I'm trolling the code right now. The water visual you guys achieved is so great, we definitely gonna use crest-ocean if we can support lakes and rivers.

So what's your plan for this feature? Are you trying to implement an override of the water level as a temporary solution or are you going to redesign the system? And what is the estimated time for this? And how can I best help you?

huwb commented 5 years ago

Ok we can add it to our list. Right now our focus is on various aspects around hdrp support, preparing for the release later in the year.

So working on this feature would likely fit into mid term time scales, likely towards the end of this year. This is something I'd love to push on, it's just finding the time..

PhillipZeratul commented 5 years ago

That is so good to hear. Our game is planned to release mid-term next year so it would be really lovely if this can be implemented within a few months. I probably will work on this full time later this month so I will see what I can contribute when I have a better understanding of the code.

Thank you and your team so much for this great asset and quick support. đź‘Ť

americanbean commented 4 years ago

In the future, it’d be nice to describe an water “volume”. Similar to how volumetric fog and other scene parameters work in HDRP. That way multiple water volumes could be placed in a scene with localized parameters.

huwb commented 4 years ago

Yeah idea, im sure the volumes could be helpful in a few ways. I'll add it to my list to look into them.

It's not clear to me (yet) that they'll apply to networks of rivers and lakes which are less definable as discrete volumes. Thats just my first guess anyway.

PhillipZeratul commented 4 years ago

Glad that you guys are thinking about this feature. I'm still waiting for it and really hope this will come out in a few months, so keep me posted ;)

huwb commented 4 years ago

There's an experiment in https://github.com/crest-ocean/crest/pull/361 .

WaterBody defines areas where water should be visible. Then the depth cache actually sets the water level as well. Everywhere else water is sea level. If your sea level is below the terrain this should work.

PhillipZeratul commented 4 years ago

Great! I just gave it a test and yeah it works visually if I set the sea level below the terrain. So I'm wondering if we have some optimization room for those water we don't see?

huwb commented 4 years ago

Its about as good as it gets, according to my current understanding. The water under the terrain will fail the depth test so it won't draw pixels, and there aren't many verts in each patch, so this should work well.

On Mon, 11 Nov 2019, 07:51 Phillip Zeratul, notifications@github.com wrote:

Great! I just gave it a test and yeah it works visually if I set the sea level below the terrain. So I'm wondering if we have some optimization room for those water we don't see?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/crest-ocean/crest/issues/345?email_source=notifications&email_token=AAHFO7LGJGTASCNII2DDCO3QTEFI3A5CNFSM4I3ENTZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDV6SNA#issuecomment-552331572, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHFO7K53OHWAGMNPXKGGMTQTEFI3ANCNFSM4I3ENTZA .

huwb commented 3 years ago

This is still on the list, it seems to always be one or two items further down than what we have bandwidth to look at, but it is slowly bubbling up.

This captures the current status fairly well: https://www.youtube.com/watch?v=jXphUy__J0o&t=1s

I think in teh future we'd make this easier to use and work seamlessly with rivers.

We're hoping to increase our bandwidth through sponsorship and i wanted to mention that once here in case there is interest in supporting us: https://github.com/sponsors/wave-harmonic

daleeidd commented 2 years ago

This feature landed in 4.14.