Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date. Images, audio, models and binaries go through Git LFS (.gitattributes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
56
ArtSource/Textures/finalize.py
Normal file
56
ArtSource/Textures/finalize.py
Normal file
@ -0,0 +1,56 @@
|
||||
"""Copy raw gpt-image textures into Assets/Art/Textures at 1024, making tiling ones seamless."""
|
||||
import sys, os
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
DST = os.path.normpath(os.path.join(HERE, "..", "..", "Assets", "Art", "Textures"))
|
||||
TILING = {"T_Cardboard", "T_Floor", "T_WallPanel", "T_Roof", "T_Wood", "T_Metal", "T_Belt", "T_WrapRoll"}
|
||||
NO_X = {"T_WallPanel", "T_Roof"} # vertical ribs: horizontal blend would ghost ribs; ribs usually tile in X anyway
|
||||
|
||||
|
||||
def seamless(a, band=0.12, do_x=True, do_y=True):
|
||||
a = a.astype(np.float32)
|
||||
h, w = a.shape[:2]
|
||||
|
||||
def ramp(n):
|
||||
t = np.ones(n, np.float32)
|
||||
b = int(n * band)
|
||||
x = np.arange(b, dtype=np.float32) / b
|
||||
s = x * x * (3 - 2 * x)
|
||||
t[:b] = s
|
||||
t[n - b:] = s[::-1]
|
||||
return t
|
||||
if do_y:
|
||||
off = np.roll(a, h // 2, axis=0)
|
||||
m = ramp(h)[:, None, None]
|
||||
a = a * m + off * (1 - m)
|
||||
if do_x:
|
||||
off = np.roll(a, w // 2, axis=1)
|
||||
m = ramp(w)[None, :, None]
|
||||
a = a * m + off * (1 - m)
|
||||
return np.clip(a, 0, 255).astype(np.uint8)
|
||||
|
||||
|
||||
def main(names):
|
||||
os.makedirs(DST, exist_ok=True)
|
||||
for n in names:
|
||||
src = os.path.join(HERE, f"raw_{n}.png")
|
||||
if not os.path.exists(src):
|
||||
print("missing", n); continue
|
||||
im = Image.open(src).convert("RGB")
|
||||
if n == "T_Sign":
|
||||
im = im.resize((2048, 1024), Image.LANCZOS) if im.size[0] > 2048 else im
|
||||
elif im.size != (1024, 1024):
|
||||
im = im.resize((1024, 1024), Image.LANCZOS)
|
||||
if n in TILING:
|
||||
im = Image.fromarray(seamless(np.array(im), do_x=n not in NO_X))
|
||||
im.save(os.path.join(DST, f"{n}.png"))
|
||||
print("ok", n, im.size)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = sys.argv[1:]
|
||||
if not args:
|
||||
args = [f[4:-4] for f in os.listdir(HERE) if f.startswith("raw_") and f.endswith(".png")]
|
||||
main(args)
|
||||
Reference in New Issue
Block a user