Coder Social home page Coder Social logo

Progress update about crest HOT 15 CLOSED

wave-harmonic avatar wave-harmonic commented on May 20, 2024
Progress update

from crest.

Comments (15)

huwb avatar huwb commented on May 20, 2024 1

Hey Midda, thanks for note! How are things going on your side?

Yeah it looks like its been almost a month since I've pushed to master! I've been doubling down on adding LOD'd simulations to crest. I started the 'local_sim' branches in February and have been slowly working towards the following goals:

  • Layer on dynamic interaction on top of the animated waves to make the ocean feel like a water surface and increase user immersion. This is optional and only needs to be activated if there is interaction with the water.
  • Simulate foam - instead of trying to estimate where to put it based on current state, allow foam to be deposited onto surface and then faded over time as foam disperses. This sim is very simple - it just attenuates the current foam value every frame to fade it over time. This is also optional and could be disabled for a calm ocean.
  • Combine the above features to produce great boat/ship wakes.
  • Do these things elegantly and efficiently to a high quality level - replace what was in master previously

The two sim types hang off the same cascaded LOD data structure as the ocean shape and were elegant to add to the current system (moving the foam to a sim had a nice effect on other parts of the code). The key requirement with sims is a persistent state across frames (wave dynamic state, foam value, etc) and I'm adding a general framework for attaching sims any LOD levels, along with helpers to shift the sim state correctly when the viewpoint moves.

On the boat wakes, my test scene is still very hacky but I'm starting to see first glimpses of something good. I always struggled to get wakes looking good in the past and I'm happy to find that generating the foam from the dynamic sim seems to be working well. Here's a rough video showing the latest as of today in local_sim3 (the scene is called 'boat'):

https://drive.google.com/open?id=1Q1SZr-NSHpPcp6GZB2dB3n_SkO0nGQpI

For general gerstner waves the foam sims make a result a bit like this, the foam sits on the surface before dispersing. I hope in the future to make the foam effect more realistic, i think having more state in the sim might be the key here (perhaps a quickly decaying turbulent 'foam front', then a general foam value that fades slower, and an underwater bubble state that behaves slightly differently as well). Anyway this is current but needs tweaking:

https://drive.google.com/open?id=1xMTWEPXq6ThynuOXxHWbjbb0GSi4JhwI

On the efficiency/performance, I just tested the main scene at 1080p on my laptop, with foam sims running at 6 scales and I get an overall framerate of approx 290fps, which is similar or very slightly faster than what I was getting before. The cost of running the (cheap) foam sim is likely offset by the savings of moving the foam computation out of the ocean shader. The wave sim may add a cost, I don't anticipate a huge one though. It is opt-in so can be evaluated on target device/hardware.

I think the following is remaining before it can be merged into master.

  • The sim assumes the frame dt is always 1/60 which is bad news. I need to decided on an approach here.
  • Foam 3D lighting - bring it back and I'm hoping to do a pass on it to make it look less severe
  • Better scene - better boat! Probably a bigger ship.
  • Another tweaking pass
  • Code commenting/cleanup/refactoring

So actually not that far away, at last! I'll make a new release when its ready to merge and I'd love you guys to move to it if you're up for it. The required change would be to turn on the foam sims, and there might be some foam tweaking required as the parameters changed a bit.

The only other thing I'm considering is how to get this kind of info out in the future. I'm evaluating patreon as a platform for this.

Anyway, do you have thoughts on the above?

(Btw I'm not sure if you guys saw my comment here #16 (comment) - a short while ago I added the ability to render alpha blend on the ocean surface (and in the main scene I added a crest logo at the entrance to the bay). I think this is very powerful especially for any in-world UI for gameplay etc. We really wanted this on projects in the past so i thought I'd mention this!)

from crest.

Midda-C avatar Midda-C commented on May 20, 2024

Nice! The wake is looking great, can't wait to try it! Our project will definitely be able to make good use of that. Can the cost of the wake sim be adjusted by limiting it to certain LODs? Does that make an appreciable difference?

I'm assuming that this all layers on top of the existing shape textures, so the CPU get-height function just includes the wake by default?

Having the foam disperse would be a nice touch. Will there still be similar controls to what there is now (like foam coverage, etc)? Nice to hear that it's currently looking to be a net-gain on performance, too.

Yeah, I had seen that post about the textures on the ocean surface. I didn't really think much of it at the time, but I hadn't considered the possibility of using it to move some in-game UI elements. That's really interesting, because one of the things we've been trying to do in our project is to make the HUD as minimal as possible. I'll be sure to mention this to the team. :)

from crest.

huwb avatar huwb commented on May 20, 2024

Cool :)

Can the cost of the wake sim be adjusted by limiting it to certain LODs

Yeah, you choose which resolutions you want the wave sim to run at (the wave sim then generates the foam and the two work together to form the wake). I got pretty good results from simulating just two scales in that video (0.5m and 1m wavelengths). If you wanted an meteorite to hit the ocean you may go for some large scales but I'm been thinking mostly about small scale stuff.

I'm assuming that this all layers on top of the existing shape textures, so the CPU get-height function
just includes the wake by default?

Yeah, I'm pretty happy about that :). Would like to demo this with small floating objects at some point.

Will there still be similar controls to what there is now (like foam coverage, etc)?

Yeah, I'll try to do another tweaking pass and will expose the stuff I think is useful. As always I'll try to walk a line between giving control and burying you under data :) and feedback about what you need is always useful to find the right balance.

Thanks for the nice feedback, it was a bit of a slog getting through all the failed experiments to something that's starting to work (as always) but I'm getting increasingly motivated and excited about it now and will give it a big push over the next weeks.

from crest.

huwb avatar huwb commented on May 20, 2024

