VoxelMeshOptimizer 1.2.0
dotnet add package VoxelMeshOptimizer --version 1.2.0
NuGet\Install-Package VoxelMeshOptimizer -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VoxelMeshOptimizer" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VoxelMeshOptimizer" Version="1.2.0" />
<PackageReference Include="VoxelMeshOptimizer" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VoxelMeshOptimizer --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: VoxelMeshOptimizer, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VoxelMeshOptimizer@1.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VoxelMeshOptimizer&version=1.2.0
#tool nuget:?package=VoxelMeshOptimizer&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Voxel Mesh Optimization Library
VoxelMeshOptimizer turns voxel chunks into compact meshes. It removes hidden faces and merges quads so that a whole chunk can be rendered with a minimal triangle count.
Install
dotnet add package VoxelMeshOptimizer
Quick start
Basic usage
using VoxelMeshOptimizer.Core;
using VoxelMeshOptimizer.Core.OptimizationAlgorithms.DisjointSet;
using VoxelMeshOptimizer.Toolkit;
var chunk = new ExampleChunk(PerlinNoiseChunkGen.CreatePerlinLandscape(50, 123));
var optimizer = new DisjointSetMeshOptimizer(new ExampleMesh());
Mesh mesh = optimizer.Optimize(chunk);
File.WriteAllText("chunk.obj", ObjExporter.MeshToObjString(mesh));
Multithreaded usage (Tasks-based)
Multithreading usage
using VoxelMeshOptimizer.Core;
using VoxelMeshOptimizer.Core.OptimizationAlgorithms.DisjointSet;
using VoxelMeshOptimizer.Toolkit;
// Initialization of the TaskManager
using CancellationTokenSource cts = new();
// Decomposition of the types :
// - Int3 pos : Position of the chunks, usefull when generating a bunch of chunks and you need to remember where to put them
// - Func<Int3, Chunk> gen : Funciton to generate the Chunk's data
// - (Chunk chunk, Mesh mesh) : Result of a task, the initial chunk and its mesh
TaskManager<(Int3 pos, Func<Int3, Chunk> gen), (Chunk chunk, Mesh mesh)> manager = new(
workerCount: Environment.ProcessorCount, // TODO : set to 1 if you want one worker
processor: (job, ct) => // TODO : What one job actually do
{
(Int3 pos, Func<Int3, Chunk> gen) = job;
Chunk chunk = gen(pos);
DisjointSetMeshOptimizer optimizer = new(new Mesh([]));
Mesh mesh = optimizer.Optimize(chunk);
return ValueTask.FromResult((chunk, mesh));
}
);
// Creating chunks
int iterations = 3;
Int3 chunkPos = new() { x = 0, y = 0, z = 0 };
for (int i = 0; i < iterations; i++)
{
_ = manager.Enqueue((chunkPos,
p => new Chunk(PerlinNoiseChunkGen.CreatePerlinLandscape(size: 16, seed: 123))));
}
for (int i = 0; i < iterations; i++)
{
if (manager.TryDequeueCompleted(out TaskManager<(Int3 pos, Func<Int3, Chunk> gen), (Chunk chunk, Mesh mesh)>.Completion r))
{
if (r.Error) {
// An issue occured during the process
// TODO : Handle the error
}
// TODO : Do what you like with the chunk
}
else
{
// TODO : Continue program's work and come back later
}
}
// Destroy manager and prevent leaks
await manager.DisposeAsync();
General Workflow
- Build or load a
Chunk<Voxel>. DisjointSetMeshOptimizerusesVoxelOcclusionOptimizerand a 2‑D union‑find to merge faces.- Export the resulting mesh or feed it to your engine.
See the GitHub repository for examples, benchmarks and complete documentation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- CommunityToolkit.Diagnostics (>= 8.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.