BlueGit

timfa questward

Align deep/shallow water noise and add black lava coasts.

Deep water now samples the same water noise atlas as shallow so texAmp no longer hard-cuts at depth seams. Lava coasts retreat and binary-clip to black like water, without wetting sand.

timfa Tim Falken · pushed by timfa

Authored 2026-09-04 · 2 months ago

Hash
e7ccfdf611d5a0040d8d20ae5ca213a513fd6d74
Parent
ac402c34
2 files changed +19 −3
client/src/play/waterDebug.js +5 −2
@@ -69,7 +69,8 @@ export const DEFAULT_LAVA_DEBUG = Object.freeze({
69 69 lightDirY: -0.63,
70 70 lightDirZ: 0.78,
71 71 normalEps: 0.09,
72 bloomStrength: 0.9
72 bloomStrength: 0.9,
73 shoreClip: 0.54
73 74 });
74 75
75 76 const WATER_SLIDERS = [
@@ -104,6 +105,7 @@ const LAVA_SLIDERS = [
104 105 { key: "bodyHi", label: "Body hi", min: 0.3, max: 1, step: 0.01 },
105 106 { key: "litMix", label: "Lit mix", min: 0, max: 1, step: 0.01 },
106 107 { key: "bloomStrength", label: "Bloom", min: 0, max: 2, step: 0.01 },
108 { key: "shoreClip", label: "Shore clip", min: 0.1, max: 0.9, step: 0.01 },
107 109 { key: "edgeDark", label: "Edge dark", min: 0, max: 1, step: 0.01 }
108 110 ];
109 111
@@ -174,7 +176,8 @@ export function lavaDebugUniforms ()
174 176 {
175 177 const p = lavaParams;
176 178 return uniformBagFrom(p, {
177 u_bloomStrength: p.bloomStrength
179 u_bloomStrength: p.bloomStrength,
180 u_shoreClip: p.shoreClip
178 181 });
179 182 }
180 183
@@ -69,7 +69,8 @@ export const DEFAULT_LAVA_DEBUG = Object.freeze({
69 lightDirY: -0.63,
69 lightDirY: -0.63,
70 lightDirZ: 0.78,
70 lightDirZ: 0.78,
71 normalEps: 0.09,
71 normalEps: 0.09,
72 bloomStrength: 0.9
72 bloomStrength: 0.9,
73 shoreClip: 0.54
73});
74});
74
75
75const WATER_SLIDERS = [
76const WATER_SLIDERS = [
@@ -104,6 +105,7 @@ const LAVA_SLIDERS = [
104 { key: "bodyHi", label: "Body hi", min: 0.3, max: 1, step: 0.01 },
105 { key: "bodyHi", label: "Body hi", min: 0.3, max: 1, step: 0.01 },
105 { key: "litMix", label: "Lit mix", min: 0, max: 1, step: 0.01 },
106 { key: "litMix", label: "Lit mix", min: 0, max: 1, step: 0.01 },
106 { key: "bloomStrength", label: "Bloom", min: 0, max: 2, step: 0.01 },
107 { key: "bloomStrength", label: "Bloom", min: 0, max: 2, step: 0.01 },
108 { key: "shoreClip", label: "Shore clip", min: 0.1, max: 0.9, step: 0.01 },
107 { key: "edgeDark", label: "Edge dark", min: 0, max: 1, step: 0.01 }
109 { key: "edgeDark", label: "Edge dark", min: 0, max: 1, step: 0.01 }
108];
110];
109
111
@@ -174,7 +176,8 @@ export function lavaDebugUniforms ()
174{
176{
175 const p = lavaParams;
177 const p = lavaParams;
176 return uniformBagFrom(p, {
178 return uniformBagFrom(p, {
177 u_bloomStrength: p.bloomStrength
179 u_bloomStrength: p.bloomStrength,
180 u_shoreClip: p.shoreClip
178 });
181 });
179}
182}
180
183
client/src/render/worldView.js +14 −1
@@ -452,6 +452,7 @@ const LAVA_GROUND_FRAG = [
452 452 "uniform float u_lightDirY;",
453 453 "uniform float u_lightDirZ;",
454 454 "uniform float u_normalEps;",
455 "uniform float u_shoreClip;",
455 456 ...LAVA_FBM_COMMON,
456 457 "void main() {",
457 458 " vec2 px = floor(v_texCoord * 16.0) + 0.5;",
@@ -507,6 +508,10 @@ const LAVA_GROUND_FRAG = [
507 508 " float shade = mix(u_shadeLo, u_shadeHi, ndotl);",
508 509 " rgb *= shade;",
509 510 " rgb = mix(rgb, darkRed, edgeProx * u_edgeDark);",
511 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
512 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
513 " float shoreMask = step(u_shoreClip, retreat);",
514 " rgb = mix(rgb, vec3(0.0), shoreMask);",
510 515 " float litTop = mix(u_litNW, u_litNE, v_texCoord.x);",
511 516 " float litBottom = mix(u_litSW, u_litSE, v_texCoord.x);",
512 517 " float lit = mix(litTop, litBottom, v_texCoord.y);",
@@ -559,6 +564,7 @@ const LAVA_BLOOM_FRAG = [
559 564 "uniform float u_lightDirZ;",
560 565 "uniform float u_normalEps;",
561 566 "uniform float u_bloomStrength;",
567 "uniform float u_shoreClip;",
562 568 ...LAVA_FBM_COMMON,
563 569 "void main() {",
564 570 " vec2 px = floor(v_texCoord * 16.0) + 0.5;",
@@ -603,7 +609,10 @@ const LAVA_BLOOM_FRAG = [
603 609 " float heat = smoothstep(u_bodyLo, max(u_bodyHi, u_bodyLo + 0.01), waveBody);",
604 610 " heat = mix(heat, 1.0, smoothstep(u_litLo, max(u_litHi, u_litLo + 0.01), waveBody) * u_litMix * 0.35);",
605 611 " heat = clamp(heat + min(glitter, u_glitterCap) * u_glitterMix * 0.45, 0.0, 1.0);",
606 " float yellowAmt = smoothstep(0.55, 0.98, heat) * (1.0 - edgeProx * 0.85);",
612 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
613 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
614 " float shoreMask = step(u_shoreClip, retreat);",
615 " float yellowAmt = smoothstep(0.55, 0.98, heat) * (1.0 - edgeProx * 0.85) * (1.0 - shoreMask);",
607 616 " float bloom = yellowAmt * max(u_bloomStrength, 0.0);",
608 617 " vec3 glow = vec3(1.0, 0.82, 0.28) * bloom;",
609 618 " gl_FragColor = vec4(glow, bloom * u_alpha);",
@@ -3838,6 +3847,10 @@ export class WorldView
3838 3847 const dSE = deepCorners?.se ?? 0;
3839 3848 object._lit = true;
3840 3849 object.renderer.shader = getWaterGroundShader();
3850 // Shallow + deep share one noise atlas so texAmp seams don't hard-cut at depth edges.
3851 const sharedNoise = this.game.images[spriteImageName("ground", "water", "water")];
3852 if (sharedNoise)
3853 { object.renderer.sprite = sharedNoise; }
3841 3854 object.renderer.secondaryMap = shoreSprite?.g_image ?? null;
3842 3855 object.renderer.shaderUniforms = {
3843 3856 u_ambientDark: dark,
@@ -452,6 +452,7 @@ const LAVA_GROUND_FRAG = [
452 "uniform float u_lightDirY;",
452 "uniform float u_lightDirY;",
453 "uniform float u_lightDirZ;",
453 "uniform float u_lightDirZ;",
454 "uniform float u_normalEps;",
454 "uniform float u_normalEps;",
455 "uniform float u_shoreClip;",
455 ...LAVA_FBM_COMMON,
456 ...LAVA_FBM_COMMON,
456 "void main() {",
457 "void main() {",
457 " vec2 px = floor(v_texCoord * 16.0) + 0.5;",
458 " vec2 px = floor(v_texCoord * 16.0) + 0.5;",
@@ -507,6 +508,10 @@ const LAVA_GROUND_FRAG = [
507 " float shade = mix(u_shadeLo, u_shadeHi, ndotl);",
508 " float shade = mix(u_shadeLo, u_shadeHi, ndotl);",
508 " rgb *= shade;",
509 " rgb *= shade;",
509 " rgb = mix(rgb, darkRed, edgeProx * u_edgeDark);",
510 " rgb = mix(rgb, darkRed, edgeProx * u_edgeDark);",
511 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
512 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
513 " float shoreMask = step(u_shoreClip, retreat);",
514 " rgb = mix(rgb, vec3(0.0), shoreMask);",
510 " float litTop = mix(u_litNW, u_litNE, v_texCoord.x);",
515 " float litTop = mix(u_litNW, u_litNE, v_texCoord.x);",
511 " float litBottom = mix(u_litSW, u_litSE, v_texCoord.x);",
516 " float litBottom = mix(u_litSW, u_litSE, v_texCoord.x);",
512 " float lit = mix(litTop, litBottom, v_texCoord.y);",
517 " float lit = mix(litTop, litBottom, v_texCoord.y);",
@@ -559,6 +564,7 @@ const LAVA_BLOOM_FRAG = [
559 "uniform float u_lightDirZ;",
564 "uniform float u_lightDirZ;",
560 "uniform float u_normalEps;",
565 "uniform float u_normalEps;",
561 "uniform float u_bloomStrength;",
566 "uniform float u_bloomStrength;",
567 "uniform float u_shoreClip;",
562 ...LAVA_FBM_COMMON,
568 ...LAVA_FBM_COMMON,
563 "void main() {",
569 "void main() {",
564 " vec2 px = floor(v_texCoord * 16.0) + 0.5;",
570 " vec2 px = floor(v_texCoord * 16.0) + 0.5;",
@@ -603,7 +609,10 @@ const LAVA_BLOOM_FRAG = [
603 " float heat = smoothstep(u_bodyLo, max(u_bodyHi, u_bodyLo + 0.01), waveBody);",
609 " float heat = smoothstep(u_bodyLo, max(u_bodyHi, u_bodyLo + 0.01), waveBody);",
604 " heat = mix(heat, 1.0, smoothstep(u_litLo, max(u_litHi, u_litLo + 0.01), waveBody) * u_litMix * 0.35);",
610 " heat = mix(heat, 1.0, smoothstep(u_litLo, max(u_litHi, u_litLo + 0.01), waveBody) * u_litMix * 0.35);",
605 " heat = clamp(heat + min(glitter, u_glitterCap) * u_glitterMix * 0.45, 0.0, 1.0);",
611 " heat = clamp(heat + min(glitter, u_glitterCap) * u_glitterMix * 0.45, 0.0, 1.0);",
606 " float yellowAmt = smoothstep(0.55, 0.98, heat) * (1.0 - edgeProx * 0.85);",
612 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
613 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
614 " float shoreMask = step(u_shoreClip, retreat);",
615 " float yellowAmt = smoothstep(0.55, 0.98, heat) * (1.0 - edgeProx * 0.85) * (1.0 - shoreMask);",
607 " float bloom = yellowAmt * max(u_bloomStrength, 0.0);",
616 " float bloom = yellowAmt * max(u_bloomStrength, 0.0);",
608 " vec3 glow = vec3(1.0, 0.82, 0.28) * bloom;",
617 " vec3 glow = vec3(1.0, 0.82, 0.28) * bloom;",
609 " gl_FragColor = vec4(glow, bloom * u_alpha);",
618 " gl_FragColor = vec4(glow, bloom * u_alpha);",
@@ -3838,6 +3847,10 @@ export class WorldView
3838 const dSE = deepCorners?.se ?? 0;
3847 const dSE = deepCorners?.se ?? 0;
3839 object._lit = true;
3848 object._lit = true;
3840 object.renderer.shader = getWaterGroundShader();
3849 object.renderer.shader = getWaterGroundShader();
3850 // Shallow + deep share one noise atlas so texAmp seams don't hard-cut at depth edges.
3851 const sharedNoise = this.game.images[spriteImageName("ground", "water", "water")];
3852 if (sharedNoise)
3853 { object.renderer.sprite = sharedNoise; }
3841 object.renderer.secondaryMap = shoreSprite?.g_image ?? null;
3854 object.renderer.secondaryMap = shoreSprite?.g_image ?? null;
3842 object.renderer.shaderUniforms = {
3855 object.renderer.shaderUniforms = {
3843 u_ambientDark: dark,
3856 u_ambientDark: dark,