H073.VertexKit 1.0.0

Prefix Reserved
dotnet add package H073.VertexKit --version 1.0.0
                    
NuGet\Install-Package H073.VertexKit -Version 1.0.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="H073.VertexKit" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="H073.VertexKit" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="H073.VertexKit" />
                    
Project file
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 H073.VertexKit --version 1.0.0
                    
#r "nuget: H073.VertexKit, 1.0.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 H073.VertexKit@1.0.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=H073.VertexKit&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=H073.VertexKit&version=1.0.0
                    
Install as a Cake Tool

VertexKit

Lightweight geometry and render-command library for MonoGame. Handles vertex/index buffer creation, bounding volume computation, frustum culling, render sorting, GPU instancing, and dynamic meshes — so you can focus on what to draw, not how.

.NET 10 | MonoGame 3.8.4

Features

  • Primitive — GPU-resident geometry with automatic bounds. The base unit for anything drawable.
  • PrimitiveBuilder — Fluent builder that auto-selects the optimal vertex format and computes normals when missing.
  • DynamicMesh<T> — Per-frame updatable geometry using DynamicVertexBuffer / DynamicIndexBuffer. Ideal for water, trails, deformable terrain.
  • InstanceBatch<T> — Single draw call for thousands of instances (grass, trees, particles).
  • RenderCommand — Immutable draw command struct carrying everything needed to issue a draw call.
  • RenderSorter — Opaque front-to-back with material batching, transparent back-to-front.
  • BoundsHelper — Bounding box/sphere computation, transform, merge, and frustum visibility tests.
  • MeshHelper — Normal and tangent generation, polygon triangulation.

Vertex Formats

Struct Channels
VertexPositionNormal Position, Normal
VertexPositionNormalTextureColor Position, Normal, UV, Color
VertexPositionNormalTextureTangent Position, Normal, UV, Tangent

PrimitiveBuilder picks the right format automatically based on which data you provide.

Usage

Build a triangle

using VertexKit;

var primitive = new PrimitiveBuilder(GraphicsDevice)
    .SetPositions([
        new Vector3(0, 1, 0),
        new Vector3(-1, -1, 0),
        new Vector3(1, -1, 0)
    ])
    .SetIndices([0, 1, 2])
    .Build();

// Draw directly
primitive.Draw(GraphicsDevice);

// Or generate a render command for sorting/culling
var cmd = primitive.ToRenderCommand(Matrix.Identity);

Build a textured quad with a material

var quad = new PrimitiveBuilder(GraphicsDevice)
    .SetPositions([
        new Vector3(-1, 1, 0), new Vector3(1, 1, 0),
        new Vector3(-1, -1, 0), new Vector3(1, -1, 0)
    ])
    .SetTexCoords([
        new Vector2(0, 0), new Vector2(1, 0),
        new Vector2(0, 1), new Vector2(1, 1)
    ])
    .SetIndices([0, 1, 2, 2, 1, 3])
    .SetMaterial(myMaterial)
    .Build();

GPU instancing

var batch = new InstanceBatch<InstanceData>(GraphicsDevice, treePrimitive, maxInstances: 10000);

// Each frame:
batch.SetInstances(instanceArray, activeCount);
var cmd = batch.ToRenderCommand(material, boundingSphere);
cmd.Apply(GraphicsDevice);
cmd.Draw(GraphicsDevice);

Dynamic mesh (per-frame updates)

var water = new DynamicMesh<VertexPositionNormal>(GraphicsDevice, maxVertices: 4096, maxIndices: 12288);

// Each frame:
water.SetVertices(vertexArray, vertexCount);
water.SetIndices(indexArray, indexCount);
var cmd = water.ToRenderCommand(waterMaterial, Matrix.Identity, waterBounds);

Frustum culling and render sorting

var visible = new List<RenderCommand>();
RenderSorter.CollectVisible(allCommands, camera.Frustum, visible);

var span = CollectionsMarshal.AsSpan(visible);
RenderSorter.Sort(span, camera.Position);

foreach (var cmd in span)
{
    cmd.Material?.Apply();   // your shader setup
    cmd.Apply(GraphicsDevice);
    cmd.Draw(GraphicsDevice);
}

Custom material

Implement IRenderMaterial to integrate with the sort/cull pipeline:

public class MyMaterial : IRenderMaterial
{
    public bool IsOpaque => true;
    public int SortKey => _effect.GetHashCode();
}

Install

Add a project reference:

<ProjectReference Include="..\VertexKit\VertexKit.csproj" />
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 73 3/30/2026