Skip to content

gz_waves: rendering - Part 3/4#884

Open
caguero wants to merge 6 commits into
caguero/waves-02-gerstnerfrom
caguero/waves-03-rendering
Open

gz_waves: rendering - Part 3/4#884
caguero wants to merge 6 commits into
caguero/waves-02-gerstnerfrom
caguero/waves-03-rendering

Conversation

@caguero

@caguero caguero commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Third in the stacked series. Adds the renderer, the WaterVisual GUI system that draws the wave surface, plus a runnable Gerstner-ocean demo world.

How to test it?

ros2 launch vrx_bringup simulation.launch.xml

What this PR adds

  • WaterVisual (gz-sim-water-visual-system) — a gz-sim GUI system that reads the Wavefield component, rebuilds a thread-private engine from the replicated recipe via the core registry (CreateWaveSimulation), and uploads its height/displacement grid as a GPU heightmap each frame. It is provider-agnostic: it links no wave engine and depends only on the gz_waves core.
  • HeightMapTexture — the CPU→GPU heightmap helper.
  • Ogre2HeightMapBridge (libwaves-ogre2-bridge) — all Ogre Next access is isolated behind a C-ABI in this separate library, loaded on demand via dlopen, so WaterVisual carries no DT_NEEDED on libgz-rendering-ogre2 (which would interfere with gz-rendering's own engine-plugin loader).
  • water_surface model (mesh + shaders + textures) — loads WaterVisual plus the per-engine GUI registrar(s) in the same <visual> (the only level the GUI's GuiRunner loads systems at). At this point that is gz-sim-waves-gerstner-gui; the FFT registrar line is added by PR4.
  • vrx_gazebo/worlds/open_water.sdf — wired as a Gerstner ocean (gerstner source + model://water_surface, <sea_state> default + advanced-commented block) so vrx_bringup's existing launch runs it directly. Ocean-only: no references outside the PR1–PR3 stack.

Provider-agnostic design

The engine registration that lets WaterVisual rebuild an engine in the GUI process lives in the per-engine GUI plugins (shipped by the provider packages), not in this package. So adding or removing an engine never touches
gz_waves_rendering — it depends only on the core. WaterVisual keeps a private engine instance (not the component's) because the GUI render thread and the ECM thread both touch it; sharing would race.

@caguero caguero changed the title gz_waves_rendering: water visual - Part 3/4 gz_waves: rendering - Part 3/4 Jun 19, 2026
@caguero caguero force-pushed the caguero/waves-03-rendering branch 3 times, most recently from 62909c5 to f4a163e Compare June 19, 2026 16:52
@caguero caguero force-pushed the caguero/waves-02-gerstner branch from fb9d51b to a2a41b5 Compare June 19, 2026 17:32
@caguero caguero force-pushed the caguero/waves-03-rendering branch from f4a163e to 4d50173 Compare June 19, 2026 17:33
@caguero caguero force-pushed the caguero/waves-02-gerstner branch from a2a41b5 to 3b09c80 Compare June 22, 2026 16:20
@caguero caguero force-pushed the caguero/waves-03-rendering branch from 4d50173 to 7df415e Compare June 22, 2026 16:44
@caguero caguero force-pushed the caguero/waves-02-gerstner branch from 3b09c80 to bb957dc Compare June 22, 2026 17:16
caguero and others added 4 commits June 22, 2026 19:16
…ridge

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
…rx_bringup simulation.launch.xml` runs

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
…bers

HeightMapTexture::Upload now takes the raw column-major WaveField2D
buffers + N and transposes to row-major internally (a plain loop,
null channels -> zeros), so WaterVisual hands Field()'s pointers
straight through with no Eigen::Map. Removes Eigen from the package
(it was used only as a transpose helper and wasn't even declared as a
dependency) and switches HeightMapTexture members to gz-style
this->member.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Agüero <caguero@honurobotics.com>
Extract the column-major -> row-major transpose from HeightMapTexture into
a dependency-free GridReflow.hh and cover it with a gtest (the only data
transform on the upload path, previously untested because it lived in an
anonymous namespace and Upload needs a live Ogre scene).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Agüero <caguero@honurobotics.com>
@caguero caguero force-pushed the caguero/waves-03-rendering branch from 7df415e to 3a1f9b0 Compare June 22, 2026 17:20
The analytic Gerstner engine writes the Jacobian determinant into the foam
channel, but it barely leaves 1.0, so it carries no usable folding signal —
whitecaps are visually indistinguishable from no foam. Gate foamStrength to
0 for the gerstner backend (the FS then skips the foam path entirely),
matching the shader's documented intent; FFT/Encino keeps foam.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Agüero <caguero@honurobotics.com>
@caguero caguero force-pushed the caguero/waves-03-rendering branch from 70b0854 to 69c71f1 Compare June 22, 2026 17:42
- Fix a data race: hold mutex_ across ResolveVisual so its first-pass
  material setup (which calls UploadUniforms and reads the cross-thread
  cache) no longer races PreUpdate on the ECM thread.
- Release the per-entity dedup claim in ~Implementation so a reloaded
  WaterVisual for the same entity can become active again.
- Make the one-shot upload log a per-instance member, not a function static.
- Tag sim as mutex_-guarded; note the deliberate lock over Update()/Upload().
- Sweep stale 'FFT' naming to 'grid/displacement' (the path is backend-
  agnostic), refresh foam doc, and explain the Configure const_cast.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Agüero <caguero@honurobotics.com>
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.

1 participant