Shader graph: Clamp is the Output's default edge, and the sheet's own mode is a constant of its own (#81)
game-maker / suite (push) Successful in 9m16s

The default of the Edge param and the address mode the shared sheet physically
carries were the same constant; changing the value would have turned every
sentinel with it and given each shader sprite a full copy of its texture.
SHEET_EDGE ('mirror', what TextureLibrary uploads) is now separate from
DEFAULT_EDGE ('clamp'). A graph whose Sample reads nothing but its own pixel
draws with the plain sheet whatever the Edge says, so the common shader costs
no second copy.

Without a shader the quad's coordinates never leave 0..1, and mirror-repeat
reads like clamp within a texel - so clamp is what a sprite shows anyway.
This commit is contained in:
admin committed 2026-09-13 21:33:41 +02:00
1 parent 03c4323794
commit e0c459ce92
7 files changed
+74 -20

No files matched your search

+4 -4
View File
@@ -1,6 +1,6 @@
import { Assets, CanvasSource, Texture } from 'pixi.js';
import type { FrameRect, TextureRef } from '../core/model/texture';
import { DEFAULT_EDGE, type EdgeMode } from '../core/shader/nodes';
import { type EdgeMode, SHEET_EDGE } from '../core/shader/nodes';
const DEFAULT_BASE = '/game-maker/data/textures';
@@ -47,10 +47,10 @@ export class TextureLibrary {
* shared source, so two assets naming the same file with different `smooth` fight over it and
* the last one drawn wins; upload avoids that by reusing the existing asset for a known file.
*/
get(ref: TextureRef, edge: EdgeMode = DEFAULT_EDGE): Texture | null {
get(ref: TextureRef, edge: EdgeMode = SHEET_EDGE): Texture | null {
const sheet = this.load(ref.file);
if (!sheet) return null;
const rect = ref.rect ?? (edge === DEFAULT_EDGE ? null : wholeOf(sheet));
const rect = ref.rect ?? (edge === SHEET_EDGE ? null : wholeOf(sheet));
const texture = rect ? this.crop(ref.file, sheet, rect, edge) : sheet;
if (!texture) return null;
const mode = ref.smooth ? 'linear' : 'nearest';
@@ -96,7 +96,7 @@ export class TextureLibrary {
*/
private crop(file: string, sheet: Texture, rect: FrameRect, edge: EdgeMode): Texture | null {
if (rect.w <= 0 || rect.h <= 0) return null;
const key = edge === DEFAULT_EDGE ? cropKey(file, rect) : `${cropKey(file, rect)}|${edge}`;
const key = edge === SHEET_EDGE ? cropKey(file, rect) : `${cropKey(file, rect)}|${edge}`;
let texture = this.crops.get(key);
if (!texture) {
const canvas = new OffscreenCanvas(rect.w, rect.h);