"""Holo-foil example textures for a friend (2026-10-13). Tessel (Claude Opus 5.5). Writes, beside this file: foil.png 512x512 RGBA, tileable: diagonal rainbow bands, mostly transparent, a few sparkles. Slide it with llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, face, 1, 1, 0, 1, 0.08) on a face over the art. foil_n.png 512x512 normal map: fine diagonal grooves + sparkle bumps, for a shiny/PBR face that glints with view. art.png 512x512 demo card art (a star on deep blue), with an alpha mask in the overlay sense not needed. Run with local/hear-venv python. """ import colorsys import os import numpy as np from PIL import Image, ImageDraw, ImageFilter, ImageFont HERE = os.path.dirname(os.path.abspath(__file__)) N = 512 rng = np.random.default_rng(7) v, u = np.mgrid[0:N, 0:N] / N # u across, v down; everything below is periodic in both with period 1 # --- foil: hue runs along the diagonal (period 1 in u+v, so it tiles); brightness has softer secondary bands d = (u + v) % 1.0 hue = d band = 0.5 + 0.5 * np.cos(2 * np.pi * (2 * (u + v))) # two bright bands per tile fine = 0.5 + 0.5 * np.cos(2 * np.pi * (14 * (u - v))) # faint cross-hatch so it reads as foil, not paint rgb = np.zeros((N, N, 3)) for i in range(N): for j in range(0, N): rgb[i, j] = colorsys.hsv_to_rgb(hue[i, j], 0.55, 1.0) alpha = 0.10 + 0.32 * band ** 2 + 0.06 * fine # sparkles: small soft dots, wrapped so they tile sp = np.zeros((N, N)) for _ in range(90): cy, cx = rng.integers(0, N, 2) r = rng.uniform(1.2, 3.0) dy = (np.arange(N)[:, None] - cy + N // 2) % N - N // 2 dx = (np.arange(N)[None, :] - cx + N // 2) % N - N // 2 sp = np.maximum(sp, np.exp(-(dx ** 2 + dy ** 2) / (2 * r * r))) rgb = rgb * (1 - sp[..., None]) + sp[..., None] # sparkles go white alpha = np.clip(alpha + 0.6 * sp, 0, 1) img = np.dstack([rgb, alpha]) Image.fromarray((img * 255).astype(np.uint8), "RGBA").save(os.path.join(HERE, "foil.png")) # --- normal map: height = fine diagonal grooves + sparkle bumps, then tangent-space normals (OpenGL, +Y up) h = 0.5 + 0.5 * np.sin(2 * np.pi * 48 * (u - v)) + 1.5 * sp gy, gx = np.gradient(h) strength = 2.0 nx, ny, nz = -gx * strength, gy * strength, np.ones_like(h) ln = np.sqrt(nx ** 2 + ny ** 2 + nz ** 2) nmap = np.dstack([nx / ln, ny / ln, nz / ln]) * 0.5 + 0.5 Image.fromarray((nmap * 255).astype(np.uint8), "RGB").save(os.path.join(HERE, "foil_n.png")) # --- demo art: deep blue gradient, a gold star, a title art = Image.new("RGB", (N, N)) px = np.zeros((N, N, 3)) px[..., 0] = 0.05 + 0.10 * v px[..., 1] = 0.08 + 0.12 * v px[..., 2] = 0.30 + 0.30 * (1 - v) art = Image.fromarray((px * 255).astype(np.uint8), "RGB") dr = ImageDraw.Draw(art) cx, cy, R, r = N / 2, N * 0.45, N * 0.30, N * 0.12 pts = [] for k in range(10): a = -np.pi / 2 + k * np.pi / 5 rr = R if k % 2 == 0 else r pts.append((cx + rr * np.cos(a), cy + rr * np.sin(a))) glow = Image.new("L", (N, N), 0) ImageDraw.Draw(glow).polygon(pts, fill=255) glow = glow.filter(ImageFilter.GaussianBlur(18)) art = Image.composite(Image.new("RGB", (N, N), (255, 210, 120)), art, glow.point(lambda x: x // 2)) dr = ImageDraw.Draw(art) dr.polygon(pts, fill=(250, 200, 80), outline=(255, 240, 190)) try: font = ImageFont.truetype("C:/Windows/Fonts/georgiab.ttf", 44) except OSError: font = ImageFont.load_default() t = "HOLO DEMO" w = dr.textlength(t, font=font) dr.text(((N - w) / 2, N * 0.82), t, font=font, fill=(240, 240, 255)) art.save(os.path.join(HERE, "art.png")) # preview: foil over art, three phases of the slide prev = Image.new("RGB", (N * 3, N)) for k, off in enumerate((0, N // 3, 2 * N // 3)): f = np.roll(np.asarray(Image.open(os.path.join(HERE, "foil.png"))), -off, axis=1) / 255.0 a = np.asarray(art) / 255.0 out = a * (1 - f[..., 3:]) + f[..., :3] * f[..., 3:] prev.paste(Image.fromarray((out * 255).astype(np.uint8)), (k * N, 0)) prev.save(os.path.join(HERE, "preview.png")) print("ok")