Skip to content

OpenStaticFish/ZigCraft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

508 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

 /$$$$$$$$ /$$$$$$  /$$$$$$   /$$$$$$  /$$$$$$$   /$$$$$$  /$$$$$$$$ /$$$$$$$$
|_____ $$ |_  $$_/ /$$__  $$ /$$__  $$| $$__  $$ /$$__  $$| $$_____/|__  $$__/
     /$$/   | $$  | $$  \__/| $$  \__/| $$  \ $$| $$  \ $$| $$         | $$   
    /$$/    | $$  | $$ /$$$$| $$      | $$$$$$$/| $$$$$$$$| $$$$$      | $$   
   /$$/     | $$  | $$|_  $$| $$      | $$__  $$| $$__  $$| $$__/      | $$   
  /$$/      | $$  | $$  \ $$| $$    $$| $$  \ $$| $$  | $$| $$         | $$   
 /$$$$$$$$ /$$$$$$|  $$$$$$/|  $$$$$$/| $$  | $$| $$  | $$| $$         | $$   
|________/|______/ \______/  \______/ |__/  |__/|__/  |__/|__/         |__/   
ZigCraft Hero

โšก ZigCraft โšก

Zig License Build Status Tests

A high-performance Minecraft-style voxel engine built with Zig, SDL3, and a modern Vulkan graphics pipeline.


๐Ÿ’ป System Requirements

Component Minimum Recommended
OS Linux (NixOS), Windows (WSL2) Linux (NixOS)
GPU Vulkan 1.2, 4GB VRAM Vulkan 1.3, 8GB+ VRAM
RAM 8 GB 16 GB
Storage 2 GB 4 GB SSD
Build Tools Nix package manager Nix (latest)

Note: All builds require Nix for reproducible dependency management (SDL3, Vulkan, glslang).


๐Ÿš€ Overview

ZigCraft is a technical exploration of high-performance voxel rendering techniques. It features a custom-built graphics abstraction layer, advanced terrain generation, and a multithreaded job system to handle massive world streaming with zero hitching.

โœจ Key Features

๐ŸŽจ Rendering Architecture

  • Vulkan RHI: Modern, explicit graphics API with persistent UBO mapping for high performance.
  • PBR Rendering: Physically Based Rendering with Cook-Torrance BRDF for realistic materials.
  • Cascaded Shadow Maps (CSM): 3 cascades with configurable PCF sampling (4-16 samples).
  • Atmospheric Scattering: Physically-based day/night cycle with dynamic fog and sky rendering.
  • Advanced Graphics Menu: Real-time control over shadow quality, PBR, resolution scaling, and MSAA.
  • Floating Origin & Reverse-Z: Industry-standard techniques to eliminate precision jitter and Z-fighting at scale.
  • Greedy Meshing: Optimized chunk generation reducing draw call overhead and triangle counts.

๐ŸŒ World Generation

  • Biomes & Climate: Multi-noise system based on temperature and humidity (11+ biomes).
  • Infinite Terrain: Seed-based, deterministic generation with domain warping and 3D caves.
  • Volumetric Clouds: Procedural, shadowed cloud layers that integrate with the atmosphere.
  • Level of Detail (LOD): Hierarchical LOD system enabling 100+ chunk render distances using simplified terrain meshes and specialized rendering.
  • Greedy Meshing: Optimized vertex data generation for maximum throughput.

๐Ÿ› ๏ธ Engine Core

  • Multithreaded Pipeline: Dedicated worker pools for generation (4 threads) and meshing (3 threads).
  • Job Prioritization: Proximity-based task scheduling ensures immediate loading of local chunks.
  • Comprehensive Testing: 58+ unit tests covering math, worldgen, and core engine modules.
  • Refined App Lifecycle: Modular architecture with extracted systems for rendering, input, and world management.

๐Ÿ“Š Performance Benchmarks

Render Distance FPS (ReleaseFast) GPU Used
32 chunks 120+ RTX 3060
64 chunks 90+ RTX 3060
128 chunks 60+ RTX 3060

Benchmarks measured on RTX 3060 @ 1080p with HIGH quality preset

๐Ÿ–ผ๏ธ Screenshots

