Add the shattered ice effect and five-step tunings for mythic variations
« Glace brisée » joins the holographic effects: a seamless shard mosaic in four facet groups that each light up near their own tilt, with glinting cracks; in the standard layout it covers the frame and text and stays under the artwork. Its masks come from scripts/generate-shattered-ice-textures.mjs. Each mythic variation now tunes its palette intensity and, when the effect declares one, its own level (prism speed, parallax amplitude, shard size), from 1 to 5 with 3 as the reference render. Tunings are stored on mythic_variations, set with range sliders when a variation is created or later in the mythic editor, logged in the history and previewed in the Visual Lab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
efdb5c558c
commit
808adadc0c
23 changed files with 463 additions and 31 deletions
78
scripts/generate-shattered-ice-textures.mjs
Normal file
78
scripts/generate-shattered-ice-textures.mjs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
// Rôle : génère les masques de l'effet holographique « Glace brisée » : une mosaïque d'éclats raccordable sur ses bords,
|
||||
// répartie en quatre groupes de facettes (un masque par groupe), plus le masque des fissures qui les séparent.
|
||||
// Usage : node scripts/generate-shattered-ice-textures.mjs
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import sharp from "sharp";
|
||||
|
||||
const SIZE = 512;
|
||||
const GRID = 7; // 7 x 7 germes décalés : environ 49 éclats de tailles voisines par tuile.
|
||||
const GROUPS = 4;
|
||||
const OUT = "website/public/static/img/cards/effects";
|
||||
|
||||
// Générateur pseudo-aléatoire déterministe : la même commande redonne exactement les mêmes textures.
|
||||
let seed = 20261121;
|
||||
const random = () => {
|
||||
seed = (seed * 1664525 + 1013904223) >>> 0;
|
||||
return seed / 2 ** 32;
|
||||
};
|
||||
|
||||
const cells = [];
|
||||
for (let row = 0; row < GRID; row++) {
|
||||
for (let column = 0; column < GRID; column++) {
|
||||
const angle = random() * Math.PI * 2;
|
||||
cells.push({
|
||||
x: ((column + 0.15 + random() * 0.7) / GRID) * SIZE,
|
||||
y: ((row + 0.15 + random() * 0.7) / GRID) * SIZE,
|
||||
group: Math.floor(random() * GROUPS),
|
||||
// Chaque éclat reçoit un dégradé interne propre : il paraît incliné, comme un vrai fragment de glace.
|
||||
shadeX: Math.cos(angle),
|
||||
shadeY: Math.sin(angle),
|
||||
shadeMin: 0.45 + random() * 0.3
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Distance sur un tore : la tuile se raccorde à elle-même dans les deux directions.
|
||||
const wrapped = (delta) => {
|
||||
const value = Math.abs(delta) % SIZE;
|
||||
return Math.min(value, SIZE - value);
|
||||
};
|
||||
|
||||
const facets = Array.from({ length: GROUPS }, () => Buffer.alloc(SIZE * SIZE * 2));
|
||||
const cracks = Buffer.alloc(SIZE * SIZE * 2);
|
||||
for (let y = 0; y < SIZE; y++) {
|
||||
for (let x = 0; x < SIZE; x++) {
|
||||
let first = Infinity;
|
||||
let second = Infinity;
|
||||
let owner = null;
|
||||
for (const cell of cells) {
|
||||
const distance = Math.hypot(wrapped(x - cell.x), wrapped(y - cell.y));
|
||||
if (distance < first) {
|
||||
second = first;
|
||||
first = distance;
|
||||
owner = cell;
|
||||
} else if (distance < second) {
|
||||
second = distance;
|
||||
}
|
||||
}
|
||||
// Près de la médiatrice entre deux germes, l'écart entre les deux distances s'annule : c'est la fissure.
|
||||
const crack = Math.max(0, Math.min(1, 1 - (second - first - 1.2) / 1.6));
|
||||
const offset = (y * SIZE + x) * 2;
|
||||
cracks[offset] = 255;
|
||||
cracks[offset + 1] = Math.round(crack * 255);
|
||||
const dx = (x - owner.x) / (SIZE / GRID);
|
||||
const dy = (y - owner.y) / (SIZE / GRID);
|
||||
const shade = owner.shadeMin + (1 - owner.shadeMin) * Math.max(0, Math.min(1, 0.5 + (dx * owner.shadeX + dy * owner.shadeY)));
|
||||
const facet = facets[owner.group];
|
||||
facet[offset] = 255;
|
||||
facet[offset + 1] = Math.round((1 - crack) * shade * 255);
|
||||
}
|
||||
}
|
||||
|
||||
await mkdir(OUT, { recursive: true });
|
||||
const write = (buffer, name) => sharp(buffer, { raw: { width: SIZE, height: SIZE, channels: 2 } }).webp({ lossless: true }).toFile(`${OUT}/${name}`);
|
||||
await Promise.all([
|
||||
...facets.map((buffer, index) => write(buffer, `shattered-ice-facet-${index}.webp`)),
|
||||
write(cracks, "shattered-ice-cracks.webp")
|
||||
]);
|
||||
console.log(`${GROUPS} masques de facettes et un masque de fissures écrits dans ${OUT}.`);
|
||||
Loading…
Add table
Add a link
Reference in a new issue