BlueGit

timfa questward

Magenta highlights blend toward white; name gem cut recipes per stone.

G in magenta mask lightens tier tints like dual-channel whiteBlend; jewelering shows Cut Tourmaline etc. instead of generic Cut gem.

timfa Tim Falken · pushed by timfa

Authored 2026-08-31 · 2 months ago

Hash
0d515f6124739578ee9d7161b3939257e2d24424
Parent
ea6b4c09
5 files changed +32 −29
client/src/render/worldView.js +2 −4
@@ -156,8 +156,7 @@ const TINT_LIT_SPRITE_FRAG = [
156 156 " if (abs(color.r - color.b) * 255.0 <= 2.01 && color.g < color.r) {",
157 157 " float L = color.r;",
158 158 " float gBlend = color.r > 0.0 ? clamp(color.g / color.r, 0.0, 1.0) : 0.0;",
159 " float tintLuma = dot(u_tintColor, vec3(0.2126, 0.7152, 0.0722));",
160 " rgb = mix(u_tintColor, vec3(tintLuma), gBlend) * L;",
159 " rgb = mix(u_tintColor, vec3(1.0), gBlend) * L;",
161 160 " }",
162 161 " }",
163 162 " if (u_wade > 0.5 && fromBottom < 5.0) {",
@@ -282,8 +281,7 @@ const TIGHT_FIT_TINT_LIT_SPRITE_FRAG = [
282 281 " if (abs(color.r - color.b) * 255.0 <= 2.01 && color.g < color.r) {",
283 282 " float L = color.r;",
284 283 " float gBlend = color.r > 0.0 ? clamp(color.g / color.r, 0.0, 1.0) : 0.0;",
285 " float tintLuma = dot(u_tintColor, vec3(0.2126, 0.7152, 0.0722));",
286 " rgb = mix(u_tintColor, vec3(tintLuma), gBlend) * L;",
284 " rgb = mix(u_tintColor, vec3(1.0), gBlend) * L;",
287 285 " }",
288 286 " }",
289 287 " if (u_wade > 0.5 && fromBottom < 5.0) {",
@@ -156,8 +156,7 @@ const TINT_LIT_SPRITE_FRAG = [
156 " if (abs(color.r - color.b) * 255.0 <= 2.01 && color.g < color.r) {",
156 " if (abs(color.r - color.b) * 255.0 <= 2.01 && color.g < color.r) {",
157 " float L = color.r;",
157 " float L = color.r;",
158 " float gBlend = color.r > 0.0 ? clamp(color.g / color.r, 0.0, 1.0) : 0.0;",
158 " float gBlend = color.r > 0.0 ? clamp(color.g / color.r, 0.0, 1.0) : 0.0;",
159 " float tintLuma = dot(u_tintColor, vec3(0.2126, 0.7152, 0.0722));",
159 " rgb = mix(u_tintColor, vec3(1.0), gBlend) * L;",
160 " rgb = mix(u_tintColor, vec3(tintLuma), gBlend) * L;",
161 " }",
160 " }",
162 " }",
161 " }",
163 " if (u_wade > 0.5 && fromBottom < 5.0) {",
162 " if (u_wade > 0.5 && fromBottom < 5.0) {",
@@ -282,8 +281,7 @@ const TIGHT_FIT_TINT_LIT_SPRITE_FRAG = [
282 " if (abs(color.r - color.b) * 255.0 <= 2.01 && color.g < color.r) {",
281 " if (abs(color.r - color.b) * 255.0 <= 2.01 && color.g < color.r) {",
283 " float L = color.r;",
282 " float L = color.r;",
284 " float gBlend = color.r > 0.0 ? clamp(color.g / color.r, 0.0, 1.0) : 0.0;",
283 " float gBlend = color.r > 0.0 ? clamp(color.g / color.r, 0.0, 1.0) : 0.0;",
285 " float tintLuma = dot(u_tintColor, vec3(0.2126, 0.7152, 0.0722));",
284 " rgb = mix(u_tintColor, vec3(1.0), gBlend) * L;",
286 " rgb = mix(u_tintColor, vec3(tintLuma), gBlend) * L;",
287 " }",
285 " }",
288 " }",
286 " }",
289 " if (u_wade > 0.5 && fromBottom < 5.0) {",
287 " if (u_wade > 0.5 && fromBottom < 5.0) {",
server/tests/craftingStations.test.js +1 −0
@@ -134,6 +134,7 @@ test("jewelering cuts rough gems; staff recipes need cut gems", () =>
134 134 {
135 135 const cut = recipeDefinition("cut-tourmaline");
136 136 assert.ok(cut);
137 assert.equal(cut.craftGroupLabel, "Cut Tourmaline");
137 138 assert.equal(cut.stationId, CraftingStationId.jeweleringStation);
138 139 assert.equal(cut.skillId, SkillId.jewelering);
139 140 assert.equal(cut.minSkillLevel, tierSmeltSkillLevel(GemTier.tourmaline));
@@ -134,6 +134,7 @@ test("jewelering cuts rough gems; staff recipes need cut gems", () =>
134{
134{
135 const cut = recipeDefinition("cut-tourmaline");
135 const cut = recipeDefinition("cut-tourmaline");
136 assert.ok(cut);
136 assert.ok(cut);
137 assert.equal(cut.craftGroupLabel, "Cut Tourmaline");
137 assert.equal(cut.stationId, CraftingStationId.jeweleringStation);
138 assert.equal(cut.stationId, CraftingStationId.jeweleringStation);
138 assert.equal(cut.skillId, SkillId.jewelering);
139 assert.equal(cut.skillId, SkillId.jewelering);
139 assert.equal(cut.minSkillLevel, tierSmeltSkillLevel(GemTier.tourmaline));
140 assert.equal(cut.minSkillLevel, tierSmeltSkillLevel(GemTier.tourmaline));
server/tests/tint.test.js +9 −8
@@ -28,25 +28,26 @@ test("magenta tintable when R==B and G < R", () =>
28 28 assert.equal(isMagentaTintable(0.5, 0.5, 0.5), false);
29 29 });
30 30
31 test("magenta tint preserves lightness and desaturates with G", () =>
31 test("magenta tint preserves lightness and highlights blend toward white", () =>
32 32 {
33 const tint = { r: 0, g: 1, b: 0 };
33 const tint = { r: 0.2, g: 0.4, b: 0.8 };
34 34 const dark = magentaTintedRgb(50 / 255, 0, 50 / 255, tint);
35 35 const light = magentaTintedRgb(1, 0, 1, tint);
36 assert.ok(dark.g < light.g);
37 const desat = magentaTintedRgb(120 / 255, 50 / 255, 120 / 255, tint);
36 assert.ok(dark.b < light.b);
37 const highlight = magentaTintedRgb(120 / 255, 50 / 255, 120 / 255, tint);
38 38 const pure = magentaTintedRgb(120 / 255, 0, 120 / 255, tint);
39 assert.ok(desat.r > pure.r);
39 assert.ok(highlight.g > pure.g);
40 assert.ok(highlight.r > pure.r);
40 41 });
41 42
42 test("dark target tints stay dark even on high-G magenta highlights", () =>
43 test("magenta G channel adds shiny white on dark tier tints", () =>
43 44 {
44 45 const coal = { r: 23 / 255, g: 23 / 255, b: 24 / 255 };
45 46 const pure = magentaTintedRgb(1, 0, 1, coal);
46 47 const highlight = magentaTintedRgb(1, 179 / 255, 1, coal);
47 48 assert.ok(pure.r < 0.12);
48 assert.ok(highlight.r < 0.15, `highlight washed out: ${highlight.r}`);
49 assert.ok(Math.abs(highlight.r - pure.r) < 0.05);
49 assert.ok(highlight.r > pure.r, "high-G magenta should shine toward white");
50 assert.ok(highlight.g > pure.g);
50 51 });
51 52
52 53 test("resolveItemTint uses potion instance color and tier tints", () =>
@@ -28,25 +28,26 @@ test("magenta tintable when R==B and G < R", () =>
28 assert.equal(isMagentaTintable(0.5, 0.5, 0.5), false);
28 assert.equal(isMagentaTintable(0.5, 0.5, 0.5), false);
29});
29});
30
30
31test("magenta tint preserves lightness and desaturates with G", () =>
31test("magenta tint preserves lightness and highlights blend toward white", () =>
32{
32{
33 const tint = { r: 0, g: 1, b: 0 };
33 const tint = { r: 0.2, g: 0.4, b: 0.8 };
34 const dark = magentaTintedRgb(50 / 255, 0, 50 / 255, tint);
34 const dark = magentaTintedRgb(50 / 255, 0, 50 / 255, tint);
35 const light = magentaTintedRgb(1, 0, 1, tint);
35 const light = magentaTintedRgb(1, 0, 1, tint);
36 assert.ok(dark.g < light.g);
36 assert.ok(dark.b < light.b);
37 const desat = magentaTintedRgb(120 / 255, 50 / 255, 120 / 255, tint);
37 const highlight = magentaTintedRgb(120 / 255, 50 / 255, 120 / 255, tint);
38 const pure = magentaTintedRgb(120 / 255, 0, 120 / 255, tint);
38 const pure = magentaTintedRgb(120 / 255, 0, 120 / 255, tint);
39 assert.ok(desat.r > pure.r);
39 assert.ok(highlight.g > pure.g);
40 assert.ok(highlight.r > pure.r);
40});
41});
41
42
42test("dark target tints stay dark even on high-G magenta highlights", () =>
43test("magenta G channel adds shiny white on dark tier tints", () =>
43{
44{
44 const coal = { r: 23 / 255, g: 23 / 255, b: 24 / 255 };
45 const coal = { r: 23 / 255, g: 23 / 255, b: 24 / 255 };
45 const pure = magentaTintedRgb(1, 0, 1, coal);
46 const pure = magentaTintedRgb(1, 0, 1, coal);
46 const highlight = magentaTintedRgb(1, 179 / 255, 1, coal);
47 const highlight = magentaTintedRgb(1, 179 / 255, 1, coal);
47 assert.ok(pure.r < 0.12);
48 assert.ok(pure.r < 0.12);
48 assert.ok(highlight.r < 0.15, `highlight washed out: ${highlight.r}`);
49 assert.ok(highlight.r > pure.r, "high-G magenta should shine toward white");
49 assert.ok(Math.abs(highlight.r - pure.r) < 0.05);
50 assert.ok(highlight.g > pure.g);
50});
51});
51
52
52test("resolveItemTint uses potion instance color and tier tints", () =>
53test("resolveItemTint uses potion instance color and tier tints", () =>
shared/definitions/gemItems.js +15 −11
@@ -253,17 +253,21 @@ export const GEM_ITEM_DEFINITIONS = Object.freeze({
253 253 /** Jewelering: rough → cut (skill gate matches smithing ore → bar). */
254 254 export function gemCutRecipes ()
255 255 {
256 return GEM_TIER_ORDER.map((gemTier) => Object.freeze({
257 recipeId: `cut-${gemTier}`,
258 craftGroup: "cut-gem",
259 craftGroupLabel: "Cut gem",
260 stationId: CraftingStationId.jeweleringStation,
261 output: { itemId: cutGemItemId(gemTier), quantity: 1 },
262 inputs: [{ itemId: roughGemItemId(gemTier), quantity: 1 }],
263 minSkillLevel: tierSmeltSkillLevel(gemTier),
264 skillId: SkillId.jewelering,
265 xpMaterial: gemTier
266 }));
256 return GEM_TIER_ORDER.map((gemTier) =>
257 {
258 const gemName = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier;
259 return Object.freeze({
260 recipeId: `cut-${gemTier}`,
261 craftGroup: "cut-gem",
262 craftGroupLabel: `Cut ${gemName}`,
263 stationId: CraftingStationId.jeweleringStation,
264 output: { itemId: cutGemItemId(gemTier), quantity: 1 },
265 inputs: [{ itemId: roughGemItemId(gemTier), quantity: 1 }],
266 minSkillLevel: tierSmeltSkillLevel(gemTier),
267 skillId: SkillId.jewelering,
268 xpMaterial: gemTier
269 });
270 });
267 271 }
268 272
269 273 /** Craft recipes: 1 log + 1 cut gem + 1 ash → staff (matching wood/gem tier). */
@@ -253,17 +253,21 @@ export const GEM_ITEM_DEFINITIONS = Object.freeze({
253/** Jewelering: rough → cut (skill gate matches smithing ore → bar). */
253/** Jewelering: rough → cut (skill gate matches smithing ore → bar). */
254export function gemCutRecipes ()
254export function gemCutRecipes ()
255{
255{
256 return GEM_TIER_ORDER.map((gemTier) => Object.freeze({
256 return GEM_TIER_ORDER.map((gemTier) =>
257 recipeId: `cut-${gemTier}`,
257 {
258 craftGroup: "cut-gem",
258 const gemName = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier;
259 craftGroupLabel: "Cut gem",
259 return Object.freeze({
260 stationId: CraftingStationId.jeweleringStation,
260 recipeId: `cut-${gemTier}`,
261 output: { itemId: cutGemItemId(gemTier), quantity: 1 },
261 craftGroup: "cut-gem",
262 inputs: [{ itemId: roughGemItemId(gemTier), quantity: 1 }],
262 craftGroupLabel: `Cut ${gemName}`,
263 minSkillLevel: tierSmeltSkillLevel(gemTier),
263 stationId: CraftingStationId.jeweleringStation,
264 skillId: SkillId.jewelering,
264 output: { itemId: cutGemItemId(gemTier), quantity: 1 },
265 xpMaterial: gemTier
265 inputs: [{ itemId: roughGemItemId(gemTier), quantity: 1 }],
266 }));
266 minSkillLevel: tierSmeltSkillLevel(gemTier),
267 skillId: SkillId.jewelering,
268 xpMaterial: gemTier
269 });
270 });
267}
271}
268
272
269/** Craft recipes: 1 log + 1 cut gem + 1 ash → staff (matching wood/gem tier). */
273/** Craft recipes: 1 log + 1 cut gem + 1 ash → staff (matching wood/gem tier). */
shared/render/tint.js +5 −6
@@ -7,8 +7,8 @@ import { magicElementTint } from "../definitions/attackTypes.js";
7 7 * - Tintable when R ≈ B and G < R (magenta family).
8 8 * - |R − B| may be up to {@link MAGENTA_CHANNEL_TOLERANCE} (AA / export drift).
9 9 * - Lightness L = R (= B): (50,0,50) dark … (255,0,255) max light.
10 * - G > 0 (still G < R) desaturates toward the tint's own gray (not white),
11 * so dark target colours stay dark: mix(tint, vec3(luma(tint)), G/R) * L.
10 * - G > 0 (still G < R) lightens the assigned tint toward white for shiny highlights:
11 * mix(tint, vec3(1), G/R) * L.
12 12 * - Otherwise leave RGB as-is. World shaders apply darkness after this pass.
13 13 *
14 14 * Dual / triple channel ({@link applyDualChannelTintToImageData}):
@@ -342,11 +342,10 @@ export function magentaTintedRgb (r, g, b, tintRgb)
342 342 const L = r;
343 343 const gBlend = r > 0 ? Math.min(1, Math.max(0, g / r)) : 0;
344 344 const tint = normalizeRgb(tintRgb);
345 const tintLuma = luminance(tint.r, tint.g, tint.b);
346 345 return {
347 r: clamp01(mix(tint.r, tintLuma, gBlend) * L),
348 g: clamp01(mix(tint.g, tintLuma, gBlend) * L),
349 b: clamp01(mix(tint.b, tintLuma, gBlend) * L)
346 r: clamp01(mix(tint.r, 1, gBlend) * L),
347 g: clamp01(mix(tint.g, 1, gBlend) * L),
348 b: clamp01(mix(tint.b, 1, gBlend) * L)
350 349 };
351 350 }
352 351
@@ -7,8 +7,8 @@ import { magicElementTint } from "../definitions/attackTypes.js";
7 * - Tintable when R ≈ B and G < R (magenta family).
7 * - Tintable when R ≈ B and G < R (magenta family).
8 * - |R − B| may be up to {@link MAGENTA_CHANNEL_TOLERANCE} (AA / export drift).
8 * - |R − B| may be up to {@link MAGENTA_CHANNEL_TOLERANCE} (AA / export drift).
9 * - Lightness L = R (= B): (50,0,50) dark … (255,0,255) max light.
9 * - Lightness L = R (= B): (50,0,50) dark … (255,0,255) max light.
10 * - G > 0 (still G < R) desaturates toward the tint's own gray (not white),
10 * - G > 0 (still G < R) lightens the assigned tint toward white for shiny highlights:
11 * so dark target colours stay dark: mix(tint, vec3(luma(tint)), G/R) * L.
11 * mix(tint, vec3(1), G/R) * L.
12 * - Otherwise leave RGB as-is. World shaders apply darkness after this pass.
12 * - Otherwise leave RGB as-is. World shaders apply darkness after this pass.
13 *
13 *
14 * Dual / triple channel ({@link applyDualChannelTintToImageData}):
14 * Dual / triple channel ({@link applyDualChannelTintToImageData}):
@@ -342,11 +342,10 @@ export function magentaTintedRgb (r, g, b, tintRgb)
342 const L = r;
342 const L = r;
343 const gBlend = r > 0 ? Math.min(1, Math.max(0, g / r)) : 0;
343 const gBlend = r > 0 ? Math.min(1, Math.max(0, g / r)) : 0;
344 const tint = normalizeRgb(tintRgb);
344 const tint = normalizeRgb(tintRgb);
345 const tintLuma = luminance(tint.r, tint.g, tint.b);
346 return {
345 return {
347 r: clamp01(mix(tint.r, tintLuma, gBlend) * L),
346 r: clamp01(mix(tint.r, 1, gBlend) * L),
348 g: clamp01(mix(tint.g, tintLuma, gBlend) * L),
347 g: clamp01(mix(tint.g, 1, gBlend) * L),
349 b: clamp01(mix(tint.b, tintLuma, gBlend) * L)
348 b: clamp01(mix(tint.b, 1, gBlend) * L)
350 };
349 };
351}
350}
352
351