PBR Materials Cascaded Shadows Biomes
PBR Shadows Biomes

More screenshots coming soon!

โŒจ๏ธ Controls

Key Action
WASD Movement
Space / Shift Jump / Crouch (Fly Up / Down)
Left Ctrl Sprint
Mouse Look
Left Click / Right Click Mine Block / Place Block
Tab Toggle Mouse Capture / Menu
I Open Inventory
1-9 Select Hotbar Slot
F / T Toggle Wireframe / Textures
V Toggle VSync
U / K Toggle Shadow Debug / Cycle Cascades
M Toggle World Map
N Freeze / Unfreeze Time
F2 Toggle FPS Counter
F3 Toggle Creative Mode
F5 Toggle Block Info
Esc Menu / Pause

Note: Time of day can be set via the inventory screen (buttons for DAWN, NOON, DUSK, NIGHT) |

๐Ÿ—๏ธ Build & Run

This project uses Nix for a reproducible development environment.

๐Ÿ› ๏ธ Development Setup

After cloning or creating a new worktree, run the setup script to enable git hooks:

./scripts/setup-hooks.sh

This configures a pre-push hook that runs:

  • zig fmt --check src/ - formatting check
  • zig build test - full test suite

To bypass in emergencies: git push --no-verify

๐ŸŽฎ Running the Game

  • Run: nix develop --command zig build run
  • Release build: nix develop --command zig build run -Doptimize=ReleaseFast

๐Ÿงช Running Tests

  • All Tests: nix develop --command zig build test
  • Single Test: nix develop --command zig build test -- --test-filter "Test Name"

๐Ÿ“‚ Project Structure

  • src/engine/: Core engine components (RHI, Math, UI, Input, Jobs).
  • src/world/: Voxel-specific logic (Greedy Meshing, World Manager, Chunks).
  • src/world/worldgen/: Procedural terrain, noise, and biome systems.
  • assets/: GLSL shaders and textures.
  • scripts/: Helper scripts for asset processing.
  • libs/: (Planned) Extracted standalone math and noise libraries.

๐Ÿ› ๏ธ Texture Pipeline

The engine supports HD texture packs with full PBR maps. To standardize high-resolution source imagery (4k JPEGs, EXRs) into engine-ready 512px PNGs, use the provided helper script:

# Standardize an entire pack
./scripts/process_textures.sh assets/textures/pbr-test 512

The script automatically handles resizing and naming conventions for _diff, _nor_gl, _rough, and _disp maps.

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for the full development workflow.

Quick Start for Contributors

# Clone and setup
git clone https://github.com/OpenStaticFish/ZigCraft.git
cd ZigCraft
./scripts/setup-hooks.sh

# Enter dev environment and run tests
nix develop --command zig build test

Branch Workflow

main (production)
  โ””โ”€ dev (staging)
      โ”œโ”€ feature/*    # New features
      โ”œโ”€ bug/*        # Non-critical fixes
      โ”œโ”€ hotfix/*     # Critical fixes
      โ””โ”€ ci/*         # CI/workflow changes

All PRs target the dev branch. Use our PR templates (feature.md, bug.md, hotfix.md, ci.md) for best practices.

๐Ÿ”ง Troubleshooting

Nix Build Failures

# Clean build artifacts
rm -rf zig-out/ .zig-cache/

# Update Nix channels (if using older Nix)
nix-channel --update

Vulkan Driver Issues

  • Linux: Ensure vulkan-loader and GPU drivers are installed
  • NVIDIA: Proprietary drivers recommended for best performance
  • Verify: Run vulkaninfo to check Vulkan support

Shader Validation Errors

Shaders are validated during zig build test. If glslang fails:

# Install glslang via Nix
nix develop  # glslang is included in the dev shell

Performance Issues

  • Try zig build run -Doptimize=ReleaseFast for optimized builds
  • Reduce render distance in-game: Press Esc โ†’ Graphics โ†’ Render Distance
  • Disable VSync if FPS is capped at 60

๐ŸŒŸ Community

Discussions GitHub Discussions
Issues GitHub Issues
License MIT License

โฌ† Back to Top

Built with โค๏ธ by the OpenStaticFish community

โš–๏ธ License

MIT License - see LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors