Skip to main content

VIVIA โ€” Rendering Pipeline

GPU Pipeline (wgpu)โ€‹

The renderer uses wgpu 0.20 with custom WGSL shaders for all rendering. Every pass below maps to a shader that exists in Core/Src/renderer/.

Render Passesโ€‹

  1. Terrain โ€” instanced chunk geometry with per-fragment lighting and distance fog (shader.wgsl)
  2. Sky โ€” procedural sky with sun/moon and day/night cycle (sky.wgsl)
  3. Animals โ€” instanced voxel bodies with procedural walk animation (animals.wgsl)
  4. Weather โ€” rain/snow particles (weather.wgsl)
  5. UI โ€” HUD, inventory, crafting, text overlays (ui.wgsl, ui_sprite.wgsl)
  6. Text โ€” glyph rendering (text.wgsl)

Lighting Modelโ€‹

  • Sun โ€” directional NยทL with day/night cycle
  • Moon โ€” soft ambient at night
  • Fog โ€” distance-based in the terrain shader (16 references in shader.wgsl), sky-colored
  • Per-fragment lighting โ€” Blinn-Phong-style NยทL + specular for blocks and creatures

Geometryโ€‹

Procedural 3D primitives generated by pure math (no model files needed):

  • 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 carry smooth per-vertex normals for organic creature bodies.

Texture Pipelineโ€‹

  • texture_registry.rs conventions: blockname.png (all faces), blockname_side.png (side override), _top/_bottom variants
  • Dynamic atlas (dynamic_atlas.rs) โ€” MeMLP-generated procedural textures are uploaded into the atlas at runtime
  • Bilinear upscale + grain for close-up detail
  • AI texture styles selected by the MeMLP TEXTURE_ARCH head (8โ†’12โ†’6)

Shaders (as shipped)โ€‹

ShaderPurpose
shader.wgslMain terrain + block rendering, fog
sky.wgslProcedural sky, sun/moon
weather.wgslRain/snow particles
animals.wgslVoxel creature rendering + walk animation
text.wgslText/glyph rendering
ui.wgslHUD elements
ui_sprite.wgslSprite rendering

Performanceโ€‹

  • Instanced rendering โ€” one draw call per shape per chunk
  • World mesh cache โ€” invalidation on block changes (invalidate_world_mesh_cache)
  • No per-frame allocations on the hot path
  • Low-end PC mode โ€” low_end_pc setting reduces render radius via performance profiles
  • Configurable load_radius / render_radius / cleanup_radius

Planned (not in this build)โ€‹

GLB model loading, mesh decimation and skeletal skinning for AI-generated creature models โ€” designed, not implemented. Today's creatures are animated voxel compositions.