@Midda-C

https://drive.google.com/open?id=1GsmPJgIzg6_xTSkx5qK6GaahKvsnta7T

Added a second boat :)

Been fixing bugs and making it more solid and tweakable, it's going in the right direction.

from crest.

Midda-C avatar Midda-C commented on May 20, 2024

Awesome! :D

So are the wakes created as gerstner waves? Are they tweakable in any way (like their choppiness)?

from crest.

huwb avatar huwb commented on May 20, 2024

The dynamic waves are a heightfield sim which are added on top of the gerstners. They have no horizontal displacement and therefore no chop which sucks. There was actually a predecessor to the local_sim branches where I wanted to simulate the entire ocean with dynamic sims. It worked but the result looks bad without the horizontal motion.

I'll have a think again about how it might be fudged in, maybe theres something that can be done here.

from crest.

huwb avatar huwb commented on May 20, 2024

Oh but there will be some tweakable vars related to the simulation and wake, such as strength and damping factors and stuff like that. It could eventually be possible to tweak gravity with a little bit more work, but right now its hardcoded to realistic.

from crest.

Midda-C avatar Midda-C commented on May 20, 2024

Cool, no worries. Having chop on it would certainly help with our stylised aesthetic, but it's already looking awesome as it is!

from crest.

huwb avatar huwb commented on May 20, 2024

It finally happened - local_sim3 is merged into master in latest ( 98b7880 )!! I've created a new release for it.

The merge includes the scenes boat and threeboats in the example content which demo the new additions. Also notable is the debug GUI got a nice update - it has more relevant controls and the freeze option is now mapped to button F, and freezes the sims, boats, shading and everything while leaving the camera free - very handy for debugging/tweaking!

The new changes are API-breaking hence the new major release version 2.0.0) and might take a little bit of porting work, although I hope not much as its more adding than changing.

You will however likely see your foam disappear in your existing scenes, and you will need to add a CreateSims component to set up the foam sims. I've put some default data on it so it should create a few foam sims by default and get you going with minimal fuss - hopefully!

I'll close this issue, please create issues for any problems you encounter as per usual. Thanks!

from crest.

huwb avatar huwb commented on May 20, 2024

Just realised I missed a setup step - the foam sims require one layer to be added to the project named SimFoam. An error will appear if this layer is not created. I've improved the clarity of this error a bit on very latest just now, and have also updated the readme setup steps.

One layer is required per sim type (a SimWave layer is required to run dynamic wave sims). This is not ideal but is the way unity cameras want it to be. At least it does not require a layer per lod like before - hopefully you have enough spare slots to add these.

from crest.

Midda-C avatar Midda-C commented on May 20, 2024

Woo! Exciting! :D Can't wait to check it out!

Sounds like @dizzy2003 will need to adjust a few things to get it properly integrated, so it might be a couple days before we have questions or feedback.

Regarding layers, I recently purged a few layers which weren't being used, so we should be able to make that work without dramas.

Cheers, we'll let you know how it goes!

from crest.

Midda-C avatar Midda-C commented on May 20, 2024

Okay, so I just grabbed latest to try the examples in a new project. I've got the foam sim working, but I can't get the wave sim to do anything. I'm in the threeboats scene, I've added the SimFoam and SimWave layers, and everything loads up without any errors. The boats are cruising around doing little donuts, but there aren't any dynamic waves. I tried adjusting the dampening on the auto-generated SimSettings, but still nothing.

Also, regarding the foam settings, I noticed that the Foam Scale parameter on the Ocean material only seems to adjust the scale for the sub-surface foam bubbles. Doesn't appear to have any impact on the surface foam.

Really loving the new foam, though. Seeing it appear and gradually dissipate adds a lot!

from crest.

huwb avatar huwb commented on May 20, 2024

Sigh I repro'd the same issue - missing waves after importing into a new project. The problem is that unity saves layer settings as integers instead of by name, which causes havoc when moving content across projects where layer assignments can be completely different. The wave sim might start trying to use any arbitrary layer that has the same layer index.

It was never really clear to me how this was supposed to work, but now its very clear to me that it doesnt. I've taken a slightly drastic measure - i no longer use the Layer setting directly. The layer settings for all my objects are left at default, but everywhere i want layer assignments made I give layer names to the ApplyLayers script. This approach does not need to spread and infect your project - it's not required for everything that interacts with the ocean system. It only ensures that the stuff in crest uses string names for layers and won't start using random existing layers!! If you notice something odd in an existing level, you guys might want to sanity check the layer assignments of ocean related stuff, and refer to the new Crest stuff to how I'm doing it now/how the layers should be configured.

With my latest push, when I import into a new project, it throws errors for each missing layer and forces you to add them explicitly by name. After i add them I get dynamic waves in the boat scenes. So it should be good to go.

Adding custom stuff and complication around layers is not ideal, ill think about if there's a better solution.

I fixed the foam scale not working - I forgot to hook that up, thanks for reporting that regression.

Something else odd - when i import it into a new project the ocean looks VERY blue - crazy saturated - I'll look into what's causing this.

from crest.

Midda-C avatar Midda-C commented on May 20, 2024

Okay, so it's not just me! Cheers, I'll have a look at the latest data.

Also, I think the colour being really blue is just because Unity always defaults to gamma. It gets the more turquoise colouring when you switch it to linear.

from crest.

Midda-C avatar Midda-C commented on May 20, 2024

Just had a thought about the wake choppiness (adding it here because it's not worth its own topic). That exponent you tested for the general wave shapes, could something like that be applied to the dynamic waves? It's not quite the same thing as chop, as it still doesn't have the horizontal displacement, but it gives a similar result.

Would that be a good candidate for tweaking the shape of the wake?

from crest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.