Rust voxel sandbox (wgpu + wasm + axum multiplayer)
sim/lighting.rs:
- New compute_ambience(world, pos, normal) -> VertexAmbience
returns BOTH sky_vis AND bounce_color from the same 8-ray
hemisphere cast. No double walks of the voxel grid.
- walks_until_solid(world, origin, dir) -> Option<Vec3> is the
primitive: None = escaped to sky, Some(color) = first solid hit.
Used by compute_ambience to accumulate the bounce_color average.
- sky_visibility is now a thin wrapper around compute_ambience for
tests and clarity.
world.rs:
- Block::average_color() returns the mean across all 6 faces — the
contribution this block makes to a neighbor's bounce when hit by
a hemisphere ray.
- Block::material_id() returns 0 (matte) for most blocks, 1
(specular) for Ice + Snow. Reserved 2 for future emissive blocks.
mesh.rs:
- Vertex grows `bounce_mat: [f32; 4]` packing baked bounce color
(rgb) + material id (a). Float32x4 attribute at @location(6).
- build_chunk_mesh now calls compute_ambience for each quad corner
(same one-pass ray-cast that produced sky_vis already, plus the
bounce accumulation). Material id taken from cell.block.
shader.wgsl:
- VsIn / VsOut grow bounce_mat (vec4).
- ambient_term now takes the per-vertex bounce_albedo instead of a
hard-coded gray-brown. A red brick wall thus casts a faint red
bounce on dirt next to it — real GI hint, baked once at mesh
time, zero cost at runtime per fragment.
- material_for(id) lookup: Phong specular for ice/snow (m.specular
= 0.45 with cos⁴⁸ half-vector); emission slot reserved.
- fs_main pipeline now includes the specular + emission terms.
- Camera.frame keeps Round C accessor names; ambient_strength
untouched.
Tests: 63 passing. Native + wasm release clean.
Deferred from this round (own sessions): #18 water (new pipeline +
animation), #19 transparent/cutout (new blend state), #8 wider AO
(current 4-corner is sufficient for now; the wider-occlusion effect
is now coming through bounce_color anyway).
Visual change: bounce-tinted ambient (red walls glow red onto
neighbors); ice + snow get specular highlight in direct sun.
|
||
|---|---|---|
| server | ||
| src | ||
| web | ||
| .dockerignore | ||
| .gitignore | ||
| ARCHITECTURE.md | ||
| build-web.sh | ||
| Caddyfile | ||
| Cargo.lock | ||
| Cargo.toml | ||
| DEPLOY.md | ||
| docker-compose.prod.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| run.sh | ||