Beautliful voxel engine like enshrouded
Find a file
Samuel Bouchet 6b41da0932 Phase 6.2: RT shadows — inline ray queries with BLAS/TLAS fix
Add shadow compute shader (voxelShadowCS.hlsl) that traces rays toward
the sun using DXR inline ray queries (RayQuery<>, SM 6.5). Shadows
modulate voxelRT_ in-place via RWTexture2D (no extra render target).

Key fixes to Phase 6.1 BLAS/TLAS infrastructure:
- Sequential index buffer required: Wicked treats IndexCount=0 with
  non-null IndexBuffer as "0 indexed triangles" → empty BLAS
- Memory barriers between BLAS→TLAS→RT: without GPUBarrier::Memory()
  the TLAS build races with BLAS builds, causing zero ray hits
- inverseViewProjection added to VoxelCB for depth reconstruction

F5 toggles shadows OFF→ON→DEBUG (red=hit, green=miss, blue=backface).
2026-03-28 20:01:18 +01:00
shaders Phase 6.2: RT shadows — inline ray queries with BLAS/TLAS fix 2026-03-28 20:01:18 +01:00
src Phase 6.2: RT shadows — inline ray queries with BLAS/TLAS fix 2026-03-28 20:01:18 +01:00
.gitignore Phase 2: GPU-driven voxel rendering pipeline 2026-03-25 14:24:05 +01:00
blending_experiments.md Phase 3: PS-based texture blending with winner-takes-all heightmap 2026-03-26 12:14:08 +01:00
CLAUDE.md Phase 6.2: RT shadows — inline ray queries with BLAS/TLAS fix 2026-03-28 20:01:18 +01:00
CMakeLists.txt Phase 6.2: RT shadows — inline ray queries with BLAS/TLAS fix 2026-03-28 20:01:18 +01:00
plan_phase4.md Phase 4.1: TopingSystem infrastructure + procedural mesh generation 2026-03-26 15:27:15 +01:00
README.md Phase 5.2-5.3: CPU perf optimizations + GPU compute Surface Nets 2026-03-27 22:30:43 +01:00
research_connected_meshes.md Phase 4.1: TopingSystem infrastructure + procedural mesh generation 2026-03-26 15:27:15 +01:00
voxel_engine_spec.docx Phase 2: GPU-driven voxel rendering pipeline 2026-03-25 14:24:05 +01:00
voxel_engine_spec.md Phase 5.2-5.3: CPU perf optimizations + GPU compute Surface Nets 2026-03-27 22:30:43 +01:00

BVLE Voxels

Prototype de moteur voxel hybride basé sur Wicked Engine (MIT, C++17, DX12/Vulkan).

Cible : 60+ fps en 1440p, monde de 512×512×256 voxels visibles.

Prérequis

Outil Version Installation
Windows 10/11 (x64)
CMake 3.19+ winget install Kitware.CMake
Visual Studio 2022 Build Tools 17.x winget install Microsoft.VisualStudio.2022.BuildTools
Windows SDK 10.0.26100+ winget install Microsoft.WindowsSDK.10.0.26100
GPU DX12 feature level 12.0+ AMD RDNA 2+ / Nvidia RTX 3060+ recommandé

Le SDK 10.0.26100 est requis car les headers DX12 fournis par Wicked Engine ne sont pas compatibles avec le SDK 22621.

Installation

# 1. Cloner le dépôt
git clone <url> bvle-voxels
cd bvle-voxels

# 2. Cloner Wicked Engine dans engine/
git clone --depth 1 https://github.com/turanszkij/WickedEngine.git engine

# 3. Configurer CMake
cmake -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.26100.0

# 4. Compiler
cmake --build build --config Release --target BVLEVoxels --parallel

# 5. Lancer
./build/Release/BVLEVoxels.exe

Commandes de lancement

Commande Description
BVLEVoxels.exe Mode normal (monde procédural, rayon 4 chunks)
BVLEVoxels.exe debug Mode debug face-color (+X=Rouge, -X=Rouge sombre, etc.)
BVLEVoxels.exe debugdevice Active la couche de debug D3D12
BVLEVoxels.exe vulkan Force le backend Vulkan

Contrôles

Touche Action
WASD Déplacement caméra
Espace / Ctrl Monter / Descendre
Shift Vitesse ×3
Clic droit Capturer/libérer la souris
~ (tilde) Console Wicked Engine

Architecture

bvle-voxels/
├── CMakeLists.txt              # Build CMake
├── engine/                     # Wicked Engine (git clone --depth 1)
├── src/
│   ├── voxel/                  # Bibliothèque VoxelEngine (static lib)
│   │   ├── VoxelTypes.h        # Types (VoxelData, PackedQuad, ChunkPos)
│   │   ├── VoxelWorld.h/.cpp   # Monde voxel (hashmap, génération Perlin)
│   │   ├── VoxelMesher.h/.cpp  # Binary Greedy Mesher CPU
│   │   └── VoxelRenderer.h/.cpp# Renderer GPU-driven + VoxelRenderPath
│   └── app/
│       └── main.cpp            # Point d'entrée Win32
├── shaders/                    # Sources HLSL
│   ├── voxelCommon.hlsli       # Root signature, CB, structs partagés
│   ├── voxelVS.hlsl            # Vertex shader (vertex pulling)
│   ├── voxelPS.hlsl            # Pixel shader (triplanar + lighting)
│   ├── voxelCullCS.hlsl        # Compute: frustum + backface culling
│   └── voxelMeshCS.hlsl        # Compute: GPU mesher (binary, baseline)
└── voxel_engine_spec.md        # Document de spécification complet (Markdown)

Pipeline de rendu (Phase 2 — GPU-driven)

CPU: mesh dirty chunks (greedy merge) → pack quads + chunkInfo dans mega-buffers → upload GPU
GPU: frustum cull compute → indirect args → DrawInstancedIndirectCount (1 appel = N draws)

Buffers GPU :

Buffer Type Slot Rôle
megaQuadBuffer_ StructuredBuffer<PackedQuad> SRV t0 2M quads max (16 MB)
chunkInfoBuffer_ StructuredBuffer<GPUChunkInfo> SRV t2 2048 chunks max
indirectArgsBuffer_ RWStructuredBuffer UAV u0 Indirect draw args
drawCountBuffer_ RWByteAddressBuffer UAV u1 Compteur atomique de draws

Caractéristiques Phase 2 :

  • Mega-buffer unique pour tous les quads de tous les chunks
  • Vertex pulling via SV_VertexID + push constants (b999)
  • Frustum culling CPU (wi::primitive::Frustum)
  • Backface culling par face group (6 directions × chunk)
  • GPU frustum cull compute shader (prêt, activation via flag)
  • GPU mesher compute shader baseline (binary, sans greedy merge)
  • Tri des quads par direction de face dans le mesher CPU
  • GPU timestamp queries pour benchmark

Phases de développement

  • Phase 1 — Setup, meshing CPU, rendu basique
  • Phase 2 — GPU-driven pipeline, mega-buffer, culling, compute shaders
  • Phase 3 — Texture blending (triplanar, height-based)
  • Phase 4 — Toping (rebords, bordures procédurales)
  • Phase 5 — Rendu smooth (Surface Nets / Marching Cubes)
  • Phase 6 — Ray tracing hybride (RT shadows + AO)

Licence

Wicked Engine est sous licence MIT. Le code spécifique BVLE est propriétaire.