VIVIA โ Rendering Pipeline
GPU Pipeline (wgpu)โ
The renderer uses wgpu 0.20 with custom WGSL shaders for all rendering:
Render Passesโ
- Terrain โ instanced chunk geometry, per-fragment lighting
- Sky โ procedural gradient with sun/moon, ACES tonemapping
- Animals/Mobs โ instanced voxel bodies with walk animation
- GLB Models โ loaded AI-mesh models with procedural skinning
- Weather โ rain/snow particles (disabled for performance)
- UI โ HUD, inventory, crafting, text overlays
Lighting Modelโ
- Sun โ directional NยทL with day/night cycle
- Moon โ soft ambient at night
- Specular โ Bln-Phong for wet skin, shells, ice, metal
- Emission โ glow for eyes, crystals, lava
- Fog โ distance-based, sky-colored, matches terrain/mobs
- Tonemapping โ ACES (Narkowicz approximation) in linear space
Geometryโ
Procedural 3D primitives generated by pure math:
- Sphere โ UV sphere with configurable rings/stacks
- Cylinder โ lathed with end caps
- Capsule โ cylinder + hemisphere ends
- Cone โ lathed with base cap
- Box โ unit cube
All shapes have smooth per-vertex normals for organic creature bodies.
GLB Model Pipelineโ
- Load raw GLB (tripo/meshy AI exports)
- Weld duplicate vertices
- Decimate to ~6K triangles (meshopt, 2% threshold)
- Bake triplanar UVs from positions + normals
- Generate procedural skin texture per creature type
- Cache to
~/.local/share/nv2/mesh_cache(keyed by GLB hash) - Upload vertex + index buffers to GPU
Shadersโ
| Shader | Purpose |
|---|---|
shader.wgsl | Main terrain + block rendering |
sky.wgsl | Procedural sky, sun/moon, aurora |
weather.wgsl | Rain/snow particles |
animals.wgsl | Voxel creature rendering + walk animation |
model.wgsl | GLB model rendering + procedural gait |
text.wgsl | Text/glyph rendering |
ui.wgsl | HUD elements |
ui_sprite.wgsl | Sprite rendering |
Performanceโ
- Instanced rendering โ one draw call per shape per chunk
- 2048 cube instances max (creatures)
- 256 AI mesh instances max (GLB models)
- Bilinear texture upscale + high-frequency grain for close-up detail
- Deterministic mesh cache โ instant restart (0.3s from cache)