Acerola-style FFT ocean simulation (GL 4.3 compute)#1
Open
SurajBhari wants to merge 2 commits into
Open
Conversation
- Upgrade GL context 3.3 -> 4.3; add ComputeShader class - FFT ocean: JONSWAP/Phillips spectrum, GPU IFFT (butterfly ping-pong), 3 cascades, displacement + normals + Jacobian foam (shaders/ocean/*) - Ocean class orchestrates compute passes + displaced grid render - Preetham analytic sky (Hosek-Wilkie fallback) reused for water reflections - Water shading: Fresnel + sky reflection + sun specular + foam + SSS tint - main.cpp integration with 'O' toggle vs existing scene - Includes earlier grass texture-unit fix
f6f42de to
7ece2f8
Compare
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.
What
Adds a real-time, FFT-based ocean (Tessendorf / Acerola style) to the engine, driven by GPU compute shaders. Design spec:
docs/superpowers/specs/2026-06-23-fft-ocean-design.md.Press
Oat runtime to toggle between the ocean (default) and the previous cube/grass scene.How it works
Engine
ComputeShaderclass;ShadergainssetVec2/setVec4. No.vcxprojchanges (everything is header-only + runtime-loaded shaders, matching existing conventions).Simulation (per cascade, N=256, 3 cascades @ L≈256/64/16 m) —
shaders/ocean/*.compspectrum_init— Phillips spectrum × Gaussian → H0 (once).spectrum_update— evolve H0 by dispersion → packed frequency fields.butterfly_precompute— twiddles + bit-reversal (once).ifft— generic 2D inverse FFT, 8 horizontal + 8 vertical ping-pong stages (two complex fields per RGBA texture).ocean_merge— sign-correct/normalize → displacement map; normals + Jacobian foam via finite differences.Render
Oceanclass: owns textures/passes + a subdivided grid;ocean.vertdisplaces verts by summed cascades,ocean.fragdoes Fresnel(sky reflection ↔ deep water) + sun specular + foam + a cheap subsurface tint.Skyclass: analytic Preetham model, reused insideocean.fragfor reflections.Deviations / notes
main.cpp).No msbuild/Visual Studio was available in my environment, so I could not compile or run this. The architecture is complete and reviewed by hand, but expect to tune and shake out issues when you build it in VS:
1/N²IFFT normalization makes it very sensitive toOcean::amplitude(default 600) anddispScale. If the ocean looks flat, raiseamplitude; if it explodes, lower it.ERROR::COMPUTE_SHADER/ERROR::SHADERlines on startup.