Rust voxel sandbox (wgpu + wasm + axum multiplayer)
shader.wgsl restructured:
- Section headers: Camera → Sky horizon → Atmosphere extras → Terrain
lighting decomposition → Pipelines.
- sky_dome() is now the single source of truth for the horizon→zenith
mix; sky_color() builds on it instead of duplicating the gradient.
- fs_main decomposed into named helpers:
ambient_term(n, sun, day) hemisphere ambient via sky_dome lookup
direct_sun_term(n, sun) Lambert × visibility ramp
leaf_jitter(world_pos) per-pixel canopy variation
fog_factor(dist) 0..1 fog ramp
apply_fog(lit, dist, view) defers sky_color call until needed
- Camera.misc renamed to Camera.frame with named accessors
scene_time() / eye_world() so callsites read intent.
- DAY_PERIOD / SUN_OFFSET REMOVED from the shader — injected at the
top by shader_source::wgsl_constants_header(). One source of truth
in sim::lighting now drives both Rust and WGSL; mob burn and
visible sun direction can never disagree.
New src/shader_source.rs:
- wgsl_constants_header() Rust → WGSL constants prelude
- terrain_shader_source() header + shader.wgsl, used at Renderer::new
- post_shader_source() pass-through
state.rs CameraUniform:
- misc → frame to match the renamed WGSL field
- Renderer uses the assembled shader source instead of include_str! directly
Tests: 53 passing (added 2 shader_source assembly tests). Native build,
wasm release build, server build all green.
|
||
|---|---|---|
| server | ||
| src | ||
| web | ||
| .dockerignore | ||
| .gitignore | ||
| build-web.sh | ||
| Caddyfile | ||
| Cargo.lock | ||
| Cargo.toml | ||
| DEPLOY.md | ||
| docker-compose.prod.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| run.sh | ||