Code Monkey home page Code Monkey logo

Comments (22)

huwb avatar huwb commented on May 30, 2024 1

I've fiiiiiiiinally exposed per-octave chop as a test. Since per-octave speed was also requested in #41, i decided to add both.

The new options are tucked away behind the Advanced Settings toggle on the ocean wave spectrum, on the feature/per_octave_settings branch for now. These changes will add a small extra expense so it would be good to confirm this is useful before committing to master.

My initial experiments seem to give positive results. Adding chop to just the smaller wavelengths can avoid some of the unnatural horizontal motion. It also gives a nice control over foam (because choppy water generates foam).

If you have a chance to process this, let me know. We can discuss the other wave sharpening approach as well at some point. Both of these approaches will add a small expense, although its likely pretty minimal, but it would be good to be sure about stuff before adding it.

from crest.

huwb avatar huwb commented on May 30, 2024

Ha thats interesting, i had not thought of this. There are historical reasons why chop is all-up, but not great ones. I've had a few different kinds of shape in the past and they all shared the same chop value, but i think it should be broken out per shape type.

What you propose could make sense - adding it to the wave spectrum as an option, for each wavelength if i can make it work elegantly.

There is a snag that prevented me from just doing this right now - the global chop value is used to compute the potential bounding box for an ocean tile, I need to make this a bit smarter before i can remove the global setting. I'll post when i have news.

from crest.

huwb avatar huwb commented on May 30, 2024

So i removed the global chop value and it actually improved the code - I'm not measuring the bounding box based on the actual shape. When the ocean is calm, this will make the bounding boxes tight and it will render more efficiently. So that was a win on all accounts!

The chop value is now on the spectrum component. I havent broken it out per octave just yet. I'm mulling over how to do this without adding complexity to the ui and code. With my latest changes i just pushed its possible to emulate this feature by duplicating the Gerstner shape gameobject and making them render complimentary octaves, and you can then tweak the chop. If you do happen to get latest I'd be interested if you can confirm this per-octave chop is indeed useful.

Anyway i'll think about it on my side and will post back if I find a nice way to implement it.

from crest.

huwb avatar huwb commented on May 30, 2024

Hey Midda! Thought I'd bump this one. I did have a play with breaking out chop per octave, commit linked above. I wasn't happy with it so far so its currently on pause.

My note about complimentary octaves may not have been clear. I'm referring to duping the render gerstner waves GO and selecting mutually excusive sets on multiple wave components, which allows to set different chop values. One could look like this:

image

If the octaves are complimentary then it should not double up on work/expense.

I'm not sure the above is a good solution, but it might allow to test a bit more with the extra control over chop, it would be good to confirm that you're getting a good benefit out of this to motivate further investigation.

from crest.

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

Whoops, I completely missed your response here! Sorry!

I just tried duplicating the wave gameobject and setting it up as you described, and it seems to do the job pretty well. I did need to edit the script to raise the upper limit for the chop value (for the larger wave frequencies), but yeah, does the trick.

That should work for us in the short term, though when we eventually start setting up different profiles for different ocean conditions to lerp between, it may be a bit cumbersome. But, we weren't planning on implementing that for a little while yet, so no rush. :)

from crest.

huwb avatar huwb commented on May 30, 2024

Cool! Could you give me some info on what you did and why? Is it to exaggerate horizontal motion on the surface, or to get sharper crests, or both? Did you boost the chop value across the board on all wavelengths, or just some of them?

Will be interesting to hear when you do get to that stage. Actually i think a number of things will want to change to support multiple ocean conditions, such as saving out spectra as assets and potentially rendering them in localised areas. I should probably make the former change sooner rather than later, might mess with it in the next days.

from crest.

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

It was more to get sharper crests on larger waves under certain weather conditions. I did notice the side-effect though of there being a lot more horizontal movement on the surface, as you mentioned, but that wasn't really the effect we were going for.

For my testing, I just split it up into two different wave gameobjects, with the first 4 or so wavelengths on one, and the remainder on the other. I set the chop for the first group to something around about 1.5-ish, and the larger ones to around 3. I also mixed different approaches, using Phillips on the smaller wavelengths, and JONSWAP on the larger, as well as slightly more direction variance on the smaller (this seemed to reduce obvious repetition in the waves).

Again, this was all just my messing around with things as a test case, but being able to mess with all of those parameters differently for different wavelengths seemed to give a whole lot more versatility. The settings we actually settle on are going to change based on our gameplay requirements (i.e. what makes for more enjoyable/challenging sailing).

I don't know if you can glean anything useful from all this rambling, but yeah, it seemed pretty cool! :D

from crest.

huwb avatar huwb commented on May 30, 2024

While experimenting on something I looked at artificially sharpening the waves a bit. This is no longer physical which I'm generally not a fan of - it adds some fast vertical velocities and makes the surface move in a slightly different way. But it gives a bit of extra control and might be interesting? If it is I could look at pushing a version that you can play with, let me know.

