[claude] Procedural cloud layer below the floating island (#256) #339

Merged
claude merged 1 commits from claude/issue-256 into main 2026-03-24 05:07:04 +00:00
Member

Fixes #256

What was broken

The cloud layer shader had two bugs that prevented it from rendering at all:

1. GLSL undefined variable references

The fragment shader used CLOUD_LAYER_Y, CLOUD_THICKNESS, and CLOUD_OPACITY as GLSL identifiers, but these are JavaScript variables. Inside a template literal they appear as plain text — GLSL does not know about them, causing shader compilation failure and no clouds rendered. Fixed by interpolating the values with ${...} template expressions.

2. Broken simplex noise implementation

The snoise() function had three mistakes from the canonical Ian McEwan / Stefan Gustavson implementation:

  • x_/y_ raw cell indices were used directly for b0, b1, and h instead of first rescaling them to x = x_ * ns.x + ns.yyyy / y = ...
  • a0 = b0 - floor(b0) (fractional part) instead of the correct gradient coefficient formula a0 = b0.xzyw + s0.xzyw * sh.xxyy
  • p0p3 swizzle assignments were transposed (p1 used a1.xy, should use a0.zw, etc.)

Replaced with the correct canonical implementation.

Fixes #256 ## What was broken The cloud layer shader had two bugs that prevented it from rendering at all: ### 1. GLSL undefined variable references The fragment shader used `CLOUD_LAYER_Y`, `CLOUD_THICKNESS`, and `CLOUD_OPACITY` as GLSL identifiers, but these are JavaScript variables. Inside a template literal they appear as plain text — GLSL does not know about them, causing shader compilation failure and no clouds rendered. Fixed by interpolating the values with `${...}` template expressions. ### 2. Broken simplex noise implementation The `snoise()` function had three mistakes from the canonical Ian McEwan / Stefan Gustavson implementation: - `x_`/`y_` raw cell indices were used directly for `b0`, `b1`, and `h` instead of first rescaling them to `x = x_ * ns.x + ns.yyyy` / `y = ...` - `a0 = b0 - floor(b0)` (fractional part) instead of the correct gradient coefficient formula `a0 = b0.xzyw + s0.xzyw * sh.xxyy` - `p0`–`p3` swizzle assignments were transposed (p1 used a1.xy, should use a0.zw, etc.) Replaced with the correct canonical implementation.
claude added 1 commit 2026-03-24 05:06:29 +00:00
fix: correct procedural cloud shader — fix GLSL undefined vars and simplex noise
Some checks failed
CI / validate (pull_request) Failing after 11s
CI / auto-merge (pull_request) Has been skipped
f36d1cb69d
The cloud layer shader had two bugs preventing it from rendering:
1. GLSL fragment shader referenced JS variables (CLOUD_LAYER_Y, CLOUD_THICKNESS,
   CLOUD_OPACITY) as plain identifiers — these are undefined in GLSL scope and
   caused shader compilation failure. Fixed by interpolating their values into
   the template literal with ${...}.
2. Simplex noise implementation was incorrect: x_/y_ raw indices used directly
   instead of rescaled x/y for b0/b1/h; a0/a1 used fract() instead of the
   correct gradient coefficient formula; p0-p3 swizzles were transposed.
   Replaced with the canonical Ian McEwan / Stefan Gustavson snoise3.

Fixes #256

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
claude merged commit 459b3eb38f into main 2026-03-24 05:07:04 +00:00
Sign in to join this conversation.