BlueGit

timfa questward

Give cliffs a dedicated ground-top sprite shader.

Cliff tops no longer share the block-row atlas lighting path. They render as per-tile sprites with their own magenta→ground sampler so normal magenta wood/furniture tints stay untouched.

timfa Tim Falken · pushed by timfa

Authored 2026-08-31 · 2 months ago

Hash
b3cbe15389812e3c825715fa7347c7b6ede4e9a7
Parent
45fd07f7
3 files changed +83 −49
client/src/render/worldView.js +70 −47
@@ -15,7 +15,7 @@ import
15 15 } from "/shared/render/tint.js";
16 16 import { layersFromSpawnerConfig } from "/shared/appearance/layers.js";
17 17 import { chargeSpriteFrameIndex, itemMaxCharges } from "/shared/items/charges.js";
18 import { normalizeGround, isWadeGroundInSeason, isWaterGround, isLiquidWaterGround, isGroundPassable, isBlockOccludingLight, LightOcclusion } from "/shared/definitions/tiles.js";
18 import { normalizeGround, normalizeBlock, isWadeGroundInSeason, isWaterGround, isLiquidWaterGround, isGroundPassable, isBlockOccludingLight, LightOcclusion, blockDefinition } from "/shared/definitions/tiles.js";
19 19 import { spriteCenterFromPivot, spriteDrawSize, tilePivot, ySortLayer, flightSortLayer } from "/shared/render/pivot.js";
20 20 import { bakeChunkAtlases, tileBlockSpriteEntry } from "./chunkBake.js";
21 21 import { createChunkAtlasCache } from "./chunkAtlasCache.js";
@@ -354,51 +354,36 @@ const ATLAS_LIGHTING_FRAG = [
354 354 ].join("\n");
355 355
356 356 /**
357 * Block-row atlas: high-chroma magenta → sample the ground atlas (u_bump) at the
358 * same tile-local UV (1:1 scale). Used for cliff tops. Detection requires a real
359 * magenta mask (R≈B and R−G large); dark near-neutral tints like ebony wood also
360 * have R≈B after catalog tint and must not be treated as cliff magenta.
361 * The ground atlas already includes soft-terrain blending when that preference
362 * is on. Darkness matches ATLAS_LIGHTING_FRAG (lightmap in u_secondary).
357 * Per-tile cliff sprite: high-chroma / authored magenta top → sample this chunk's
358 * ground atlas (u_bump) at the cliff's tile-local UV. Only assigned to
359 * `cliffGroundTop` blocks — never to chunk block-row atlases (those keep normal
360 * lighting so magenta wood tints are not mistaken for cliff tops).
363 361 */
364 const ATLAS_BLOCK_GROUND_TOP_FRAG = [
362 const SPRITE_CLIFF_GROUND_TOP_FRAG = [
365 363 "precision mediump float;",
366 364 "varying vec2 v_texCoord;",
367 365 "uniform sampler2D u_texture;",
368 "uniform sampler2D u_secondary;",
369 366 "uniform sampler2D u_bump;",
370 367 "uniform float u_alpha;",
371 "uniform float u_ambientDark;",
372 "uniform float u_lightRow;",
368 "uniform float u_darkness;",
369 "uniform vec2 u_tileLocal;",
373 370 "void main() {",
374 371 " vec4 color = texture2D(u_texture, v_texCoord);",
375 372 " if (color.a <= 0.0) { discard; }",
376 373 " vec3 rgb = color.rgb;",
377 " // Authored magenta masks only (cliff tops). Not post-tint ebony etc.",
378 374 " float rbDiff = abs(rgb.r - rgb.b);",
379 " float magentaChroma = rgb.r - rgb.g;",
380 " if (rbDiff < 0.02 && magentaChroma > 0.15) {",
381 " float tileX = floor(v_texCoord.x * 16.0);",
382 " float tileY = max(u_lightRow, 0.0);",
383 " float localX = fract(v_texCoord.x * 16.0);",
384 " float localY = v_texCoord.y;",
385 " vec2 groundUV = vec2((tileX + localX) / 16.0, (tileY + localY) / 16.0);",
375 " if (rbDiff < 0.02 && rgb.g < rgb.r) {",
376 " vec2 groundUV = (u_tileLocal + v_texCoord) / 16.0;",
386 377 " rgb = texture2D(u_bump, groundUV).rgb;",
387 378 " }",
388 " vec2 lightUV = v_texCoord;",
389 " if (u_lightRow >= 0.0) {",
390 " lightUV.y = (u_lightRow + v_texCoord.y) / 16.0;",
391 " }",
392 " float lit = texture2D(u_secondary, lightUV).r;",
393 " float darkness = u_ambientDark * (1.0 - lit);",
394 " rgb = mix(rgb, vec3(0.0), darkness);",
379 " rgb = mix(rgb, vec3(0.0), u_darkness);",
395 380 " gl_FragColor = vec4(rgb, color.a * u_alpha);",
396 381 "}"
397 382 ].join("\n");
398 383
399 384 let spriteLightingShader = null;
400 385 let atlasLightingShader = null;
401 let atlasBlockGroundTopShader = null;
386 let cliffGroundTopShader = null;
402 387 let waterGroundShader = null;
403 388 let tintLitSpriteShader = null;
404 389 let dualTintLitSpriteShader = null;
@@ -419,11 +404,11 @@ function getAtlasLightingShader ()
419 404 return atlasLightingShader;
420 405 }
421 406
422 function getAtlasBlockGroundTopShader ()
407 function getCliffGroundTopShader ()
423 408 {
424 if (!atlasBlockGroundTopShader)
425 { atlasBlockGroundTopShader = Shader.fragment(ATLAS_BLOCK_GROUND_TOP_FRAG); }
426 return atlasBlockGroundTopShader;
409 if (!cliffGroundTopShader)
410 { cliffGroundTopShader = Shader.fragment(SPRITE_CLIFF_GROUND_TOP_FRAG); }
411 return cliffGroundTopShader;
427 412 }
428 413
429 414 function getWaterGroundShader ()
@@ -3349,7 +3334,7 @@ export class WorldView
3349 3334 for (let row = 0; row < CHUNK_SIZE; row++)
3350 3335 {
3351 3336 const object = new GameObject(0, 0, baked.blockImages[row], SORT_BLOCK);
3352 this.#applyAtlasLighting(object, baked.lightmapImage, row, baked.groundImage);
3337 this.#applyAtlasLighting(object, baked.lightmapImage, row);
3353 3338 this.scene.addObject(object);
3354 3339 baked.blockObjects.push(object);
3355 3340 }
@@ -3379,8 +3364,7 @@ export class WorldView
3379 3364 this.#applyAtlasLighting(
3380 3365 baked.blockObjects[row],
3381 3366 baked.lightmapImage,
3382 row,
3383 baked.groundImage
3367 row
3384 3368 );
3385 3369 }
3386 3370 if (baked.bloomCanvas !== atlases.bloom)
@@ -3478,21 +3462,13 @@ export class WorldView
3478 3462 { this.#scheduleTextureWarm(); }
3479 3463 }
3480 3464
3481 #applyAtlasLighting (object, lightmapImage, lightRow, groundImage = null)
3465 #applyAtlasLighting (object, lightmapImage, lightRow)
3482 3466 {
3483 3467 if (!object?.renderer)
3484 3468 { return; }
3485 3469 object._lit = true;
3486 if (groundImage)
3487 {
3488 object.renderer.shader = getAtlasBlockGroundTopShader();
3489 object.renderer.bumpMap = groundImage;
3490 }
3491 else
3492 {
3493 object.renderer.shader = getAtlasLightingShader();
3494 object.renderer.bumpMap = null;
3495 }
3470 object.renderer.shader = getAtlasLightingShader();
3471 object.renderer.bumpMap = null;
3496 3472 object.renderer.secondaryMap = lightmapImage;
3497 3473 object.renderer.shaderUniforms = {
3498 3474 u_ambientDark: 0,
@@ -3500,6 +3476,21 @@ export class WorldView
3500 3476 };
3501 3477 }
3502 3478
3479 #syncCliffGroundTopSprite (object, darkness, groundImage, localX, localY)
3480 {
3481 if (!object?.renderer)
3482 { return; }
3483 object._lit = true;
3484 const dark = Math.min(1, Math.max(0, darkness ?? 0));
3485 object.renderer.shader = getCliffGroundTopShader();
3486 object.renderer.bumpMap = groundImage ?? null;
3487 object.renderer.secondaryMap = null;
3488 object.renderer.shaderUniforms = {
3489 u_darkness: dark,
3490 u_tileLocal: [localX, localY]
3491 };
3492 }
3493
3503 3494 #layoutBakedChunk (snapshot)
3504 3495 {
3505 3496 const key = `${snapshot.chunkX},${snapshot.chunkY}`;
@@ -3637,10 +3628,25 @@ export class WorldView
3637 3628 {
3638 3629 const pivot = tilePivot(tileX, tileY, this.tileSize());
3639 3630 objects.block = this.#ensureSprite(objects.block, tileBlock.sprite, SORT_ENTITY);
3631 const blockDef = blockDefinition(normalizeBlock(snapshot.blocks[index])?.typeId);
3632 objects.cliffGroundTop = !!blockDef?.cliffGroundTop;
3640 3633 if (objects.block)
3641 3634 {
3642 3635 this.#placePivoted(objects.block, pivot.x, pivot.y, pivot.y, SORT_ENTITY);
3643 this.#syncLitSprite(objects.block, objects.shadeAlpha ?? 0);
3636 if (objects.cliffGroundTop)
3637 {
3638 const localX = ((tileX % CHUNK_SIZE) + CHUNK_SIZE) % CHUNK_SIZE;
3639 const localY = ((tileY % CHUNK_SIZE) + CHUNK_SIZE) % CHUNK_SIZE;
3640 this.#syncCliffGroundTopSprite(
3641 objects.block,
3642 objects.shadeAlpha ?? 0,
3643 baked?.groundImage ?? null,
3644 localX,
3645 localY
3646 );
3647 }
3648 else
3649 { this.#syncLitSprite(objects.block, objects.shadeAlpha ?? 0); }
3644 3650 }
3645 3651 objects.blockBloom = this.#placeBloomOverlay(objects.blockBloom, tileBlock.bloom, pivot, SORT_ENTITY);
3646 3652 }
@@ -3650,6 +3656,7 @@ export class WorldView
3650 3656 objects.block = null;
3651 3657 objects.blockBloom?.destroy();
3652 3658 objects.blockBloom = null;
3659 objects.cliffGroundTop = false;
3653 3660 }
3654 3661 }
3655 3662
@@ -3977,7 +3984,23 @@ export class WorldView
3977 3984 if (objects._inViewport === false)
3978 3985 { continue; }
3979 3986 if (objects.block)
3980 { this.#syncLitSprite(objects.block, objects.shadeAlpha); }
3987 {
3988 if (objects.cliffGroundTop)
3989 {
3990 const baked = this.bakedChunks.get(`${objects.chunkX},${objects.chunkY}`);
3991 const localX = ((objects.tileX % CHUNK_SIZE) + CHUNK_SIZE) % CHUNK_SIZE;
3992 const localY = ((objects.tileY % CHUNK_SIZE) + CHUNK_SIZE) % CHUNK_SIZE;
3993 this.#syncCliffGroundTopSprite(
3994 objects.block,
3995 objects.shadeAlpha,
3996 baked?.groundImage ?? null,
3997 localX,
3998 localY
3999 );
4000 }
4001 else
4002 { this.#syncLitSprite(objects.block, objects.shadeAlpha); }
4003 }
3981 4004 if (objects.ground && isWaterGround(objects.groundTypeId))
3982 4005 {
3983 4006 const baked = this.bakedChunks.get(`${objects.chunkX},${objects.chunkY}`);
@@ -15,7 +15,7 @@ import
15 } from "/shared/render/tint.js";
15 } from "/shared/render/tint.js";
16import { layersFromSpawnerConfig } from "/shared/appearance/layers.js";
16import { layersFromSpawnerConfig } from "/shared/appearance/layers.js";
17import { chargeSpriteFrameIndex, itemMaxCharges } from "/shared/items/charges.js";
17import { chargeSpriteFrameIndex, itemMaxCharges } from "/shared/items/charges.js";
18import { normalizeGround, isWadeGroundInSeason, isWaterGround, isLiquidWaterGround, isGroundPassable, isBlockOccludingLight, LightOcclusion } from "/shared/definitions/tiles.js";
18import { normalizeGround, normalizeBlock, isWadeGroundInSeason, isWaterGround, isLiquidWaterGround, isGroundPassable, isBlockOccludingLight, LightOcclusion, blockDefinition } from "/shared/definitions/tiles.js";
19import { spriteCenterFromPivot, spriteDrawSize, tilePivot, ySortLayer, flightSortLayer } from "/shared/render/pivot.js";
19import { spriteCenterFromPivot, spriteDrawSize, tilePivot, ySortLayer, flightSortLayer } from "/shared/render/pivot.js";
20import { bakeChunkAtlases, tileBlockSpriteEntry } from "./chunkBake.js";
20import { bakeChunkAtlases, tileBlockSpriteEntry } from "./chunkBake.js";
21import { createChunkAtlasCache } from "./chunkAtlasCache.js";
21import { createChunkAtlasCache } from "./chunkAtlasCache.js";
@@ -354,51 +354,36 @@ const ATLAS_LIGHTING_FRAG = [
354].join("\n");
354].join("\n");
355
355
356/**
356/**
357 * Block-row atlas: high-chroma magenta → sample the ground atlas (u_bump) at the
357 * Per-tile cliff sprite: high-chroma / authored magenta top → sample this chunk's
358 * same tile-local UV (1:1 scale). Used for cliff tops. Detection requires a real
358 * ground atlas (u_bump) at the cliff's tile-local UV. Only assigned to
359 * magenta mask (R≈B and R−G large); dark near-neutral tints like ebony wood also
359 * `cliffGroundTop` blocks — never to chunk block-row atlases (those keep normal
360 * have R≈B after catalog tint and must not be treated as cliff magenta.
360 * lighting so magenta wood tints are not mistaken for cliff tops).
361 * The ground atlas already includes soft-terrain blending when that preference
362 * is on. Darkness matches ATLAS_LIGHTING_FRAG (lightmap in u_secondary).
363 */
361 */
364const ATLAS_BLOCK_GROUND_TOP_FRAG = [
362const SPRITE_CLIFF_GROUND_TOP_FRAG = [
365 "precision mediump float;",
363 "precision mediump float;",
366 "varying vec2 v_texCoord;",
364 "varying vec2 v_texCoord;",
367 "uniform sampler2D u_texture;",
365 "uniform sampler2D u_texture;",
368 "uniform sampler2D u_secondary;",
369 "uniform sampler2D u_bump;",
366 "uniform sampler2D u_bump;",
370 "uniform float u_alpha;",
367 "uniform float u_alpha;",
371 "uniform float u_ambientDark;",
368 "uniform float u_darkness;",
372 "uniform float u_lightRow;",
369 "uniform vec2 u_tileLocal;",
373 "void main() {",
370 "void main() {",
374 " vec4 color = texture2D(u_texture, v_texCoord);",
371 " vec4 color = texture2D(u_texture, v_texCoord);",
375 " if (color.a <= 0.0) { discard; }",
372 " if (color.a <= 0.0) { discard; }",
376 " vec3 rgb = color.rgb;",
373 " vec3 rgb = color.rgb;",
377 " // Authored magenta masks only (cliff tops). Not post-tint ebony etc.",
378 " float rbDiff = abs(rgb.r - rgb.b);",
374 " float rbDiff = abs(rgb.r - rgb.b);",
379 " float magentaChroma = rgb.r - rgb.g;",
375 " if (rbDiff < 0.02 && rgb.g < rgb.r) {",
380 " if (rbDiff < 0.02 && magentaChroma > 0.15) {",
376 " vec2 groundUV = (u_tileLocal + v_texCoord) / 16.0;",
381 " float tileX = floor(v_texCoord.x * 16.0);",
382 " float tileY = max(u_lightRow, 0.0);",
383 " float localX = fract(v_texCoord.x * 16.0);",
384 " float localY = v_texCoord.y;",
385 " vec2 groundUV = vec2((tileX + localX) / 16.0, (tileY + localY) / 16.0);",
386 " rgb = texture2D(u_bump, groundUV).rgb;",
377 " rgb = texture2D(u_bump, groundUV).rgb;",
387 " }",
378 " }",
388 " vec2 lightUV = v_texCoord;",
379 " rgb = mix(rgb, vec3(0.0), u_darkness);",
389 " if (u_lightRow >= 0.0) {",
390 " lightUV.y = (u_lightRow + v_texCoord.y) / 16.0;",
391 " }",
392 " float lit = texture2D(u_secondary, lightUV).r;",
393 " float darkness = u_ambientDark * (1.0 - lit);",
394 " rgb = mix(rgb, vec3(0.0), darkness);",
395 " gl_FragColor = vec4(rgb, color.a * u_alpha);",
380 " gl_FragColor = vec4(rgb, color.a * u_alpha);",
396 "}"
381 "}"
397].join("\n");
382].join("\n");
398
383
399let spriteLightingShader = null;
384let spriteLightingShader = null;
400let atlasLightingShader = null;
385let atlasLightingShader = null;
401let atlasBlockGroundTopShader = null;
386let cliffGroundTopShader = null;
402let waterGroundShader = null;
387let waterGroundShader = null;
403let tintLitSpriteShader = null;
388let tintLitSpriteShader = null;
404let dualTintLitSpriteShader = null;
389let dualTintLitSpriteShader = null;
@@ -419,11 +404,11 @@ function getAtlasLightingShader ()
419 return atlasLightingShader;
404 return atlasLightingShader;
420}
405}
421
406
422function getAtlasBlockGroundTopShader ()
407function getCliffGroundTopShader ()
423{
408{
424 if (!atlasBlockGroundTopShader)
409 if (!cliffGroundTopShader)
425 { atlasBlockGroundTopShader = Shader.fragment(ATLAS_BLOCK_GROUND_TOP_FRAG); }
410 { cliffGroundTopShader = Shader.fragment(SPRITE_CLIFF_GROUND_TOP_FRAG); }
426 return atlasBlockGroundTopShader;
411 return cliffGroundTopShader;
427}
412}
428
413
429function getWaterGroundShader ()
414function getWaterGroundShader ()
@@ -3349,7 +3334,7 @@ export class WorldView
3349 for (let row = 0; row < CHUNK_SIZE; row++)
3334 for (let row = 0; row < CHUNK_SIZE; row++)
3350 {
3335 {
3351 const object = new GameObject(0, 0, baked.blockImages[row], SORT_BLOCK);
3336 const object = new GameObject(0, 0, baked.blockImages[row], SORT_BLOCK);
3352 this.#applyAtlasLighting(object, baked.lightmapImage, row, baked.groundImage);
3337 this.#applyAtlasLighting(object, baked.lightmapImage, row);
3353 this.scene.addObject(object);
3338 this.scene.addObject(object);
3354 baked.blockObjects.push(object);
3339 baked.blockObjects.push(object);
3355 }
3340 }
@@ -3379,8 +3364,7 @@ export class WorldView
3379 this.#applyAtlasLighting(
3364 this.#applyAtlasLighting(
3380 baked.blockObjects[row],
3365 baked.blockObjects[row],
3381 baked.lightmapImage,
3366 baked.lightmapImage,
3382 row,
3367 row
3383 baked.groundImage
3384 );
3368 );
3385 }
3369 }
3386 if (baked.bloomCanvas !== atlases.bloom)
3370 if (baked.bloomCanvas !== atlases.bloom)
@@ -3478,21 +3462,13 @@ export class WorldView
3478 { this.#scheduleTextureWarm(); }
3462 { this.#scheduleTextureWarm(); }
3479 }
3463 }
3480
3464
3481 #applyAtlasLighting (object, lightmapImage, lightRow, groundImage = null)
3465 #applyAtlasLighting (object, lightmapImage, lightRow)
3482 {
3466 {
3483 if (!object?.renderer)
3467 if (!object?.renderer)
3484 { return; }
3468 { return; }
3485 object._lit = true;
3469 object._lit = true;
3486 if (groundImage)
3470 object.renderer.shader = getAtlasLightingShader();
3487 {
3471 object.renderer.bumpMap = null;
3488 object.renderer.shader = getAtlasBlockGroundTopShader();
3489 object.renderer.bumpMap = groundImage;
3490 }
3491 else
3492 {
3493 object.renderer.shader = getAtlasLightingShader();
3494 object.renderer.bumpMap = null;
3495 }
3496 object.renderer.secondaryMap = lightmapImage;
3472 object.renderer.secondaryMap = lightmapImage;
3497 object.renderer.shaderUniforms = {
3473 object.renderer.shaderUniforms = {
3498 u_ambientDark: 0,
3474 u_ambientDark: 0,
@@ -3500,6 +3476,21 @@ export class WorldView
3500 };
3476 };
3501 }
3477 }
3502
3478
3479 #syncCliffGroundTopSprite (object, darkness, groundImage, localX, localY)
3480 {
3481 if (!object?.renderer)
3482 { return; }
3483 object._lit = true;
3484 const dark = Math.min(1, Math.max(0, darkness ?? 0));
3485 object.renderer.shader = getCliffGroundTopShader();
3486 object.renderer.bumpMap = groundImage ?? null;
3487 object.renderer.secondaryMap = null;
3488 object.renderer.shaderUniforms = {
3489 u_darkness: dark,
3490 u_tileLocal: [localX, localY]
3491 };
3492 }
3493
3503 #layoutBakedChunk (snapshot)
3494 #layoutBakedChunk (snapshot)
3504 {
3495 {
3505 const key = `${snapshot.chunkX},${snapshot.chunkY}`;
3496 const key = `${snapshot.chunkX},${snapshot.chunkY}`;
@@ -3637,10 +3628,25 @@ export class WorldView
3637 {
3628 {
3638 const pivot = tilePivot(tileX, tileY, this.tileSize());
3629 const pivot = tilePivot(tileX, tileY, this.tileSize());
3639 objects.block = this.#ensureSprite(objects.block, tileBlock.sprite, SORT_ENTITY);
3630 objects.block = this.#ensureSprite(objects.block, tileBlock.sprite, SORT_ENTITY);
3631 const blockDef = blockDefinition(normalizeBlock(snapshot.blocks[index])?.typeId);
3632 objects.cliffGroundTop = !!blockDef?.cliffGroundTop;
3640 if (objects.block)
3633 if (objects.block)
3641 {
3634 {
3642 this.#placePivoted(objects.block, pivot.x, pivot.y, pivot.y, SORT_ENTITY);
3635 this.#placePivoted(objects.block, pivot.x, pivot.y, pivot.y, SORT_ENTITY);
3643 this.#syncLitSprite(objects.block, objects.shadeAlpha ?? 0);
3636 if (objects.cliffGroundTop)
3637 {
3638 const localX = ((tileX % CHUNK_SIZE) + CHUNK_SIZE) % CHUNK_SIZE;
3639 const localY = ((tileY % CHUNK_SIZE) + CHUNK_SIZE) % CHUNK_SIZE;
3640 this.#syncCliffGroundTopSprite(
3641 objects.block,
3642 objects.shadeAlpha ?? 0,
3643 baked?.groundImage ?? null,
3644 localX,
3645 localY
3646 );
3647 }
3648 else
3649 { this.#syncLitSprite(objects.block, objects.shadeAlpha ?? 0); }
3644 }
3650 }
3645 objects.blockBloom = this.#placeBloomOverlay(objects.blockBloom, tileBlock.bloom, pivot, SORT_ENTITY);
3651 objects.blockBloom = this.#placeBloomOverlay(objects.blockBloom, tileBlock.bloom, pivot, SORT_ENTITY);
3646 }
3652 }
@@ -3650,6 +3656,7 @@ export class WorldView
3650 objects.block = null;
3656 objects.block = null;
3651 objects.blockBloom?.destroy();
3657 objects.blockBloom?.destroy();
3652 objects.blockBloom = null;
3658 objects.blockBloom = null;
3659 objects.cliffGroundTop = false;
3653 }
3660 }
3654 }
3661 }
3655
3662
@@ -3977,7 +3984,23 @@ export class WorldView
3977 if (objects._inViewport === false)
3984 if (objects._inViewport === false)
3978 { continue; }
3985 { continue; }
3979 if (objects.block)
3986 if (objects.block)
3980 { this.#syncLitSprite(objects.block, objects.shadeAlpha); }
3987 {
3988 if (objects.cliffGroundTop)
3989 {
3990 const baked = this.bakedChunks.get(`${objects.chunkX},${objects.chunkY}`);
3991 const localX = ((objects.tileX % CHUNK_SIZE) + CHUNK_SIZE) % CHUNK_SIZE;
3992 const localY = ((objects.tileY % CHUNK_SIZE) + CHUNK_SIZE) % CHUNK_SIZE;
3993 this.#syncCliffGroundTopSprite(
3994 objects.block,
3995 objects.shadeAlpha,
3996 baked?.groundImage ?? null,
3997 localX,
3998 localY
3999 );
4000 }
4001 else
4002 { this.#syncLitSprite(objects.block, objects.shadeAlpha); }
4003 }
3981 if (objects.ground && isWaterGround(objects.groundTypeId))
4004 if (objects.ground && isWaterGround(objects.groundTypeId))
3982 {
4005 {
3983 const baked = this.bakedChunks.get(`${objects.chunkX},${objects.chunkY}`);
4006 const baked = this.bakedChunks.get(`${objects.chunkX},${objects.chunkY}`);
server/tests/chunk-atlas-baked-blocks.test.js +6 −0
@@ -35,6 +35,12 @@ test("stone walls remain chunk-atlas baked", () =>
35 35 assert.equal(isChunkAtlasBakedBlock({ typeId: BlockType.stoneWall }), true);
36 36 });
37 37
38 test("cliff blocks are per-tile (ground-top shader), not atlas-baked", () =>
39 {
40 assert.equal(isChunkAtlasBakedBlock({ typeId: BlockType.cliff }), false);
41 assert.equal(isChunkAtlasBakedBlock({ typeId: BlockType.cliffThin }), false);
42 });
43
38 44 test("runtime campfires are not chunk-atlas baked", () =>
39 45 {
40 46 assert.equal(isChunkAtlasBakedBlock({
@@ -35,6 +35,12 @@ test("stone walls remain chunk-atlas baked", () =>
35 assert.equal(isChunkAtlasBakedBlock({ typeId: BlockType.stoneWall }), true);
35 assert.equal(isChunkAtlasBakedBlock({ typeId: BlockType.stoneWall }), true);
36});
36});
37
37
38test("cliff blocks are per-tile (ground-top shader), not atlas-baked", () =>
39{
40 assert.equal(isChunkAtlasBakedBlock({ typeId: BlockType.cliff }), false);
41 assert.equal(isChunkAtlasBakedBlock({ typeId: BlockType.cliffThin }), false);
42});
43
38test("runtime campfires are not chunk-atlas baked", () =>
44test("runtime campfires are not chunk-atlas baked", () =>
39{
45{
40 assert.equal(isChunkAtlasBakedBlock({
46 assert.equal(isChunkAtlasBakedBlock({
shared/definitions/tiles.js +7 −2
@@ -286,8 +286,9 @@ export const BLOCK_DEFINITIONS = Object.freeze({
286 286 neighborConnect: true,
287 287 neighborConnectNamed: true,
288 288 /**
289 * Magenta top faces are replaced at draw time by sampling the chunk
290 * ground atlas at the same tile-local UV (1:1; includes soft-terrain blend).
289 * Magenta top faces are replaced at draw time by a dedicated per-tile
290 * cliff shader that samples the chunk ground atlas (1:1 UV, soft-terrain
291 * blend included). These blocks are not baked into chunk atlas rows.
291 292 */
292 293 cliffGroundTop: true
293 294 }),
@@ -303,6 +304,7 @@ export const BLOCK_DEFINITIONS = Object.freeze({
303 304 outdoor: true,
304 305 neighborConnect: true,
305 306 neighborConnectNamed: true,
307 /** @see {@link BlockType.cliff} `cliffGroundTop` */
306 308 cliffGroundTop: true
307 309 }),
308 310 [BlockType.torch]: Object.freeze({
@@ -834,6 +836,9 @@ export function isChunkAtlasBakedBlock (block)
834 836 { return false; }
835 837 if (def.perTileBlock)
836 838 { return false; }
839 /** Cliff tops need a dedicated per-tile ground-sample shader, not the row atlas. */
840 if (def.cliffGroundTop)
841 { return false; }
837 842 if (resourceNodeDisplayName(entry))
838 843 { return false; }
839 844 if (isPickablePlantBlock(entry))
@@ -286,8 +286,9 @@ export const BLOCK_DEFINITIONS = Object.freeze({
286 neighborConnect: true,
286 neighborConnect: true,
287 neighborConnectNamed: true,
287 neighborConnectNamed: true,
288 /**
288 /**
289 * Magenta top faces are replaced at draw time by sampling the chunk
289 * Magenta top faces are replaced at draw time by a dedicated per-tile
290 * ground atlas at the same tile-local UV (1:1; includes soft-terrain blend).
290 * cliff shader that samples the chunk ground atlas (1:1 UV, soft-terrain
291 * blend included). These blocks are not baked into chunk atlas rows.
291 */
292 */
292 cliffGroundTop: true
293 cliffGroundTop: true
293 }),
294 }),
@@ -303,6 +304,7 @@ export const BLOCK_DEFINITIONS = Object.freeze({
303 outdoor: true,
304 outdoor: true,
304 neighborConnect: true,
305 neighborConnect: true,
305 neighborConnectNamed: true,
306 neighborConnectNamed: true,
307 /** @see {@link BlockType.cliff} `cliffGroundTop` */
306 cliffGroundTop: true
308 cliffGroundTop: true
307 }),
309 }),
308 [BlockType.torch]: Object.freeze({
310 [BlockType.torch]: Object.freeze({
@@ -834,6 +836,9 @@ export function isChunkAtlasBakedBlock (block)
834 { return false; }
836 { return false; }
835 if (def.perTileBlock)
837 if (def.perTileBlock)
836 { return false; }
838 { return false; }
839 /** Cliff tops need a dedicated per-tile ground-sample shader, not the row atlas. */
840 if (def.cliffGroundTop)
841 { return false; }
837 if (resourceNodeDisplayName(entry))
842 if (resourceNodeDisplayName(entry))
838 { return false; }
843 { return false; }
839 if (isPickablePlantBlock(entry))
844 if (isPickablePlantBlock(entry))