From 7d3a8a81ba708e35f80ee97d6c9b97607757d596 Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 14 Jul 2026 23:51:29 +0800 Subject: [PATCH] =?UTF-8?q?shader:=20fix=20FBM=20disk=20seam=20(atan2?= =?UTF-8?q?=E2=86=92Cartesian)=20+=20value=5Fnoise3=20range?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two issues from code review: (1) the noise coordinate used phi=atan2 which has a branch-cut discontinuity at ±π, producing a visible radial seam. Switch to Cartesian pos.x/pos.z (continuous, seam-free). (2) value_noise3 summed three hash components per corner via dot(.,(1,1,1)), giving a [-1.5,1.5) range instead of [0,1). Use a single scalar hash (.x) per corner and drop the +0.5 recenter. --- assets/shaders/black_hole.wgsl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/assets/shaders/black_hole.wgsl b/assets/shaders/black_hole.wgsl index 0513137..1294240 100644 --- a/assets/shaders/black_hole.wgsl +++ b/assets/shaders/black_hole.wgsl @@ -154,21 +154,21 @@ fn value_noise3(p: vec3) -> f32 { let i = floor(p); let f = fract(p); let u = f * f * (3.0 - 2.0 * f); - let n000 = dot(hash33(i + vec3(0.0, 0.0, 0.0)) - 0.5, vec3(1.0)); - let n100 = dot(hash33(i + vec3(1.0, 0.0, 0.0)) - 0.5, vec3(1.0)); - let n010 = dot(hash33(i + vec3(0.0, 1.0, 0.0)) - 0.5, vec3(1.0)); - let n110 = dot(hash33(i + vec3(1.0, 1.0, 0.0)) - 0.5, vec3(1.0)); - let n001 = dot(hash33(i + vec3(0.0, 0.0, 1.0)) - 0.5, vec3(1.0)); - let n101 = dot(hash33(i + vec3(1.0, 0.0, 1.0)) - 0.5, vec3(1.0)); - let n011 = dot(hash33(i + vec3(0.0, 1.0, 1.0)) - 0.5, vec3(1.0)); - let n111 = dot(hash33(i + vec3(1.0, 1.0, 1.0)) - 0.5, vec3(1.0)); + let n000 = hash33(i + vec3(0.0, 0.0, 0.0)).x; + let n100 = hash33(i + vec3(1.0, 0.0, 0.0)).x; + let n010 = hash33(i + vec3(0.0, 1.0, 0.0)).x; + let n110 = hash33(i + vec3(1.0, 1.0, 0.0)).x; + let n001 = hash33(i + vec3(0.0, 0.0, 1.0)).x; + let n101 = hash33(i + vec3(1.0, 0.0, 1.0)).x; + let n011 = hash33(i + vec3(0.0, 1.0, 1.0)).x; + let n111 = hash33(i + vec3(1.0, 1.0, 1.0)).x; let nx00 = mix(n000, n100, u.x); let nx10 = mix(n010, n110, u.x); let nx01 = mix(n001, n101, u.x); let nx11 = mix(n011, n111, u.x); let nxy0 = mix(nx00, nx10, u.y); let nxy1 = mix(nx01, nx11, u.y); - return mix(nxy0, nxy1, u.z) + 0.5; + return mix(nxy0, nxy1, u.z); } fn fbm3(p: vec3, octaves: u32) -> f32 { @@ -197,7 +197,7 @@ fn disk_color(pos: vec3, dir: vec3) -> vec3 { // Domain-warped FBM for feathered/smoky gas texture. The Keplerian shear // (rot ∝ 1/r^1.5) is folded into the noise flow term so inner radii flow // faster than outer — correct differential rotation. - let noise = disk_noise(vec3(r * 0.5, phi * 0.3, rot), uniforms.time); + let noise = disk_noise(vec3(pos.x * 0.3, pos.z * 0.3, rot), uniforms.time); let t = (r - uniforms.disk_inner) / (uniforms.disk_outer - uniforms.disk_inner); let tcol = mix(vec3(1.0, 0.95, 0.85), vec3(1.0, 0.45, 0.12), clamp(t, 0.0, 1.0));