# noniv/web-ocean architecture

> Architecture diagram of the GitHub repository noniv/web-ocean, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/noniv/web-ocean
- Repository: https://github.com/noniv/web-ocean

## Overview

web-ocean is a browser-based, real-time WebGPU ocean renderer. The user adjusts settings and flies a free camera; each frame combines simulated waves and foam, atmospheric sky and clouds, ocean shading, and HDR post-processing into the displayed scene. The graph separates those domain stages and the shared shader definitions. Main-module imports and shader-module imports are visible in excerpts; several runtime dispatch and data-flow details are not, so those links are omitted rather than inferred.

Main entry points: [`js/main.js`](https://github.com/noniv/web-ocean/blob/main/js/main.js) (WebGPU frame runtime), [`js/wgsl/common.js`](https://github.com/noniv/web-ocean/blob/main/js/wgsl/common.js) (Shared shader definitions), [`js/wgsl/ocean.js`](https://github.com/noniv/web-ocean/blob/main/js/wgsl/ocean.js) (Ocean surface shading), [`js/wgsl/sky.js`](https://github.com/noniv/web-ocean/blob/main/js/wgsl/sky.js) (Atmosphere LUTs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_controls["Controls and settings<br/>[main.js]"]
  node_camera["Free camera<br/>[main.js]"]
end

subgraph group_simulation["Ocean simulation"]
  node_wave["FFT wave simulation<br/>[sim.js]"]
  node_foam["Foam and whitecaps<br/>[sim.js]"]
  node_heightprobe["Water height probe<br/>[ocean.js]"]
end

subgraph group_environment["Sky and atmosphere"]
  node_atmosphere["Atmosphere LUTs<br/>[sky.js]"]
  node_clouds["Cloud layers<br/>[sky.js]"]
  node_environmentmap["Environment cube map<br/>[sky.js]"]
end

subgraph group_rendering["Scene rendering"]
  node_frame["WebGPU frame runtime<br/>[main.js]"]
  node_shared["Shared shader definitions<br/>[common.js]"]
  node_surface["Ocean surface shading<br/>[ocean.js]"]
  node_skybackground["Sky background pass<br/>[ocean.js]"]
  node_post["Bloom and tone mapping<br/>[post.js]"]
end

node_user(("Viewer"))

node_user -->|"adjusts"| node_controls
node_user -->|"flies"| node_camera
node_frame -->|"imports"| node_shared
node_frame -->|"imports"| node_wave
node_frame -->|"imports"| node_atmosphere
node_frame -->|"imports"| node_surface
node_frame -->|"imports"| node_post
node_wave -->|"imports"| node_shared
node_atmosphere -->|"imports"| node_shared
node_surface -->|"imports"| node_shared
node_surface -->|"imports"| node_atmosphere

click node_controls "https://github.com/noniv/web-ocean/blob/main/js/main.js"
click node_camera "https://github.com/noniv/web-ocean/blob/main/js/main.js"
click node_frame "https://github.com/noniv/web-ocean/blob/main/js/main.js"
click node_shared "https://github.com/noniv/web-ocean/blob/main/js/wgsl/common.js"
click node_wave "https://github.com/noniv/web-ocean/blob/main/js/wgsl/sim.js"
click node_foam "https://github.com/noniv/web-ocean/blob/main/js/wgsl/sim.js"
click node_atmosphere "https://github.com/noniv/web-ocean/blob/main/js/wgsl/sky.js"
click node_clouds "https://github.com/noniv/web-ocean/blob/main/js/wgsl/sky.js"
click node_environmentmap "https://github.com/noniv/web-ocean/blob/main/js/wgsl/sky.js"
click node_surface "https://github.com/noniv/web-ocean/blob/main/js/wgsl/ocean.js"
click node_skybackground "https://github.com/noniv/web-ocean/blob/main/js/wgsl/ocean.js"
click node_heightprobe "https://github.com/noniv/web-ocean/blob/main/js/wgsl/ocean.js"
click node_post "https://github.com/noniv/web-ocean/blob/main/js/wgsl/post.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_controls,node_camera,node_user toneBlue
class node_wave,node_foam,node_heightprobe toneAmber
class node_atmosphere,node_clouds,node_environmentmap toneMint
class node_frame,node_shared,node_surface,node_skybackground,node_post toneRose
```

## Components

### User interaction

- [Controls and settings](https://github.com/noniv/web-ocean/blob/main/js/main.js): `js/main.js`
- [Free camera](https://github.com/noniv/web-ocean/blob/main/js/main.js): `js/main.js`

### Ocean simulation

- [FFT wave simulation](https://github.com/noniv/web-ocean/blob/main/js/wgsl/sim.js): `js/wgsl/sim.js`
- [Foam and whitecaps](https://github.com/noniv/web-ocean/blob/main/js/wgsl/sim.js): `js/wgsl/sim.js`
- [Water height probe](https://github.com/noniv/web-ocean/blob/main/js/wgsl/ocean.js): `js/wgsl/ocean.js`

### Sky and atmosphere

- [Atmosphere LUTs](https://github.com/noniv/web-ocean/blob/main/js/wgsl/sky.js): `js/wgsl/sky.js`
- [Cloud layers](https://github.com/noniv/web-ocean/blob/main/js/wgsl/sky.js): `js/wgsl/sky.js`
- [Environment cube map](https://github.com/noniv/web-ocean/blob/main/js/wgsl/sky.js): `js/wgsl/sky.js`

### Scene rendering

- [WebGPU frame runtime](https://github.com/noniv/web-ocean/blob/main/js/main.js): `js/main.js`
- [Shared shader definitions](https://github.com/noniv/web-ocean/blob/main/js/wgsl/common.js): `js/wgsl/common.js`
- [Ocean surface shading](https://github.com/noniv/web-ocean/blob/main/js/wgsl/ocean.js): `js/wgsl/ocean.js`
- [Sky background pass](https://github.com/noniv/web-ocean/blob/main/js/wgsl/ocean.js): `js/wgsl/ocean.js`
- [Bloom and tone mapping](https://github.com/noniv/web-ocean/blob/main/js/wgsl/post.js): `js/wgsl/post.js`

### Other components

- **Viewer**

## Connections

- Viewer → Controls and settings: adjusts (evidence: `README.md`)
- Viewer → Free camera: flies (evidence: `README.md`)
- WebGPU frame runtime → Shared shader definitions: imports (evidence: `js/main.js`)
- WebGPU frame runtime → FFT wave simulation: imports (evidence: `js/main.js`)
- WebGPU frame runtime → Atmosphere LUTs: imports (evidence: `js/main.js`)
- WebGPU frame runtime → Ocean surface shading: imports (evidence: `js/main.js`)
- WebGPU frame runtime → Bloom and tone mapping: imports (evidence: `js/main.js`)
- FFT wave simulation → Shared shader definitions: imports (evidence: `js/wgsl/sim.js`)
- Atmosphere LUTs → Shared shader definitions: imports (evidence: `js/wgsl/sky.js`)
- Ocean surface shading → Shared shader definitions: imports (evidence: `js/wgsl/ocean.js`)
- Ocean surface shading → Atmosphere LUTs: imports (evidence: `js/wgsl/ocean.js`)
