Repository navigation
cvc::ocean: the sea's spectrum and the cascades' h0 on the CPU (O2) - #1116
Merged
Merged
Conversation
O2 of docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md (B1, E1, decision D1 as a new standard-library module, with a configure-time check that it includes no other libcvc library). cvc/ocean/spectrum.h ports ABYSSAL's spectrum: JONSWAP with the TMA correction, Donelan-Banner spreading blended with cos^2 (rotated with the wind, D10), the fetch law clamped at a fully developed sea, and the swell term (DNV-RP-C205 from Hs and Tp, narrowed and cut off). cvc/ocean/h0.h builds a cascade's h0 from it: make_cascades gives bands at 8 pi / L that partition the wavenumbers and a seed per cascade, paying the two port debts (shared noise, overlapping bands); build_h0 writes the texel layout OceanFFT's time evolution reads, bit-identical across runs. OceanFFT drops its spectrum shader pass and noise texture for setH0. lsystem_coast builds its three cascades from one sea state, all at amplitude 1 (the old 0.55 / 0.32 weights tamed cascades that each held the whole spectrum), with swell height and period sliders, the swell off by default.
…/ocean-model # Conflicts: # src/cvc/CMakeLists.txt # src/cvc/tests/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
O2 of
docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md(B1, E1, §10.1). The sea's spectrum now lives on the CPU, in a module every consumer can link. The GPU ocean uploads the h0 it builds, so the picture and the physics band (O6) will evolve the same numbers (R3). This PR doesn't depend on #1109.What it adds
cvc::ocean, a new module of the core library (decision D1). It depends on the standard library only, and a configure-time check fails the build if it includes another libcvc library.cvc/ocean/spectrum.hports ABYSSAL's spectrum (src/ocean/OceanFFT.jsat 849ff7f4, MIT, credited in the headers andTHIRD_PARTY_NOTICES.md):significant_wave_height, and the wind sea's and swell's heights separately.cvc/ocean/h0.hbuilds each cascade's h0, paying two debts the roadmap lists in §1.1:make_cascadesgives each cascade a band edge at 8π/L of the next tile, as ABYSSAL does. The bands partition the wavenumbers, so the sum holds the spectrum once; before, every cascade carried a whole spectrum, so the peak was counted up to three times.build_h0writes h0(k) and conj h0(−k) in the texel layoutOceanFFT's time evolution already reads. It is bit-identical across runs.OceanFFTdrops its spectrum shader pass and its noise texture.setH0()holds the CPU h0 and uploads it (atinit()if it hasn't run yet). With no h0 the sea is flat.lsystem_coast builds its three cascades (tiles 251, 83 and 29 m) from one
sea_state:coast.water.swell_hs,swell_periodandswell_dir_x/_zare new knobs, with height and period sliders in the Ocean panel. The swell is off by default.Looks
I compared 40-frame
--capture orbitrenders before and after (fixed capture clock).Not yet
std::log,exp,sinandcoscome from each platform's libm. O6 puts the surface into the physicsstate_hash, so it needs correctly rounded versions first.cvc::physics's privatedet_mathhas no exp or log; moving it tocvc::algo(added in cvc::world: water_bodies, the sea, lakes and ponds and the shore grid (O1) #1109) and adding them is the likely route. The roadmap's B1 now says so.--set. Its spectrum is covered by the unit tests.Tests
ocean_spectrum_testhas 13 tests:cvcgl_ocean_fftnow feeds the GPU ocean throughsetH0. It checks that the wrong resolution is refused, that a re-upload afterinit()makes the wind knob live, and that an ocean with no h0 is flat, alongside the existing FFT invariants.Run locally (Windows Release, GL build) and passing:
ocean_spectrum_test(13),cvcgl_ocean_fft(all checks).git clang-format18.1.8 is clean on the changed lines.