feat: red and white tablecloth on the Cook's Table
The cook goes back to the cartography table with its map painted over offline (scripts/paint_cook_cloth.py from textures pulled by scripts/extract_carto.py). The three PNGs are embedded in the DLL and swapped onto copied materials by PieceLook.Retexture. The smith stays on the black marble table.
This commit is contained in:
parent
b3edb2aed1
commit
069e098cf0
8 changed files with 238 additions and 22 deletions
55
scripts/paint_cook_cloth.py
Normal file
55
scripts/paint_cook_cloth.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"""Paint a red and white gingham tablecloth over the cartography table's map.
|
||||
Usage: py -3.14 -I paint_cloth.py <pylib> <carto dir> <out dir>"""
|
||||
import os, sys
|
||||
sys.path.insert(0, sys.argv[1])
|
||||
from PIL import Image, ImageFilter
|
||||
|
||||
src, out = sys.argv[2], sys.argv[3]
|
||||
os.makedirs(out, exist_ok=True)
|
||||
|
||||
# The parchment's UV island spans x 10-133, y 11-90 (read off the mesh). A margin either side,
|
||||
# stopping short of the next island (the red disc starts at y 96, the stone at x 150).
|
||||
X0, Y0, X1, Y1 = 4, 4, 141, 95
|
||||
SQUARE = 6 # pixels; the island is ~45 px per metre, so about 13 cm squares
|
||||
|
||||
WHITE = (236, 231, 219)
|
||||
MID = (204, 92, 86)
|
||||
DARK = (158, 28, 32)
|
||||
|
||||
|
||||
def gingham(x, y):
|
||||
a = ((x - X0) // SQUARE) % 2 == 0
|
||||
b = ((y - Y0) // SQUARE) % 2 == 0
|
||||
return DARK if a and b else MID if a or b else WHITE
|
||||
|
||||
|
||||
def paint(name, fade=0.0, dirt=1.0):
|
||||
img = Image.open(os.path.join(src, name + ".png")).convert("RGBA")
|
||||
# Keep the parchment's broad light and shadow (the folds, the dark rolled edges) but not
|
||||
# its ink: a heavy blur of its brightness, around 1.0.
|
||||
lum = img.convert("L").filter(ImageFilter.GaussianBlur(5))
|
||||
region = [lum.getpixel((x, y)) for y in range(Y0, Y1) for x in range(X0, X1)]
|
||||
mean = sum(region) / len(region)
|
||||
px = img.load()
|
||||
for y in range(Y0, Y1):
|
||||
for x in range(X0, X1):
|
||||
shade = max(0.7, min(1.15, lum.getpixel((x, y)) / mean)) * dirt
|
||||
r, g, b = gingham(x, y)
|
||||
o = px[x, y]
|
||||
c = [int(min(255, v * shade)) for v in (r, g, b)]
|
||||
c = [int(cv * (1 - fade) + ov * fade) for cv, ov in zip(c, o[:3])]
|
||||
px[x, y] = (c[0], c[1], c[2], o[3])
|
||||
img.save(os.path.join(out, name.replace("Cartographer", "CookCloth") + ".png"))
|
||||
|
||||
|
||||
def smooth_normal(name):
|
||||
img = Image.open(os.path.join(src, name + ".png")).convert("RGBA")
|
||||
box = (X0, Y0, X1, Y1)
|
||||
img.paste(img.crop(box).filter(ImageFilter.GaussianBlur(4)), box)
|
||||
img.save(os.path.join(out, name.replace("Cartographer", "CookCloth") + ".png"))
|
||||
|
||||
|
||||
paint("Cartographer_d")
|
||||
paint("Cartographer_worn_d", fade=0.3, dirt=0.85) # the damaged table: a stained, faded cloth
|
||||
smooth_normal("Cartographer_n")
|
||||
print("done")
|
||||
Loading…
Add table
Add a link
Reference in a new issue