refactor: decouple sim from framework, remove voxel geometry

This commit is contained in:
asrael 2026-02-27 01:22:35 -06:00
parent c538641ec8
commit 5a565844dd
41 changed files with 477 additions and 2407 deletions

View file

@ -327,4 +327,58 @@
(g:destroy)
tex-id)))
(fn textures.rough-stone [seed base-color]
(let [g (build-graph seed
(fn [ctx]
(let [cell (voronoi-cell ctx 8)
edge (voronoi-edge ctx 8)
crack-threshold (const ctx 0.03)
is-crack (sub ctx crack-threshold edge)
crack-color (const ctx (- base-color 3))
roughness (noise-turbulence ctx 3 24 0.6)
detail (noise-value ctx 48)
combined (add ctx (mul ctx roughness (const ctx 0.5))
(add ctx (mul ctx cell (const ctx 0.3))
(mul ctx detail (const ctx 0.2))))
stone-quant (quantize ctx combined base-color 6)]
(select ctx is-crack crack-color stone-quant))))]
(let [tex-id (g:eval_texture 64 64)]
(g:destroy)
tex-id)))
(fn textures.packed-dirt [seed base-color]
(let [g (build-graph seed
(fn [ctx]
(let [base-noise (noise-fbm ctx 3 16 0.5)
detail (noise-value ctx 32)
combined (add ctx (mul ctx base-noise (const ctx 0.6))
(mul ctx detail (const ctx 0.4)))
dirt-quant (quantize ctx combined base-color 5)
pebble (voronoi-cell ctx 12)
pebble-edge (voronoi-edge ctx 12)
pebble-threshold (const ctx 0.08)
is-pebble (sub ctx pebble-threshold pebble-edge)
pebble-quant (quantize ctx pebble (- base-color 2) 4)]
(select ctx is-pebble pebble-quant dirt-quant))))]
(let [tex-id (g:eval_texture 64 64)]
(g:destroy)
tex-id)))
(fn textures.grass-top [seed base-color]
(let [g (build-graph seed
(fn [ctx]
(let [blade-x (mul ctx ctx.x (const ctx 32))
blade-y (mul ctx ctx.y (const ctx 4))
blades (noise-fbm-at ctx blade-x blade-y 3 6 0.5)
fine (noise-value ctx 64)
patch (noise-fbm ctx 2 6 0.4)
combined (add ctx (mul ctx blades (const ctx 0.4))
(add ctx (mul ctx fine (const ctx 0.3))
(mul ctx patch (const ctx 0.3))))
grass-quant (quantize ctx combined base-color 6)]
grass-quant)))]
(let [tex-id (g:eval_texture 64 64)]
(g:destroy)
tex-id)))
textures