Skip to content

Add hydrological flow visualization#70

Merged
brendancol merged 4 commits intomasterfrom
add-hydro-viz
Mar 2, 2026
Merged

Add hydrological flow visualization#70
brendancol merged 4 commits intomasterfrom
add-hydro-viz

Conversation

@brendancol
Copy link
Contributor

Summary

  • New HydroState subsystem (rtxpy/viewer/hydro.py) following the composed viewer pattern
  • GPU-accelerated hydro flow particle simulation with stream-order-aware rendering, trail visualization, and accumulation-scaled particle sizing
  • Threaded hydro_data parameter through accessor.explore(), quickstart(), and engine.py
  • Added hydro overlay support and keybinding
  • Trinidad example now launches with hydro=True

Test plan

  • Run python examples/trinidad.py and verify hydro flow particles render on terrain
  • Toggle hydro overlay on/off with keybinding
  • Verify non-hydro scenes are unaffected (no regressions)

Introduce GPU-accelerated hydro flow particle simulation with stream-order-
aware rendering, trail visualization, and accumulation-scaled particle
sizing. New HydroState subsystem follows the composed viewer pattern.
Trinidad example now launches with hydro=True.
…on rasterization

- Burn Overture waterway LineStrings and Polygons into DEM before D8
  computation so flow routes through known channels (quickstart)
- Add distance-to-ocean gradient and channel burning pass for better
  coastal drainage and stream connectivity
- Toggle hydro (Shift+Y) now switches to stream_link overlay with water
  reflection shader, restoring previous layer on OFF
- Rasterize waterway Polygons (lakes/reservoirs) via scanline fill in
  both engine and quickstart, not just LineStrings
- Burn waterway features into stream_link and stream_order grids so
  they render with the unified water shader
- Update stream order palette to blue gradient (8 levels) and remove
  HDR emissive boost for natural water appearance
- Reduce default hydro particle count to 12k and min render depth to 1m
Add _trace_tributaries_flow_path() using xrspatial flow_path to trace
waterway-seeded channels and headwater tributaries into the stream
network. Add coast_distance parameter using xrspatial surface_distance
for terrain-aware 3D Dijkstra distance from coastline.
…plore()

The hydro block in quickstart() created ~20 intermediate (H,W) arrays
that were never freed before explore() blocked indefinitely. On a
4096x4096 DEM this leaked ~1.3 GB of dead CPU arrays plus stale CuPy
pool memory, causing OOM kills on WSL.

- Add explicit del for all intermediate arrays after last use
- Load waterway GeoJSON once instead of 4 redundant file reads
- Free CuPy memory pool between heavy computation steps
- gc.collect() before launching explore()
- Clean up coast_distance intermediates similarly
- Store boolean flag in _hydro_data instead of (flow_dir, flow_accum)
  tuple that redundantly kept two full grids alive during viewer session
@brendancol brendancol merged commit d4d71b7 into master Mar 2, 2026
1 check passed
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