ThreeKingdomsSlingshot/Tools/make_glow_disk_texture.py

66 lines
2.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 빛 번짐 원판 그림(자체 제작) — 2026-11-13 PD 「원판 그림을 만들어서 보여줘」(방통 봉추의 계 · HCFX_Beam_03 터짐 뒤의 큰 흰 원판 = 원본 미리보기 영상의 빛 번짐)
# 가운데 흰색 → 옅은 연두 → 연두 빛이 가장자리로 부드럽게 사라지는 원 · 256×256 RGBA · 출력 Assets/VFX/TKS2D/sk_glow_disk.png
# 미리보기(어두운 바탕 · 모래 바탕) = 인자 2 가 있으면 그 경로에 저장
# 실행: python -I -X utf8 Tools/make_glow_disk_texture.py [미리보기.png]
import math, os, sys
from PIL import Image
N = 256
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')
OUT = os.path.join(ROOT, 'Assets', 'VFX', 'TKS2D', 'sk_glow_disk.png')
# 반지름(0 = 가운데 · 1 = 그림 가장자리)별 색 · 불투명도
COLOR_STOPS = [(0.0, (255, 255, 255)), (0.38, (255, 255, 250)), (0.55, (238, 255, 190)), (0.75, (190, 236, 80)), (1.0, (150, 214, 58))]
DISK_EDGE = 0.52 # 흰 원판 가장자리(여기까지 거의 불투명)
DISK_SOFT = 0.10 # 원판 가장자리 번짐 폭
GLOW_ALPHA = 0.55 # 원판 바깥 빛의 시작 불투명도
GLOW_FALL = 3.2 # 빛이 사라지는 빠르기(클수록 빨리)
def lerp(a, b, t):
return a + (b - a) * t
def color_at(r):
for (r0, c0), (r1, c1) in zip(COLOR_STOPS, COLOR_STOPS[1:]):
if r <= r1:
t = (r - r0) / (r1 - r0) if r1 > r0 else 0.0
return tuple(int(round(lerp(a, b, t))) for a, b in zip(c0, c1))
return COLOR_STOPS[-1][1]
def smoothstep(e0, e1, x):
t = min(1.0, max(0.0, (x - e0) / (e1 - e0)))
return t * t * (3 - 2 * t)
def alpha_at(r):
disk = 1.0 - smoothstep(DISK_EDGE - DISK_SOFT, DISK_EDGE + DISK_SOFT, r)
glow = GLOW_ALPHA * math.exp(-GLOW_FALL * max(0.0, r - DISK_EDGE + DISK_SOFT)) * (1.0 - smoothstep(0.85, 1.0, r))
return max(disk, glow)
img = Image.new('RGBA', (N, N))
px = img.load()
c = (N - 1) / 2.0
for y in range(N):
for x in range(N):
r = math.hypot(x - c, y - c) / c
if r >= 1.0:
px[x, y] = (0, 0, 0, 0)
continue
col = color_at(r)
px[x, y] = (col[0], col[1], col[2], int(round(255 * alpha_at(r))))
os.makedirs(os.path.dirname(OUT), exist_ok=True)
img.save(OUT)
print('saved', OUT)
if len(sys.argv) > 1:
prev = Image.new('RGB', (N * 2 + 30, N + 20), (30, 30, 30))
for i, bg in enumerate([(40, 34, 48), (232, 178, 92)]): # 어두운 바탕 · 모래 바탕
tile = Image.new('RGBA', (N, N), bg + (255,))
tile.alpha_composite(img)
prev.paste(tile.convert('RGB'), (10 + i * (N + 10), 10))
prev.save(sys.argv[1])
print('preview', sys.argv[1])