# tuntenfisch/voxels architecture

> Architecture diagram of the GitHub repository tuntenfisch/voxels, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tuntenfisch/voxels
- Repository: https://github.com/tuntenfisch/voxels

## Overview

##### Project type and purpose
- This is an open-source Unity project implementing GPU-based Dual Contouring for infinite, destructible voxel terrain with seamless LOD and multi-material support. It’s neither a web service nor a traditional full-stack app but a real-time 3D engine extension/tool.

##### File structure
Top-level folders:
- Assets/Compute – HLSL include files and Compute Shader kernels
- Assets/Scripts – C# orchestrators, data objects, GPU wrapper classes, chunk & world management
- Assets/Shaders & ShaderGraphs – custom URP PBR surface shader (with geometry stage) and node-based shader graphs
- Assets/Materials, Textures – ScriptableObjects and Texture2DArray input for materials
- Assets/Prefabs, Scenes – ready-to-drop chunk prefab & sample scene
- Assets/ScriptableObjects – configuration assets for voxel volume, DC settings, materials
- Packages & ProjectSettings – Unity package manifest and editor settings

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% GPU/HLSL Components
    subgraph "GPU/HLSL Components"
        HLSLGlobal["HLSL Includes (Global)"]:::gpu
        HLSLVox["HLSL Includes (Voxels)"]:::gpu
        ComputeDual["DualContouring.compute"]:::gpu
        ComputeVol["VoxelVolume.compute"]:::gpu
    end

    %% C# GPU Invocation Layer
    subgraph "C# GPU Invocation Layer"
        CSExt["ComputeShaderExtensions.cs"]:::cs
        AsyncBuf["AsyncComputeBuffer.cs"]:::cs
        BakeJob["BakeJob.cs"]:::cs
        IRequest["IRequest.cs"]:::cs
    end

    %% Dual Contouring Module
    subgraph "Dual Contouring Module"
        DCmain["DualContouring.cs"]:::cs
        DCconfig["DualContouringConfig.cs"]:::cs
        GPUVertex["GPUVertex.cs"]:::cs
        OnMeshGen["OnMeshGenerated.cs"]:::cs
    end

    %% Voxel Volume & CSG Module
    subgraph "Voxel Volume & CSG Module"
        VVol["VoxelVolume.cs"]:::cs
        VVolConfig["VoxelVolumeConfig.cs"]:::cs
        GPUVoxelCSG["GPUVoxelVolumeCSGOperation.cs"]:::cs
        GPUCSG["GPUCSGOperator.cs"]:::cs
        CSGUtil["CSGUtility.cs"]:::cs
    end

    %% Chunk & World Management
    ChunkCS["Chunk.cs"]:::cs
    WorldMgr["WorldManager.cs"]:::cs

    %% Data Configurations
    subgraph "Data Configurations"
        DCAsset["Dual Contouring Config.asset"]:::data
        GenGraph["Generation Graph.asset"]:::data
        MatConfig["Material Config.asset"]:::data
        VVAsset["Voxel Volume Config.asset"]:::data
    end

    %% Rendering Pipeline
    subgraph "Rendering Pipeline"
        URPAsset["UniversalRenderPipelineAsset.asset"]:::render
        VShader["Voxel.shader"]:::render
        HoloGraph["Hologram.shadergraph"]:::render
    end

    %% Scene & Prefab layer
    subgraph "Scene & Prefab layer"
        Prefab["Chunk.prefab"]:::data
        Scene["Main.unity"]:::data
    end

    %% Connections
    HLSLGlobal --> ComputeDual
    HLSLGlobal --> ComputeVol
    HLSLVox --> ComputeDual
    HLSLVox --> ComputeVol

    ComputeDual --> CSExt
    ComputeVol --> CSExt

    CSExt --> DCmain
    AsyncBuf --> DCmain
    BakeJob --> DCmain
    IRequest --> DCmain

    CSExt --> VVol
    AsyncBuf --> VVol
    BakeJob --> VVol
    IRequest --> VVol

    DCmain --> ChunkCS
    GPUVertex --> ChunkCS
    OnMeshGen --> ChunkCS

    VVol --> ChunkCS
    GPUVoxelCSG --> ChunkCS
    GPUCSG --> ChunkCS
    CSGUtil --> ChunkCS

    ChunkCS --> WorldMgr
    WorldMgr --> Prefab
    Prefab --> Scene

    Scene --> URPAsset
    URPAsset --> VShader
    URPAsset --> HoloGraph

    DCAsset --> ComputeDual
    VVAsset --> ComputeVol
    DCAsset --> DCmain
    VVAsset --> VVol
    MatConfig --> VShader
    MatConfig --> HoloGraph

    %% Click Events
    click HLSLGlobal "https://github.com/tuntenfisch/voxels/tree/release/Assets/Compute/Include"
    click HLSLVox "https://github.com/tuntenfisch/voxels/tree/release/Assets/Compute/Voxels/Include"
    click ComputeDual "https://github.com/tuntenfisch/voxels/blob/release/Assets/Compute/Voxels/DualContouring.compute"
    click ComputeVol "https://github.com/tuntenfisch/voxels/blob/release/Assets/Compute/Voxels/VoxelVolume.compute"
    click CSExt "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Extensions/ComputeShaderExtensions.cs"
    click AsyncBuf "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Generics/AsyncComputeBuffer.cs"
    click BakeJob "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Generics/BakeJob.cs"
    click IRequest "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Generics/IRequest.cs"
    click DCmain "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Voxels/DC/DualContouring.cs"
    click DCconfig "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Voxels/DC/DualContouringConfig.cs"
    click GPUVertex "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Voxels/DC/GPUVertex.cs"
    click OnMeshGen "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Voxels/DC/OnMeshGenerated.cs"
    click VVol "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Voxels/Volume/VoxelVolume.cs"
    click VVolConfig "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Voxels/Volume/VoxelVolumeConfig.cs"
    click GPUVoxelCSG "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Voxels/Volume/GPUVoxelVolumeCSGOperation.cs"
    click GPUCSG "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Voxels/CSG/GPUCSGOperator.cs"
    click CSGUtil "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/Voxels/CSG/CSGUtility.cs"
    click ChunkCS "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/World/Chunk.cs"
    click WorldMgr "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scripts/World/WorldManager.cs"
    click DCAsset "https://github.com/tuntenfisch/voxels/blob/release/Assets/ScriptableObjects/Voxels/Dual Contouring Config.asset"
    click GenGraph "https://github.com/tuntenfisch/voxels/blob/release/Assets/ScriptableObjects/Voxels/Generation Graph.asset"
    click MatConfig "https://github.com/tuntenfisch/voxels/blob/release/Assets/ScriptableObjects/Voxels/Material Config.asset"
    click VVAsset "https://github.com/tuntenfisch/voxels/blob/release/Assets/ScriptableObjects/Voxels/Voxel Volume Config.asset"
    click URPAsset "https://github.com/tuntenfisch/voxels/blob/release/Assets/ScriptableRenderPipeline/UniversalRenderPipelineAsset.asset"
    click VShader "https://github.com/tuntenfisch/voxels/blob/release/Assets/Shaders/Voxels/Voxel.shader"
    click HoloGraph "https://github.com/tuntenfisch/voxels/blob/release/Assets/ShaderGraphs/Hologram.shadergraph"
    click Prefab "https://github.com/tuntenfisch/voxels/blob/release/Assets/Prefabs/Voxels/Chunk.prefab"
    click Scene "https://github.com/tuntenfisch/voxels/blob/release/Assets/Scenes/Main.unity"

    %% Styles
    classDef gpu fill:#cce5ff,stroke:#3399ff;
    classDef cs fill:#ccffcc,stroke:#33cc33;
    classDef data fill:#ffe6cc,stroke:#ff9933;
    classDef render fill:#e0ccff,stroke:#9933ff;
```
