diff --git a/README.md b/README.md index e3e0b1d..70626ad 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,9 @@ raylib 6.2 is fetched automatically by CMake (FetchContent). Needs a C++23 compi - `docs/ROADMAP.md` — milestones M0–M6 and current status - `docs/concept/` — rendered Blender concept frames (visual target for M5) - `docs/ENV_ENHANCEMENT.md` — enhancement slices S0–S15 for the environment/actors -- `ConcreteMaterial.blend` + `tools/blender/bake_cgtrader_concrete.py` — CGTrader - concrete source material and the reproducible 2K bake used by floor/walls/pillars +- `ConcreteMaterial.blend` + `tools/blender/bake_cgtrader_concrete.py` and + `process_concrete_maps.py` — CGTrader concrete source and the reproducible 2K + bake/post-process used by floor/walls/pillars - `tools/blender/` — procedural diorama + actor builders (`actor_kit.py` loft/sweep/blob/crystal helpers) and render scripts - `assets/models/` — game-ready GLB actors (guard, 3 enemies, cyan resonance point crystal) and `props/` OoP set dressing - `assets/textures/concrete/` — shared seamless albedo/normal/roughness maps diff --git a/assets/blender/fbc_night_shift_diorama.blend b/assets/blender/fbc_night_shift_diorama.blend index ed41843..5b8952e 100644 Binary files a/assets/blender/fbc_night_shift_diorama.blend and b/assets/blender/fbc_night_shift_diorama.blend differ diff --git a/assets/textures/concrete/concrete_albedo.png b/assets/textures/concrete/concrete_albedo.png index 5bfe7f3..fe97ea6 100644 Binary files a/assets/textures/concrete/concrete_albedo.png and b/assets/textures/concrete/concrete_albedo.png differ diff --git a/assets/textures/concrete/concrete_normal.png b/assets/textures/concrete/concrete_normal.png index 6499e6f..2835092 100644 Binary files a/assets/textures/concrete/concrete_normal.png and b/assets/textures/concrete/concrete_normal.png differ diff --git a/assets/textures/concrete/concrete_roughness.png b/assets/textures/concrete/concrete_roughness.png index c7b2ffe..c51ac40 100644 Binary files a/assets/textures/concrete/concrete_roughness.png and b/assets/textures/concrete/concrete_roughness.png differ diff --git a/docs/ART_DIRECTION.md b/docs/ART_DIRECTION.md index ea37eab..c985b7e 100644 --- a/docs/ART_DIRECTION.md +++ b/docs/ART_DIRECTION.md @@ -27,7 +27,8 @@ units are little free-standing puppets rather than printed cards: - Concrete `#2b2b2f`, paper `#e8e4d8`, redaction `#111111` - One tileable concrete PBR set (albedo/normal/roughness, baked in Blender from - the CGTrader "Concrete material" by KirillP and tinted to graphite) is reused + the CGTrader "Concrete material" by KirillP, kept light grey with the crack + network baked into the albedo) is reused on every concrete surface — floor, curbs, pillars, door frame — via world-space triplanar mapping, so texel density is identical everywhere. The source `.blend` and its bake script live in the repo root / `tools/blender/` diff --git a/docs/ENV_ENHANCEMENT.md b/docs/ENV_ENHANCEMENT.md index 451d880..bc37942 100644 --- a/docs/ENV_ENHANCEMENT.md +++ b/docs/ENV_ENHANCEMENT.md @@ -397,11 +397,15 @@ clipping < 0.5%, red-dominant 15–25%. `tools/blender/bake_cgtrader_concrete.py` torus-maps the source's 4D Noise/Musgrave/Voronoi to a seamless tile, bakes albedo + height, derives a seamless normal from the two bump signals, and remaps roughness before writing - 3 x 2K PNGs to `assets/textures/concrete/`. Albedo is tinted to the graphite - palette (mean 0.17, matching the old set) so the material's crack network and - fine aggregate read without breaking the look. Game load verified with a - temporary magenta albedo test; diorama scene rebuilt and concept frames - re-rendered. Old generator in `build_materials.py` remains as a fallback. + 3 x 2K PNGs to `assets/textures/concrete/`. Follow-up (same day): albedo lifted + to 80% of the source value (mean 0.51, light grey) at the user's request; the + high-frequency speckle is blurred to stop aliasing/shimmer, the Voronoi crack + network is darkened into the albedo so the pattern reads at camera distance, + and the derived normal is softened with a broader roughness range for a slick, + non-sparkly floor. Game load verified with a temporary magenta albedo test; + diorama scene rebuilt and concept frames re-rendered. Old generator in + `build_materials.py` remains as a fallback. The bake needs two interpreters: + Blender for the Cycles maps, system Python + PIL for `process_concrete_maps.py`. - 2026-11-23 (shard redesign): enemy point crystals are now small Control-style Resonance crystals — a slim faceted cyan bipyramid (`#00c4eb`) with a hot `#40dfff` core and three dark splinters, 60 tris down from the 154-tri yellow diff --git a/docs/concept/detail_guard_standees.png b/docs/concept/detail_guard_standees.png index b772395..f1acf4a 100644 Binary files a/docs/concept/detail_guard_standees.png and b/docs/concept/detail_guard_standees.png differ diff --git a/docs/concept/hero_game_camera.png b/docs/concept/hero_game_camera.png index 1853511..1e4df67 100644 Binary files a/docs/concept/hero_game_camera.png and b/docs/concept/hero_game_camera.png differ diff --git a/docs/concept/hero_oldest_house.png b/docs/concept/hero_oldest_house.png index ccce35f..0b250cf 100644 Binary files a/docs/concept/hero_oldest_house.png and b/docs/concept/hero_oldest_house.png differ diff --git a/tools/blender/bake_cgtrader_concrete.py b/tools/blender/bake_cgtrader_concrete.py index ad00660..30ae711 100644 --- a/tools/blender/bake_cgtrader_concrete.py +++ b/tools/blender/bake_cgtrader_concrete.py @@ -1,10 +1,9 @@ import math import os +import subprocess import sys import bpy -import numpy as np -from PIL import Image REPO = "/home/dandovlatov/Documents/cntrl" SRC = os.path.join(REPO, "ConcreteMaterial.blend") @@ -96,55 +95,17 @@ def bake(name, bake_type): img.file_format = "PNG" img.save() bake_node.select = False - return Image.open(img.filepath_raw).convert("RGB") -albedo = bake("albedo", "DIFFUSE") +bake("albedo", "DIFFUSE") bake("normal", "NORMAL") -rough = bake("roughness", "ROUGHNESS") +bake("roughness", "ROUGHNESS") cracks = next(n for n in nodes if n.name == "ColorRamp.002") bw2 = nodes.new("ShaderNodeRGBToBW") links.new(cracks.outputs["Color"], bw2.inputs["Color"]) rng2 = nodes.new("ShaderNodeMapRange") links.new(bw2.outputs[0], rng2.inputs["Value"]) links.new(rng2.outputs["Result"], bsdf.inputs["Roughness"]) -voronoi = bake("height_voronoi", "ROUGHNESS") - - -def arr(img): - return np.asarray(img, np.float32) / 255.0 - - -def upscale(a): - h, w = a.shape[:2] - out = np.zeros((h * 2, w * 2, 3), np.float32) - for c in range(3): - out[:, :, c] = np.asarray( - Image.fromarray((a[:, :, c] * 255).astype(np.uint8)).resize( - (w * 2, h * 2), Image.Resampling.LANCZOS), np.float32) / 255.0 - return out - - -def save(name, a): - Image.fromarray((np.clip(a, 0.0, 1.0) * 255.0 + 0.5).astype(np.uint8)).save( - os.path.join(TEX, name + ".png")) - print("[concrete] saved", name, flush=True) - - -albedo = upscale(arr(albedo)) * np.array([0.265, 0.265, 0.30], np.float32) -rough = upscale(arr(rough)) -r = rough[:, :, 0] -rough[:, :, 0] = rough[:, :, 1] = rough[:, :, 2] = ( - (r - r.min()) / max(r.max() - r.min(), 1e-5) * 0.38 + 0.30) -voronoi = upscale(arr(voronoi))[:, :, 0] -h = 0.37 * (rough[:, :, 0] - rough[:, :, 0].mean()) + 0.89 * (voronoi - voronoi.mean()) -gx = (np.roll(h, -1, 1) - np.roll(h, 1, 1)) * 0.5 -gy = (np.roll(h, -1, 0) - np.roll(h, 1, 0)) * 0.5 -nx, ny, nz = -gx * 12.0, gy * 12.0, np.ones_like(h) -inv = 1.0 / np.sqrt(nx * nx + ny * ny + nz * nz) -normal = np.stack((nx * inv, ny * inv, nz * inv), 2) * 0.5 + 0.5 - -save("concrete_albedo", albedo) -save("concrete_roughness", rough) -save("concrete_normal", normal) -print("[concrete] done — 3 x 2048px seamless maps from CGTrader ConcreteMaterial.blend") +bake("height_voronoi", "ROUGHNESS") +subprocess.run(["python3", os.path.join(REPO, "tools", "blender", + "process_concrete_maps.py")], check=True) diff --git a/tools/blender/process_concrete_maps.py b/tools/blender/process_concrete_maps.py new file mode 100644 index 0000000..4b65e82 --- /dev/null +++ b/tools/blender/process_concrete_maps.py @@ -0,0 +1,60 @@ +import os + +import numpy as np +from PIL import Image, ImageFilter + +REPO = "/home/dandovlatov/Documents/cntrl" +SRC = "/tmp/opencode" +DST = os.path.join(REPO, "assets", "textures", "concrete") + + +def load(name): + return np.asarray(Image.open(os.path.join(SRC, name + ".png")).convert("RGB"), + np.float32) / 255.0 + + +def save(name, rgb): + Image.fromarray((np.clip(rgb, 0.0, 1.0) * 255.0 + 0.5).astype(np.uint8)).save( + os.path.join(DST, name + ".png")) + im = np.asarray(Image.open(os.path.join(DST, name + ".png")), np.float32) / 255.0 + print("[concrete] %-22s mean %.3f seamX %.4f" % + (name + ".png", im.mean(), np.abs(im[:, 0] - im[:, -1]).mean()), flush=True) + + +def upscale(rgb): + h, w = rgb.shape[:2] + out = np.zeros((h * 2, w * 2, 3), np.float32) + for c in range(3): + out[:, :, c] = np.asarray( + Image.fromarray((rgb[:, :, c] * 255).astype(np.uint8)).resize( + (w * 2, h * 2), Image.Resampling.LANCZOS), np.float32) / 255.0 + return out + + +def blur(a, radius): + return np.asarray( + Image.fromarray((np.clip(a, 0.0, 1.0) * 255.0).astype(np.uint8)).filter( + ImageFilter.GaussianBlur(radius)), np.float32) / 255.0 + + +albedo = upscale(load("albedo")) * np.array([0.80, 0.80, 0.86], np.float32) +albedo = blur(albedo, 1.6) +rough = upscale(load("roughness")) +r = rough[:, :, 0] +rough[:, :, 0] = rough[:, :, 1] = rough[:, :, 2] = ( + (r - r.min()) / max(r.max() - r.min(), 1e-5) * 0.27 + 0.45) +voronoi = upscale(load("height_voronoi"))[:, :, 0] +crack = blur(np.clip((0.92 - voronoi) / 0.5, 0.0, 1.0), 1.0) +albedo *= (1.0 - 0.18 * crack)[:, :, None] +height = (0.37 * (blur(rough[:, :, 0], 1.0) - rough[:, :, 0].mean()) + + 0.89 * (blur(voronoi, 1.0) - voronoi.mean())) +gx = (np.roll(height, -1, 1) - np.roll(height, 1, 1)) * 0.5 +gy = (np.roll(height, -1, 0) - np.roll(height, 1, 0)) * 0.5 +nx, ny, nz = -gx * 8.0, gy * 8.0, np.ones_like(height) +inv = 1.0 / np.sqrt(nx * nx + ny * ny + nz * nz) +normal = np.stack((nx * inv, ny * inv, nz * inv), 2) * 0.5 + 0.5 + +save("concrete_albedo", albedo) +save("concrete_roughness", rough) +save("concrete_normal", normal) +print("[concrete] 3 x 2048px seamless maps written")