Skip to content

[Reviewed][3D terrain] Make the ground faster to draw on slower graphics cards (v0.2.0) - #2345

Merged
4ian merged 1 commit into
mainfrom
claude/sharp-tesla-20zcgw
Nov 3, 2026
Merged

4ian merged 1 commit into
mainfrom
claude/sharp-tesla-20zcgw

Conversation

@4ian

@4ian 4ian commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Some testers report stuttering in starters using the 3D terrain (GDevelopApp/GDevelop-examples#1106). Their Chrome traces show the graphics card is the bottleneck: the terrain's shader costs too much for each pixel of ground. JavaScript time per frame is unchanged.

Changes

  • Noise: the noise making layer borders irregular is read from a 256×256 texture of random values: 1 texture read instead of 16 sin() hashes per pixel. With texture variation, it is 3 reads instead of 12 hashes.
  • Height blending: the average color of each layer texture is computed once on the CPU and passed as a uniform, instead of 4 extra texture reads per pixel. If the image can't be read by the CPU (from another domain without CORS, or not loaded yet), that layer still reads the smallest mipmap.
  • Shader variants: the shader is compiled only with what the terrain uses, through #defines for layer textures, normal maps, height blending and texture variation.
  • Vertex shader: the world normal comes from the camera-space normal three.js already computes, instead of an inverse() for each vertex.
  • New advanced property "Anisotropic filtering", 4x by default as before.

Compatibility

  • Projects keep the same properties and values.
  • The shader is compiled again only when the set of #defines changes. Properties change only in the editor (property actions are private), and holes already worked this way.
  • The irregular shapes of layer borders and texture-variation patches use new random values, so they look the same overall but sit in different places.

Testing

The gameplay tests of 5 examples using the terrain, grass and scattered models were run with GDevelop 5.6.286: 3D island terrain, 3D driving, 3D tank, first-person horror and 3D flight sim. Each game was run twice with the old extension and twice with the new one.

  • 25 of 25 tests pass with both versions.
  • Screenshots: with the same version, two runs give pixel-identical screenshots, except the tank game's gameplay screenshots, whose physics vary from run to run. Between old and new, differences are small and limited to the fine texture of the ground and the position of the noise patterns.
  • Rendering time: measured with a temporary benchmark test (not committed): a 640×360 frame, waiting for the graphics work to finish, median of 20 frames, averaged over the two rounds. Times come from Chromium's software renderer, so they show the direction of the change rather than the gain on a real graphics card. "Terrain only" hides the grass and scattered models, whose code didn't change.
Game Full scene Terrain only
3D island terrain 2077 → 1888 ms (−9.1%) 1865 → 1697 ms (−9.0%)
3D driving 913 → 817 ms (−10.6%) 747 → 709 ms (−5.1%)
3D flight sim 972 → 842 ms (−13.5%) 808 → 704 ms (−12.9%)
3D tank 1030 → 906 ms (−12.0%) 791 → 671 ms (−15.2%)
First-person horror 997 → 900 ms (−9.7%) 449 → 388 ms (−13.7%)

🤖 Generated with Claude Code

https://claude.ai/code/session_01GFZnZwjYz8dSQxu3B2QVUJ

…ics cards (v0.2.0)

- Read the noise making layer borders irregular from a small texture
  instead of computing 16 hashes per pixel.
- Compute the average color of layer textures once on the CPU for the
  height blending, instead of 4 texture reads per pixel (the mipmap is still
  read if the image can't be read, like for images from another domain).
- Compile the shader only with the layers, normal maps, height blending and
  texture variation used by the terrain.
- Get the world normal of vertices without inverting a matrix per vertex.
- Add an advanced "Anisotropic filtering" property (4x by default, as before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GFZnZwjYz8dSQxu3B2QVUJ
@4ian
4ian requested a review from a team as a code owner November 2, 2026 14:15
@4ian
4ian merged commit 428d541 into main Nov 3, 2026
5 checks passed
@4ian
4ian deleted the claude/sharp-tesla-20zcgw branch November 3, 2026 10:14
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.

2 participants