Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wave speed or gap #41

Closed
holdingjason opened this issue Aug 6, 2018 · 12 comments
Closed

Wave speed or gap #41

holdingjason opened this issue Aug 6, 2018 · 12 comments

Comments

@holdingjason
Copy link
Sponsor

Is there away to control the speed of the waves or frequency between them? Right now I can play with the equalizer but the wave frequency speed stays the same between them. I am talking between generated waves at the same level. I see that I can turn off or lower waves in the equalizer that would create gaps but that only works with larger waves following smaller waves which is not what I want.

Think a shore shot with lazy small waves drifting in slowly with large gaps between them.

@Midda-C
Copy link

Midda-C commented Aug 7, 2018

Yeah, I've thought about this too. The ocean is always moving in its set direction at a constant speed, as are the scrolling textures. Having some extra control over the speed would be great.

@huwb
Copy link
Contributor

huwb commented Aug 7, 2018

Thanks guys. I've had related thoughts but its purely in the realms of RnD at the moment. It would be figure out an approach here.

If we're purely talking wave speeds, i could expose speed control for each octave.

If you mean time-varying wave conditions, that is somewhat possible right now. the GerstnerWaveBatched script has a Weight param that can be driven as desired. one could set up two GerstnerWaveBatched objects and crossfade the weights to transition between them. one could also drive the equalizer values as desired directly - you could lerp small waves in or out using script, or maybe even animate them (i don't think i've tried applying animation curves to ScriptableObject's before..).

If you mean spatially varying wave conditions - different waves in different areas of the world - I havent figured out if this can be done efficiently. my best idea so far is to break world up into a grid and in each grid square mix together the spectra that apply. or, allow the user to author geometry with vertex weights that blend different wave conditions, exactly how multilayered materials work.

What do you guys think?

@holdingjason
Copy link
Sponsor Author

I was talking wave speed. The speed at which the wave moves across the ocean from point A to point B.

Need to think about your other scenarios.

@Midda-C
Copy link

Midda-C commented Aug 7, 2018

Me too, I was mostly just talking about the speed that the wave moves. Essentially just like the time-scale for a given octave. Might need some way to control the speed of the textures too?

I hadn't considered driving the weight with animation curves before. That could be interesting (should be easy to do as-is, Unity is pretty good about letting you animate pretty much any exposed value).

@huwb
Copy link
Contributor

huwb commented Aug 8, 2018

Yeah let me know about how animating goes, I want this to be well supported.

Ok that makes sense. I was hesitant to add per octave chop but if we're going to add per octave speed it might make sense to add both.

@huwb
Copy link
Contributor

huwb commented Aug 13, 2018

Nothing to show yet, but i spent a couple of hours this evening looking at having chop and wave speed tweakable per octave. Think i've got the groundwork done now so hopefully that stuff can come online in the not too distant future!

huwb added a commit that referenced this issue Aug 14, 2018
@huwb
Copy link
Contributor

huwb commented Aug 14, 2018

I've added a per octave speed scale in the referenced commit. I think its pretty cool actually. You can set it to 0 to freeze one or more octaves which is kinda fun.

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.

huwb added a commit that referenced this issue Aug 14, 2018
Added an override at the gerstner wave levels (above the per-octave setting), and a global override that affects all wave types.
@huwb
Copy link
Contributor

huwb commented Aug 14, 2018

In #18 @Midda-C asked about exposing a global wave speed control.

I've decided to tie everything to gravity (the wave speed is computed in part from gravity - more gravity means faster waves). Doing it this way ensures global consistency in the world, but I've also added overrides at multiple levels:

  • The ocean system takes the gravity value from the physics settings
  • It has a global gravity multiplier in the OceanRenderer script. This global setting will affect both dynamic wave sims and the gerstner waves.
  • There is a gravity multiplier on the wave spectrum that will affect all wave octaves
  • There is a per-octave gravity multiplier

So at the highest level you can override the gravity and you'll get consistent behaviour in both dynamic sims and the gerstner waves, but you can override at multiple levels, down to per-octave granulariy.

huwb added a commit that referenced this issue Aug 15, 2018
@huwb
Copy link
Contributor

huwb commented Aug 15, 2018

I believe this is resolved on master, in the commit referenced above. Let me know if you see issues!

@huwb huwb closed this as completed Aug 15, 2018
@Midda-C
Copy link

Midda-C commented Aug 15, 2018

Yeah let me know about how animating goes, I want this to be well supported.

Just thought I'd let you know that I finally remembered to try this out, and as expected, it works fine. All of the exposed parameters are available in the animation editor, and fading the weight in and out works perfectly. :)

@huwb
Copy link
Contributor

huwb commented Aug 26, 2018

@Midda-C are you able to animate the wave spectrum - like the power values for each wavelength?

I could not work out how to do it - i can animate params on the ShapeGerstnerBatch script, but not in the spectrum.

@Midda-C
Copy link

Midda-C commented Aug 26, 2018

I just had a quick look, and no, I wasn't able to do it either. I think that may be because those properties aren't actually part of the object, rather they're stored on an asset file.

I suspect that if the ShapeGerstnerBatched script actually replicated the settings from the Spectrum asset on the component itself (i.e. when you dropped in the spectrum file, its settings appeared on the compoenent), they'd be visible from the animation editor. Not 100% sure, that's just a guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants