Skip to content

feat(extensions): add WebGPU height-map fitting to TerrainExtension - #10751

Merged
ibgreen merged 18 commits into
masterfrom
codex/webgpu-terrain-heightmap
Nov 17, 2026
Merged

ibgreen merged 18 commits into
masterfrom
codex/webgpu-terrain-heightmap

Conversation

@charlieforward9

@charlieforward9 charlieforward9 commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Background

WebGPU terrain offset fitting places layers on a height map. Texture draping remains WebGL-only.

Change List

  • Share terrain shaders and hooks between GLSL and WGSL
  • Encode heights in RGBA8; select upper surfaces with depth
  • Preserve picking, globe offsets, and transformed terrain bounds
  • Preserve perspective billboard sizing, clipping, and pixel path widths
  • Keep final-position hooks compatible with clipping
  • Describe screen-space offsets in shared geometry metadata
  • Ignore display depth bias when selecting terrain heights
  • Unit tests cover fitting, camera clipping, and extension order
  • Documentation for supported modes and geometry metadata

Verified: build, lint, website, 71 extension tests, nine focused regressions, 26 render comparisons, and 49 node tests.


Note

Medium Risk
Modifies shared shader geometry structures, SimpleMeshLayer bounding box calculations, and picking blend logic alongside experimental WebGPU terrain pipelines.

Overview
Adds WebGPU support to TerrainExtension for height-map fitting using terrainDrawMode: 'offset'. New WGSL shader modules encode elevation into RGBA8 render targets, sample terrain heights, and reposition vertices in clip space.

HeightMapBuilder and TerrainPass are updated on WebGPU to calculate elevation ranges for depth-ordered writes, manage depth-enabled height-map render targets, and configure blending. To preserve billboard sizing and path stroke widths across height adjustments, VertexGeometry now tracks screenSpaceOffset across GLSL and WGSL shaders.

In addition, SimpleMeshLayer.getBounds now accounts for instance transforms to supply accurate mesh elevation ranges, and PickLayersPass updates picking blend parameters to avoid invalid alpha writes during pure terrain passes.

Reviewed by Cursor Bugbot for commit b7d618d. Bugbot is set up for automated code reviews on this repo. Configure here.

@coveralls

coveralls commented Sep 25, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 83.71% (+0.09%) from 83.623% — codex/webgpu-terrain-heightmap into master

@charlieforward9
charlieforward9 marked this pull request as ready for review September 30, 2026 20:57
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes reach terrain rendering, shared shader geometry, and picking.

Satisfy the repository's TSDoc requirement before merging; no new blocking behavior issue was established.

Findings

  1. P2 Shader constants lack required docs ▶

Summary

Adds WebGPU terrain fitting in offset mode while keeping texture draping WebGL-only.

  • WebGPU layers can fit their geometry to the upper terrain surface.
  • WebGPU terrain layers default to offset mode and reject draping.
  • Terrain fitting accounts for transformed meshes and screen-space geometry.
  • Terrain layers occlude picks without adding false pick colors.

The new shader constants need the documentation required by the repository guide.

Reviews (17) · Last reviewed commit: "fix(extensions): register terrain effect..." · Reviewed by Greptile

@charlieforward9 charlieforward9 changed the title TerrainExtension: add WebGPU height-map fitting feat(extensions): add WebGPU height-map fitting to TerrainExtension Oct 26, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@ibgreen
ibgreen force-pushed the codex/webgpu-terrain-heightmap branch from 59fed01 to cc81329 Compare November 4, 2026 18:40
@ibgreen
ibgreen force-pushed the codex/webgpu-terrain-heightmap branch from cb26a68 to fb26e1d Compare November 4, 2026 19:03
@ibgreen
ibgreen force-pushed the codex/webgpu-terrain-heightmap branch from 1c60fbc to 5d509a3 Compare November 4, 2026 21:37
Comment thread .github/workflows/test.yml Resolved
Comment thread vitest.config.ts Resolved
@ibgreen
ibgreen force-pushed the codex/webgpu-terrain-heightmap branch from 315383c to f3a99a8 Compare November 5, 2026 01:49

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f3a99a8. Configure here.

@ibgreen ibgreen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the shared Terrain plugin, height pass, and follow-up fixes for implicit offset mode and registering the effect when the extension is added. The final CI run exercised all 46 Terrain browser cases in the standard job. I found no remaining blocker.

@ibgreen
ibgreen force-pushed the codex/webgpu-terrain-heightmap branch from 1c777ca to b7d618d Compare November 17, 2026 22:53

import {TERRAIN_MODE} from './terrain-mode';

export const terrainWGSLSource = /* wgsl */ `

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Shader constants lack required docs. The repository guide requires TSDoc for constants, including internal declarations. terrainWGSLSource has none, as do terrainWGSLVertexInjection and terrainWGSLFragmentInjection. Add short comments explaining what each string supplies; this pattern also appears elsewhere in the additions.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@ibgreen
ibgreen merged commit 7dd2438 into master Nov 17, 2026
8 of 9 checks passed
@ibgreen
ibgreen deleted the codex/webgpu-terrain-heightmap branch November 17, 2026 23:08
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.

4 participants