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

Spectrum Driven Small Details #638

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

daleeidd
Copy link
Collaborator

@daleeidd daleeidd commented Aug 28, 2020

I have attempted to drive small details strength with values from the ocean wave spectrum. I am not sure I have done it correctly, but it appears to be working. Small details is covered by normals and roughness.

I used the amplitude values. Not sure if that was the best way to go.

For the "enabled" and "disabled" screenshots, the roughness was set to one and zero respectively. The base normal scale needs to be improved and can look strange when the scale is low enough to be visible but too small to look good. I am thinking that driving the scale and strength might work so we ensure normals always look nice when visible.

Let me know what you think.

Main Scene without changes

1_1_Enabled
Enabled

1_2_Disabled
Disabled

Main Scene with low spectrum weight

2_1_Disabled
Enabled

2_2_Disabled
Disabled

Main Scene with zero spectrum weight

3_1_Enabled
Enabled

3_2_Disabled
Disabled

Issues

Noticeable scale change

When weighing out a spectrum, the normal scale will decrease. When the camera has a high altitude, this is very noticeable. It looks almost like the normals scroll at fast speed.

Local Gerstners

Not sure if we should try and handle this case.

TODO

Multiple Gerstners

I think just a static list of global gerstners could work. And then we take the highest value.

Testing

On the OceanRenderer, there are two toggles to enable/disable driven normals and roughness. I have also exposed properties on the OceanChunkRenderer for debugging.

@daleeidd daleeidd marked this pull request as draft August 28, 2020 20:42
@daleeidd daleeidd changed the title [Draft] Spectrum Driven Details Spectrum Driven Details Aug 28, 2020
@daleeidd daleeidd changed the title Spectrum Driven Details Spectrum Driven Small Details Aug 28, 2020
Add more debug options. Amplitude multiplier. Added min and max
normal scale. Also apply driven normals to strength.
@daleeidd
Copy link
Collaborator Author

Added some debugging stuff and some possible improvements.

@daleeidd
Copy link
Collaborator Author

Solved that one issue with LODs. Was a pretty obvious bug. Added a new issue about scale changing.

@daleeidd
Copy link
Collaborator Author

Not ready to merge but ready for some feedback. It demonstrates the idea enough I think.

@huwb
Copy link
Contributor

huwb commented Sep 16, 2020

Thanks for the bump it's next on my list to look at

@huwb
Copy link
Contributor

huwb commented Sep 17, 2020

Thanks for this! Really interesting to see this coming through.

I've been playing around and i think i get the jist of it. I've realised it's quite tricky thing to make work correctly.

One basic problem is that the normal maps do not capture the appearance of the waves at all. In an ideal world, if you zoom in on a patch of water like the below, the only visual thing that changes is detail subtlely gets blended in.

image

Instead what happens is when the actual waves come in they can be very different from the normals (the waves are ramped up a bit too much here and trigger the foam like crazy, which is another potential problem).

image

I need to think about if the normals could be a good approximation to the underlying waves. It makes me think that should be possible to render a patch of waves that tiles horizontally, which could then be used as a normal map? Like what would happen with FFT. This is an entirely new rabbit hole / tangent but just thinking aloud..

If they cant match then maybe they are not driven by the spectrum and function the way they are now, leaving the roughness. I played with the spectrum and observed the roughness. I can see it changing but am struggling to decide if this is a good thing or if it should be left entirely to art.

Its possible i was failing at tweaking or focusing on the worst cases, apologies if thats the case. Let me know what you think.

@moosichu
Copy link
Contributor

moosichu commented Sep 27, 2020

I haven't looked at the code, so haven't seen if this is taken into account, but it's worth pointing out that the physics of small (capillary) waves is quite different than those of large (gravity) waves.

https://en.wikipedia.org/wiki/Capillary_wave

Mainly because the restoring force in the former is surface tensions, whilst in the latter it is gravity.

just had a look at the changes

This would be more relevant if we ever wanted to drive small details procedurally.

https://youtu.be/ts2am8WRBXQ?t=466

Uncharted 4 has a nice effect where the wind seemingly generates surface ripples as it blows over it.

@huwb
Copy link
Contributor

huwb commented Oct 5, 2020

Yeah that's a cool effect

It makes me think that should be possible to render a patch of waves that tiles horizontally, which could then be used as a normal map?

I decided to scratch the itch and try this out. I believe it does tile - at least the waves do. However it's pretty easy to break the tiling property. Going to write notes to capture for the future

  • Only the waves within the Lod will tile, not bigger wavelengths copied on from larger lods, so it would need to be taken before the combine pass from the wave buffer. This is possible I think.
  • Shallow water dampens waves and breaks tiling (water depth does not tile periodically). I think the shoreline depth could be taken into account later instead of during generation.. maybe..
  • Alignment to shorelines breaks periodicity
  • Flow probably breaks periodicity too and would need a rejig

I think it's possible to render a repeating patch of waves in a canonical frame and then transform them to achieve the above points. I think we'd probably work in this way if we were using fft as well. Needs more investigation though, will leave for now.

@daleeidd
Copy link
Collaborator Author

daleeidd commented Oct 6, 2020

I think it's possible to render a repeating patch of waves in a canonical frame and then transform them to achieve the above points.

I have been thinking about this too but to solve another problem where small waves contribute to other data like foam. Because the smaller wavelengths aren't present in the distant LODs, foam generation can be noticeable more potent under the camera with certain settings. I wonder if we could also similarly tile a patch of smaller waves into the foam data?

@huwb
Copy link
Contributor

huwb commented Oct 11, 2020

Yes i think that could help as well. I think it would be worth exploring moving to purely-repeating wave buffers to allow testing this stuff, at some point..

Tangentially related, i tried a hack to boost the foam - branch test/increase-foam-in-dist . If you get time feel free to check it out

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

Successfully merging this pull request may close these issues.

None yet

3 participants