https://drive.google.com/open?id=12jT5Tb7E4E9HOBb78uJ00k7h-OBPD7PH

from crest.

huwb avatar huwb commented on May 30, 2024

(oh and you'll notice the sea level drops a lot - this is due to the shape modification - it essentially pushes the troughs down in order to make the crests sharper, and this has the affect of lowering much of the ocean surface..)

from crest.

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

Interesting, thanks. Judging from the clip, it looks like it's a replacement for the existing chop, is that right? Or is it something that layers on top of the existing method?

from crest.

huwb avatar huwb commented on May 30, 2024

Oh no it would be a separate "sharpness" setting, in the video i stole the chop slider temporarily as a quick experiment. I've not explored how chop and this setting will interact, it should work though.

from crest.

huwb avatar huwb commented on May 30, 2024

To illustrate, the attached image (from Graph Toy) shows conceptually what I'm doing - I apply an exponent to the wave (orange) to get a new, slightly weird function (blue) which is a bit sharper

image

from crest.

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

Ah yes, I wondered if it might have just been an exponent. I'd certainly be keen to try it out. I do think though we'd probably need to account for the apparent lowering of the sea level, though. Our world generation expects the sea level to be at a certain height (otherwise we'll have some rocks and reefs sticking out of the water).

from crest.

huwb avatar huwb commented on May 30, 2024

Probably not highest priority but if you get around to it, i have pushed a new branch feature/sharp_gerstners (commit shown above), which has a Sharpen Exponent parameter added to the wave spectrum (next to chop). I was able to solve the height change issue by ensuring average height across the waves is maintained.

from crest.

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

So I just had a look at the sharp_gerstners branch, and it works pretty well. Seems like a nice way to get that little bit of extra sharpness on the peaks without getting that horizontal clipping which happens when the chop is too high.

We'd probably make use of it, and I expect others might too.

from crest.

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

Great! I just had a quick play with the changes (just a few minutes), and it seems really powerful so far!. Currently, we've got two separate Shape Gerstner Batched scripts with different spectrum assets on there, but in the little bit I've played with this, it looks like we should be able to just go back to the one file.

Yeah, you're able to avoid that strong horizonal motion now by isolating the high chop to the smaller wavelengths, without having to have multiple spectrum files. Nice!

The speed is handy too. One thing which might be good is to have a global speed slider, like we do with the chop. I assume the chop scale sliders are a multiplier over the main chop value at the top? It'd be good to have that for the speed too. It doesn't add any extra functionality, but it woule mean you could quickly set a base speed for all wavelengths and then just tweak accordingly.

The additional cost that you mentioned, is that only there if the "Show Advanced Controls" option is ticked? Or is it always there now? Any idea how significant that is?

from crest.

huwb avatar huwb commented on May 30, 2024

Ah that sounds like a win then!

Base speed - good idea - i've added that as discussed in #41.

The cost is all the time - but it's a few multiplications extra and is unlikely to be a noticeable hit. I'll put it in for now - core crest can be flexible, but if a particular project has more severe perf constraints, teams are free to hack this stuff out.

I'll get this pushed to master. If you have any feedback about parameter ranges, its useful as always.

from crest.

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

Yeah, I noticed today that the advanced control option is bascially just a UI option. But that's good! It meant I could go in there and adjust the chop on a few different resolutions, then hide it all again to just adjust the sliders like before.

from crest.

huwb avatar huwb commented on May 30, 2024

Yeah thats cool. I tweaked the UI a bit to hopefully make it less programmer-art-y . Despite spending quite a lot of time making editor GUIs i never really became good at it!

The wave sharpening approach - I'll leave it on ice?

An easy optimisation occurred to me, i could put this stuff on static switches, like the Ocean.shader options. I think its pretty easy to turn features on or off dynamically, i.e. only when the defaults are overridden. I'll leave that for future work for now though.

from crest.

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

The sharpening has some merit, it might have some use somewhere down the line, but it's probably not needed for this. It might be better to leave it out, in the interest of not overwhelming users with too many options.

Could maybe be used to sharpen the dynamic waves or something?

from crest.

huwb avatar huwb commented on May 30, 2024

Maybe it is possible to sharpen dynamic waves. I did an experiment here where i shift the points horizontally based on the gradient of the height - this can actually convert a sin wave to a gerstner/trochoid wave (provably), which i had not thought of before. But most relevant for us, it might work on arbitrary shape, as demo'd here:

https://www.shadertoy.com/view/ltcyDX

Blue is the original function (could come from the dynamic wave sim), white is the sharpened result. You can see the result is not perfect (there are some curvature issues), i'm not sure how it will look from the wave sim. Seems worth trying though, i'll post back if i get a chance to try it.

from crest.

huwb avatar huwb commented on May 30, 2024

I'm happy to report that i have a prototype implementation pushed and I think this might have legs - I have opened a new issue for it: #47

If you could try it out at some point I'd love to hear if you think it is usable!

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.