BlueGit

timfa questward

Merge branch 'feature/remove-thick-smooth-stone-wall'

timfa Tim Falken · pushed by timfa

Authored 2026-08-31 · 2 months ago

Hash
a627562e8b062ee46e0e7aee4c60191aaeddd3d9
55 files changed +96 −71
client/assets/blocks/fence/0.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/1.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/10.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/11.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/12.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/13.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/14.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/15.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/2.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/3.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/4.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/5.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/6.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/7.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/8.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/fence/9.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/1.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/10.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/11.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/12.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/13.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/14.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/15.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/2.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/3.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/4.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/5.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/6.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/7.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/8.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/table/9.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-e.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-es.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-esw.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-n.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-ne.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-nes.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-nesw.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-ns.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-s.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-sw.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-swn.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-w.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-we.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-wn.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall-wne.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-smooth-stone-wall/thick-smooth-stone-wall.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/staff/staff.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/sword/sword.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/waraxe/waraxe.png Binary file +0 −0

The contents of this binary file are not shown.

client/scripts/texture-wall-sprites.mjs +3 −2
@@ -550,7 +550,6 @@ const VARIANT_OUT = {
550 550 thin: { dir: "thin-stone-wall", named: true, prefix: "thin-stone-wall" }
551 551 },
552 552 smooth: {
553 thick: { dir: "thick-smooth-stone-wall", named: true, prefix: "thick-smooth-stone-wall" },
554 553 thin: { dir: "thin-smooth-stone-wall", named: true, prefix: "thin-smooth-stone-wall" }
555 554 },
556 555 brick: {
@@ -648,8 +647,10 @@ function bakeVariant (variant, { force = false } = {})
648 647 let wrote = 0;
649 648 for (const kind of ["thick", "thin"])
650 649 {
651 const shapeKey = `${kind}-stone-wall`;
652 650 const out = cfg[kind];
651 if (!out)
652 { continue; }
653 const shapeKey = `${kind}-stone-wall`;
653 654 const outDir = join(ROOT, out.dir);
654 655 mkdirSync(outDir, { recursive: true });
655 656 const files = shapeFiles(shapeKey);
@@ -550,7 +550,6 @@ const VARIANT_OUT = {
550 thin: { dir: "thin-stone-wall", named: true, prefix: "thin-stone-wall" }
550 thin: { dir: "thin-stone-wall", named: true, prefix: "thin-stone-wall" }
551 },
551 },
552 smooth: {
552 smooth: {
553 thick: { dir: "thick-smooth-stone-wall", named: true, prefix: "thick-smooth-stone-wall" },
554 thin: { dir: "thin-smooth-stone-wall", named: true, prefix: "thin-smooth-stone-wall" }
553 thin: { dir: "thin-smooth-stone-wall", named: true, prefix: "thin-smooth-stone-wall" }
555 },
554 },
556 brick: {
555 brick: {
@@ -648,8 +647,10 @@ function bakeVariant (variant, { force = false } = {})
648 let wrote = 0;
647 let wrote = 0;
649 for (const kind of ["thick", "thin"])
648 for (const kind of ["thick", "thin"])
650 {
649 {
651 const shapeKey = `${kind}-stone-wall`;
652 const out = cfg[kind];
650 const out = cfg[kind];
651 if (!out)
652 { continue; }
653 const shapeKey = `${kind}-stone-wall`;
653 const outDir = join(ROOT, out.dir);
654 const outDir = join(ROOT, out.dir);
654 mkdirSync(outDir, { recursive: true });
655 mkdirSync(outDir, { recursive: true });
655 const files = shapeFiles(shapeKey);
656 const files = shapeFiles(shapeKey);
client/src/render/worldView.js +77 −51
@@ -6,16 +6,16 @@ import { smoothLitCorner } from "/shared/lighting/lightCorners.js";
6 6 import { bloomCompanionName, spriteImageName } from "/shared/definitions/tileSprites.js";
7 7 import { EQUIPMENT_SLOT, itemEquipSprite, itemSpriteName, itemDefinition } from "/shared/definitions/items.js";
8 8 import
9 {
10 resolveItemTint,
11 resolveEquipTint,
12 resolveItemDualTint,
13 resolveEquipDualTint,
14 normalizeRgb
15 } from "/shared/render/tint.js";
9 {
10 resolveItemTint,
11 resolveEquipTint,
12 resolveItemDualTint,
13 resolveEquipDualTint,
14 normalizeRgb
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,48 +354,36 @@ const ATLAS_LIGHTING_FRAG = [
354 354 ].join("\n");
355 355
356 356 /**
357 * Block-row atlas: magenta → sample the ground atlas (u_bump) at the same
358 * tile-local UV (1:1 scale). The ground atlas already includes soft-terrain
359 * blending when that preference is on, so cliff tops match the floor beneath.
360 * 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).
361 361 */
362 const ATLAS_BLOCK_GROUND_TOP_FRAG = [
362 const SPRITE_CLIFF_GROUND_TOP_FRAG = [
363 363 "precision mediump float;",
364 364 "varying vec2 v_texCoord;",
365 365 "uniform sampler2D u_texture;",
366 "uniform sampler2D u_secondary;",
367 366 "uniform sampler2D u_bump;",
368 367 "uniform float u_alpha;",
369 "uniform float u_ambientDark;",
370 "uniform float u_lightRow;",
368 "uniform float u_darkness;",
369 "uniform vec2 u_tileLocal;",
371 370 "void main() {",
372 371 " vec4 color = texture2D(u_texture, v_texCoord);",
373 372 " if (color.a <= 0.0) { discard; }",
374 373 " vec3 rgb = color.rgb;",
375 " // Magenta family (R≈B, G<R): replace with blended ground under this pixel.",
376 374 " float rbDiff = abs(rgb.r - rgb.b);",
377 " if (rbDiff < 0.02 && rgb.g < rgb.r - 0.02) {",
378 " float tileX = floor(v_texCoord.x * 16.0);",
379 " float tileY = max(u_lightRow, 0.0);",
380 " float localX = fract(v_texCoord.x * 16.0);",
381 " float localY = v_texCoord.y;",
382 " 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;",
383 377 " rgb = texture2D(u_bump, groundUV).rgb;",
384 378 " }",
385 " vec2 lightUV = v_texCoord;",
386 " if (u_lightRow >= 0.0) {",
387 " lightUV.y = (u_lightRow + v_texCoord.y) / 16.0;",
388 " }",
389 " float lit = texture2D(u_secondary, lightUV).r;",
390 " float darkness = u_ambientDark * (1.0 - lit);",
391 " rgb = mix(rgb, vec3(0.0), darkness);",
379 " rgb = mix(rgb, vec3(0.0), u_darkness);",
392 380 " gl_FragColor = vec4(rgb, color.a * u_alpha);",
393 381 "}"
394 382 ].join("\n");
395 383
396 384 let spriteLightingShader = null;
397 385 let atlasLightingShader = null;
398 let atlasBlockGroundTopShader = null;
386 let cliffGroundTopShader = null;
399 387 let waterGroundShader = null;
400 388 let tintLitSpriteShader = null;
401 389 let dualTintLitSpriteShader = null;
@@ -416,11 +404,11 @@ function getAtlasLightingShader ()
416 404 return atlasLightingShader;
417 405 }
418 406
419 function getAtlasBlockGroundTopShader ()
407 function getCliffGroundTopShader ()
420 408 {
421 if (!atlasBlockGroundTopShader)
422 { atlasBlockGroundTopShader = Shader.fragment(ATLAS_BLOCK_GROUND_TOP_FRAG); }
423 return atlasBlockGroundTopShader;
409 if (!cliffGroundTopShader)
410 { cliffGroundTopShader = Shader.fragment(SPRITE_CLIFF_GROUND_TOP_FRAG); }
411 return cliffGroundTopShader;
424 412 }
425 413
426 414 function getWaterGroundShader ()
@@ -3346,7 +3334,7 @@ export class WorldView
3346 3334 for (let row = 0; row < CHUNK_SIZE; row++)
3347 3335 {
3348 3336 const object = new GameObject(0, 0, baked.blockImages[row], SORT_BLOCK);
3349 this.#applyAtlasLighting(object, baked.lightmapImage, row, baked.groundImage);
3337 this.#applyAtlasLighting(object, baked.lightmapImage, row);
3350 3338 this.scene.addObject(object);
3351 3339 baked.blockObjects.push(object);
3352 3340 }
@@ -3376,8 +3364,7 @@ export class WorldView
3376 3364 this.#applyAtlasLighting(
3377 3365 baked.blockObjects[row],
3378 3366 baked.lightmapImage,
3379 row,
3380 baked.groundImage
3367 row
3381 3368 );
3382 3369 }
3383 3370 if (baked.bloomCanvas !== atlases.bloom)
@@ -3475,21 +3462,13 @@ export class WorldView
3475 3462 { this.#scheduleTextureWarm(); }
3476 3463 }
3477 3464
3478 #applyAtlasLighting (object, lightmapImage, lightRow, groundImage = null)
3465 #applyAtlasLighting (object, lightmapImage, lightRow)
3479 3466 {
3480 3467 if (!object?.renderer)
3481 3468 { return; }
3482 3469 object._lit = true;
3483 if (groundImage)
3484 {
3485 object.renderer.shader = getAtlasBlockGroundTopShader();
3486 object.renderer.bumpMap = groundImage;
3487 }
3488 else
3489 {
3490 object.renderer.shader = getAtlasLightingShader();
3491 object.renderer.bumpMap = null;
3492 }
3470 object.renderer.shader = getAtlasLightingShader();
3471 object.renderer.bumpMap = null;
3493 3472 object.renderer.secondaryMap = lightmapImage;
3494 3473 object.renderer.shaderUniforms = {
3495 3474 u_ambientDark: 0,
@@ -3497,6 +3476,21 @@ export class WorldView
3497 3476 };
3498 3477 }
3499 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
3500 3494 #layoutBakedChunk (snapshot)
3501 3495 {
3502 3496 const key = `${snapshot.chunkX},${snapshot.chunkY}`;
@@ -3634,10 +3628,25 @@ export class WorldView
3634 3628 {
3635 3629 const pivot = tilePivot(tileX, tileY, this.tileSize());
3636 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;
3637 3633 if (objects.block)
3638 3634 {
3639 3635 this.#placePivoted(objects.block, pivot.x, pivot.y, pivot.y, SORT_ENTITY);
3640 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); }
3641 3650 }
3642 3651 objects.blockBloom = this.#placeBloomOverlay(objects.blockBloom, tileBlock.bloom, pivot, SORT_ENTITY);
3643 3652 }
@@ -3647,6 +3656,7 @@ export class WorldView
3647 3656 objects.block = null;
3648 3657 objects.blockBloom?.destroy();
3649 3658 objects.blockBloom = null;
3659 objects.cliffGroundTop = false;
3650 3660 }
3651 3661 }
3652 3662
@@ -3974,7 +3984,23 @@ export class WorldView
3974 3984 if (objects._inViewport === false)
3975 3985 { continue; }
3976 3986 if (objects.block)
3977 { 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 }
3978 4004 if (objects.ground && isWaterGround(objects.groundTypeId))
3979 4005 {
3980 4006 const baked = this.bakedChunks.get(`${objects.chunkX},${objects.chunkY}`);
@@ -6,16 +6,16 @@ import { smoothLitCorner } from "/shared/lighting/lightCorners.js";
6import { bloomCompanionName, spriteImageName } from "/shared/definitions/tileSprites.js";
6import { bloomCompanionName, spriteImageName } from "/shared/definitions/tileSprites.js";
7import { EQUIPMENT_SLOT, itemEquipSprite, itemSpriteName, itemDefinition } from "/shared/definitions/items.js";
7import { EQUIPMENT_SLOT, itemEquipSprite, itemSpriteName, itemDefinition } from "/shared/definitions/items.js";
8import
8import
9 {
9{
10 resolveItemTint,
10 resolveItemTint,
11 resolveEquipTint,
11 resolveEquipTint,
12 resolveItemDualTint,
12 resolveItemDualTint,
13 resolveEquipDualTint,
13 resolveEquipDualTint,
14 normalizeRgb
14 normalizeRgb
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,48 +354,36 @@ const ATLAS_LIGHTING_FRAG = [
354].join("\n");
354].join("\n");
355
355
356/**
356/**
357 * Block-row atlas: magenta → sample the ground atlas (u_bump) at the same
357 * Per-tile cliff sprite: high-chroma / authored magenta top → sample this chunk's
358 * tile-local UV (1:1 scale). The ground atlas already includes soft-terrain
358 * ground atlas (u_bump) at the cliff's tile-local UV. Only assigned to
359 * blending when that preference is on, so cliff tops match the floor beneath.
359 * `cliffGroundTop` blocks — never to chunk block-row atlases (those keep normal
360 * Darkness matches ATLAS_LIGHTING_FRAG (lightmap in u_secondary).
360 * lighting so magenta wood tints are not mistaken for cliff tops).
361 */
361 */
362const ATLAS_BLOCK_GROUND_TOP_FRAG = [
362const SPRITE_CLIFF_GROUND_TOP_FRAG = [
363 "precision mediump float;",
363 "precision mediump float;",
364 "varying vec2 v_texCoord;",
364 "varying vec2 v_texCoord;",
365 "uniform sampler2D u_texture;",
365 "uniform sampler2D u_texture;",
366 "uniform sampler2D u_secondary;",
367 "uniform sampler2D u_bump;",
366 "uniform sampler2D u_bump;",
368 "uniform float u_alpha;",
367 "uniform float u_alpha;",
369 "uniform float u_ambientDark;",
368 "uniform float u_darkness;",
370 "uniform float u_lightRow;",
369 "uniform vec2 u_tileLocal;",
371 "void main() {",
370 "void main() {",
372 " vec4 color = texture2D(u_texture, v_texCoord);",
371 " vec4 color = texture2D(u_texture, v_texCoord);",
373 " if (color.a <= 0.0) { discard; }",
372 " if (color.a <= 0.0) { discard; }",
374 " vec3 rgb = color.rgb;",
373 " vec3 rgb = color.rgb;",
375 " // Magenta family (R≈B, G<R): replace with blended ground under this pixel.",
376 " float rbDiff = abs(rgb.r - rgb.b);",
374 " float rbDiff = abs(rgb.r - rgb.b);",
377 " if (rbDiff < 0.02 && rgb.g < rgb.r - 0.02) {",
375 " if (rbDiff < 0.02 && rgb.g < rgb.r) {",
378 " float tileX = floor(v_texCoord.x * 16.0);",
376 " vec2 groundUV = (u_tileLocal + v_texCoord) / 16.0;",
379 " float tileY = max(u_lightRow, 0.0);",
380 " float localX = fract(v_texCoord.x * 16.0);",
381 " float localY = v_texCoord.y;",
382 " vec2 groundUV = vec2((tileX + localX) / 16.0, (tileY + localY) / 16.0);",
383 " rgb = texture2D(u_bump, groundUV).rgb;",
377 " rgb = texture2D(u_bump, groundUV).rgb;",
384 " }",
378 " }",
385 " vec2 lightUV = v_texCoord;",
379 " rgb = mix(rgb, vec3(0.0), u_darkness);",
386 " if (u_lightRow >= 0.0) {",
387 " lightUV.y = (u_lightRow + v_texCoord.y) / 16.0;",
388 " }",
389 " float lit = texture2D(u_secondary, lightUV).r;",
390 " float darkness = u_ambientDark * (1.0 - lit);",
391 " rgb = mix(rgb, vec3(0.0), darkness);",
392 " gl_FragColor = vec4(rgb, color.a * u_alpha);",
380 " gl_FragColor = vec4(rgb, color.a * u_alpha);",
393 "}"
381 "}"
394].join("\n");
382].join("\n");
395
383
396let spriteLightingShader = null;
384let spriteLightingShader = null;
397let atlasLightingShader = null;
385let atlasLightingShader = null;
398let atlasBlockGroundTopShader = null;
386let cliffGroundTopShader = null;
399let waterGroundShader = null;
387let waterGroundShader = null;
400let tintLitSpriteShader = null;
388let tintLitSpriteShader = null;
401let dualTintLitSpriteShader = null;
389let dualTintLitSpriteShader = null;
@@ -416,11 +404,11 @@ function getAtlasLightingShader ()
416 return atlasLightingShader;
404 return atlasLightingShader;
417}
405}
418
406
419function getAtlasBlockGroundTopShader ()
407function getCliffGroundTopShader ()
420{
408{
421 if (!atlasBlockGroundTopShader)
409 if (!cliffGroundTopShader)
422 { atlasBlockGroundTopShader = Shader.fragment(ATLAS_BLOCK_GROUND_TOP_FRAG); }
410 { cliffGroundTopShader = Shader.fragment(SPRITE_CLIFF_GROUND_TOP_FRAG); }
423 return atlasBlockGroundTopShader;
411 return cliffGroundTopShader;
424}
412}
425
413
426function getWaterGroundShader ()
414function getWaterGroundShader ()
@@ -3346,7 +3334,7 @@ export class WorldView
3346 for (let row = 0; row < CHUNK_SIZE; row++)
3334 for (let row = 0; row < CHUNK_SIZE; row++)
3347 {
3335 {
3348 const object = new GameObject(0, 0, baked.blockImages[row], SORT_BLOCK);
3336 const object = new GameObject(0, 0, baked.blockImages[row], SORT_BLOCK);
3349 this.#applyAtlasLighting(object, baked.lightmapImage, row, baked.groundImage);
3337 this.#applyAtlasLighting(object, baked.lightmapImage, row);
3350 this.scene.addObject(object);
3338 this.scene.addObject(object);
3351 baked.blockObjects.push(object);
3339 baked.blockObjects.push(object);
3352 }
3340 }
@@ -3376,8 +3364,7 @@ export class WorldView
3376 this.#applyAtlasLighting(
3364 this.#applyAtlasLighting(
3377 baked.blockObjects[row],
3365 baked.blockObjects[row],
3378 baked.lightmapImage,
3366 baked.lightmapImage,
3379 row,
3367 row
3380 baked.groundImage
3381 );
3368 );
3382 }
3369 }
3383 if (baked.bloomCanvas !== atlases.bloom)
3370 if (baked.bloomCanvas !== atlases.bloom)
@@ -3475,21 +3462,13 @@ export class WorldView
3475 { this.#scheduleTextureWarm(); }
3462 { this.#scheduleTextureWarm(); }
3476 }
3463 }
3477
3464
3478 #applyAtlasLighting (object, lightmapImage, lightRow, groundImage = null)
3465 #applyAtlasLighting (object, lightmapImage, lightRow)
3479 {
3466 {
3480 if (!object?.renderer)
3467 if (!object?.renderer)
3481 { return; }
3468 { return; }
3482 object._lit = true;
3469 object._lit = true;
3483 if (groundImage)
3470 object.renderer.shader = getAtlasLightingShader();
3484 {
3471 object.renderer.bumpMap = null;
3485 object.renderer.shader = getAtlasBlockGroundTopShader();
3486 object.renderer.bumpMap = groundImage;
3487 }
3488 else
3489 {
3490 object.renderer.shader = getAtlasLightingShader();
3491 object.renderer.bumpMap = null;
3492 }
3493 object.renderer.secondaryMap = lightmapImage;
3472 object.renderer.secondaryMap = lightmapImage;
3494 object.renderer.shaderUniforms = {
3473 object.renderer.shaderUniforms = {
3495 u_ambientDark: 0,
3474 u_ambientDark: 0,
@@ -3497,6 +3476,21 @@ export class WorldView
3497 };
3476 };
3498 }
3477 }
3499
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
3500 #layoutBakedChunk (snapshot)
3494 #layoutBakedChunk (snapshot)
3501 {
3495 {
3502 const key = `${snapshot.chunkX},${snapshot.chunkY}`;
3496 const key = `${snapshot.chunkX},${snapshot.chunkY}`;
@@ -3634,10 +3628,25 @@ export class WorldView
3634 {
3628 {
3635 const pivot = tilePivot(tileX, tileY, this.tileSize());
3629 const pivot = tilePivot(tileX, tileY, this.tileSize());
3636 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;
3637 if (objects.block)
3633 if (objects.block)
3638 {
3634 {
3639 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);
3640 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); }
3641 }
3650 }
3642 objects.blockBloom = this.#placeBloomOverlay(objects.blockBloom, tileBlock.bloom, pivot, SORT_ENTITY);
3651 objects.blockBloom = this.#placeBloomOverlay(objects.blockBloom, tileBlock.bloom, pivot, SORT_ENTITY);
3643 }
3652 }
@@ -3647,6 +3656,7 @@ export class WorldView
3647 objects.block = null;
3656 objects.block = null;
3648 objects.blockBloom?.destroy();
3657 objects.blockBloom?.destroy();
3649 objects.blockBloom = null;
3658 objects.blockBloom = null;
3659 objects.cliffGroundTop = false;
3650 }
3660 }
3651 }
3661 }
3652
3662
@@ -3974,7 +3984,23 @@ export class WorldView
3974 if (objects._inViewport === false)
3984 if (objects._inViewport === false)
3975 { continue; }
3985 { continue; }
3976 if (objects.block)
3986 if (objects.block)
3977 { 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 }
3978 if (objects.ground && isWaterGround(objects.groundTypeId))
4004 if (objects.ground && isWaterGround(objects.groundTypeId))
3979 {
4005 {
3980 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({
server/tests/tile-states.test.js +2 −2
@@ -23,9 +23,9 @@ test("sprite folders expose alphabetical states; first is default", () =>
23 23 assert.equal(catalog.blocks["thin-stone-wall"].defaultState, "thin-stone-wall");
24 24 assert.equal(catalog.blocks["thin-stone-wall"].states.length, 16);
25 25 assert.ok(catalog.images.some((image) => image.name === "block:thin-stone-wall:thin-stone-wall-wne"));
26 assert.equal(catalog.blocks["thick-smooth-stone-wall"].states.length, 16);
27 26 assert.equal(catalog.blocks["thin-smooth-stone-wall"].states.length, 16);
28 assert.ok(catalog.images.some((image) => image.name === "block:thick-smooth-stone-wall:thick-smooth-stone-wall"));
27 assert.ok(catalog.images.some((image) => image.name === "block:thin-smooth-stone-wall:thin-smooth-stone-wall"));
28 assert.equal(catalog.blocks["thick-smooth-stone-wall"], undefined);
29 29 assert.equal(catalog.blocks["thick-brick-wall"].states.length, 16);
30 30 assert.equal(catalog.blocks["thin-brick-wall"].states.length, 16);
31 31 assert.ok(catalog.images.some((image) => image.name === "block:thick-brick-wall:thick-brick-wall-we"));
@@ -23,9 +23,9 @@ test("sprite folders expose alphabetical states; first is default", () =>
23 assert.equal(catalog.blocks["thin-stone-wall"].defaultState, "thin-stone-wall");
23 assert.equal(catalog.blocks["thin-stone-wall"].defaultState, "thin-stone-wall");
24 assert.equal(catalog.blocks["thin-stone-wall"].states.length, 16);
24 assert.equal(catalog.blocks["thin-stone-wall"].states.length, 16);
25 assert.ok(catalog.images.some((image) => image.name === "block:thin-stone-wall:thin-stone-wall-wne"));
25 assert.ok(catalog.images.some((image) => image.name === "block:thin-stone-wall:thin-stone-wall-wne"));
26 assert.equal(catalog.blocks["thick-smooth-stone-wall"].states.length, 16);
27 assert.equal(catalog.blocks["thin-smooth-stone-wall"].states.length, 16);
26 assert.equal(catalog.blocks["thin-smooth-stone-wall"].states.length, 16);
28 assert.ok(catalog.images.some((image) => image.name === "block:thick-smooth-stone-wall:thick-smooth-stone-wall"));
27 assert.ok(catalog.images.some((image) => image.name === "block:thin-smooth-stone-wall:thin-smooth-stone-wall"));
28 assert.equal(catalog.blocks["thick-smooth-stone-wall"], undefined);
29 assert.equal(catalog.blocks["thick-brick-wall"].states.length, 16);
29 assert.equal(catalog.blocks["thick-brick-wall"].states.length, 16);
30 assert.equal(catalog.blocks["thin-brick-wall"].states.length, 16);
30 assert.equal(catalog.blocks["thin-brick-wall"].states.length, 16);
31 assert.ok(catalog.images.some((image) => image.name === "block:thick-brick-wall:thick-brick-wall-we"));
31 assert.ok(catalog.images.some((image) => image.name === "block:thick-brick-wall:thick-brick-wall-we"));
shared/definitions/tiles.js +8 −16
@@ -79,7 +79,7 @@ export const BlockType = Object.freeze({
79 79 silkCocoon: 36,
80 80 fence: 37,
81 81 stoneWallThin: 38,
82 smoothStoneWall: 39,
82 /** Former thick smooth stone wall (39) removed — id left unused. */
83 83 smoothStoneWallThin: 40,
84 84 brickWall: 41,
85 85 brickWallThin: 42,
@@ -205,19 +205,6 @@ export const BLOCK_DEFINITIONS = Object.freeze({
205 205 neighborConnect: true,
206 206 neighborConnectNamed: true
207 207 }),
208 [BlockType.smoothStoneWall]: Object.freeze({
209 id: BlockType.smoothStoneWall,
210 key: "thick-smooth-stone-wall",
211 displayName: "Thick smooth stone wall",
212 passable: false,
213 lightRangeTiles: 0,
214 frames: 1,
215 framesPerRow: 1,
216 animationSpeed: 0,
217 outdoor: false,
218 neighborConnect: true,
219 neighborConnectNamed: true
220 }),
221 208 [BlockType.smoothStoneWallThin]: Object.freeze({
222 209 id: BlockType.smoothStoneWallThin,
223 210 key: "thin-smooth-stone-wall",
@@ -299,8 +286,9 @@ export const BLOCK_DEFINITIONS = Object.freeze({
299 286 neighborConnect: true,
300 287 neighborConnectNamed: true,
301 288 /**
302 * Magenta top faces are replaced at draw time by sampling the chunk
303 * 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.
304 292 */
305 293 cliffGroundTop: true
306 294 }),
@@ -316,6 +304,7 @@ export const BLOCK_DEFINITIONS = Object.freeze({
316 304 outdoor: true,
317 305 neighborConnect: true,
318 306 neighborConnectNamed: true,
307 /** @see {@link BlockType.cliff} `cliffGroundTop` */
319 308 cliffGroundTop: true
320 309 }),
321 310 [BlockType.torch]: Object.freeze({
@@ -847,6 +836,9 @@ export function isChunkAtlasBakedBlock (block)
847 836 { return false; }
848 837 if (def.perTileBlock)
849 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; }
850 842 if (resourceNodeDisplayName(entry))
851 843 { return false; }
852 844 if (isPickablePlantBlock(entry))
@@ -79,7 +79,7 @@ export const BlockType = Object.freeze({
79 silkCocoon: 36,
79 silkCocoon: 36,
80 fence: 37,
80 fence: 37,
81 stoneWallThin: 38,
81 stoneWallThin: 38,
82 smoothStoneWall: 39,
82 /** Former thick smooth stone wall (39) removed — id left unused. */
83 smoothStoneWallThin: 40,
83 smoothStoneWallThin: 40,
84 brickWall: 41,
84 brickWall: 41,
85 brickWallThin: 42,
85 brickWallThin: 42,
@@ -205,19 +205,6 @@ export const BLOCK_DEFINITIONS = Object.freeze({
205 neighborConnect: true,
205 neighborConnect: true,
206 neighborConnectNamed: true
206 neighborConnectNamed: true
207 }),
207 }),
208 [BlockType.smoothStoneWall]: Object.freeze({
209 id: BlockType.smoothStoneWall,
210 key: "thick-smooth-stone-wall",
211 displayName: "Thick smooth stone wall",
212 passable: false,
213 lightRangeTiles: 0,
214 frames: 1,
215 framesPerRow: 1,
216 animationSpeed: 0,
217 outdoor: false,
218 neighborConnect: true,
219 neighborConnectNamed: true
220 }),
221 [BlockType.smoothStoneWallThin]: Object.freeze({
208 [BlockType.smoothStoneWallThin]: Object.freeze({
222 id: BlockType.smoothStoneWallThin,
209 id: BlockType.smoothStoneWallThin,
223 key: "thin-smooth-stone-wall",
210 key: "thin-smooth-stone-wall",
@@ -299,8 +286,9 @@ export const BLOCK_DEFINITIONS = Object.freeze({
299 neighborConnect: true,
286 neighborConnect: true,
300 neighborConnectNamed: true,
287 neighborConnectNamed: true,
301 /**
288 /**
302 * 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
303 * 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.
304 */
292 */
305 cliffGroundTop: true
293 cliffGroundTop: true
306 }),
294 }),
@@ -316,6 +304,7 @@ export const BLOCK_DEFINITIONS = Object.freeze({
316 outdoor: true,
304 outdoor: true,
317 neighborConnect: true,
305 neighborConnect: true,
318 neighborConnectNamed: true,
306 neighborConnectNamed: true,
307 /** @see {@link BlockType.cliff} `cliffGroundTop` */
319 cliffGroundTop: true
308 cliffGroundTop: true
320 }),
309 }),
321 [BlockType.torch]: Object.freeze({
310 [BlockType.torch]: Object.freeze({
@@ -847,6 +836,9 @@ export function isChunkAtlasBakedBlock (block)
847 { return false; }
836 { return false; }
848 if (def.perTileBlock)
837 if (def.perTileBlock)
849 { 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; }
850 if (resourceNodeDisplayName(entry))
842 if (resourceNodeDisplayName(entry))
851 { return false; }
843 { return false; }
852 if (isPickablePlantBlock(entry))
844 if (isPickablePlantBlock(entry))