SDF Mesh Library

Library

Marching cubes & squares mesh generation

Facepunch updated 1y ago 0 MB engine 22
thumb_up 25 open_in_new View on sbox.game
SDF Mesh Library

About SDF Mesh Library

Allows you to define a 2D / 3D field of signed distances to a virtual surface, perform operations with primitive shapes, and then generate a 3D mesh of the surface in real-time.

Create a world

using Sandbox.Sdf;

// ...

var sdfWorld = new Sdf2DWorld
{
    // Rotate so that Y is up
    LocalRotation = Rotation.FromRoll( 90f )
};

In this example we've rotated it by 90 degrees, so that the Y axis when doing 2D operations becomes the Z (up) axis in world space.

Draw some shapes

Still in server-side code, you can modify the SDF world like this:

// Shape that we want to add
var circle = new CircleSdf( new Vector2( localPos.x, localPos.y ), radius );

// Load the material to use
var material = ResourceLibrary.Get<Sdf2DLayer>( "layers/sdf2d/checkerboard.sdflayer" );

// Draw the circle!
sdfWorld.Add( circle, material );

// Move the circle to the right, then subtract it!
sdfWorld.Subtract( circle.Translate( new Vector2( 32f, 0f ) ), baseMat );
6,523
Total Users
16,980
Total Sessions
5.8 months
Total Playtime
0 recorded entries
Rank Player Score Recorded
refresh
Discovering package leaderboards...
Package ID: facepunch.libsdf
Created: 2023-04-27 10:24 UTC
Updated: 2025-09-30 15:14 UTC
Type: library
Public: Yes
Version: 121787
files: 57
Size: 0.5 MB
Engine Version: 22
Asset Version ID: 121787
Version Created: 2025-09-30 15:14 UTC
Hash: 8250603074539432805
Manifest: Open manifest

more_horiz Additional Properties

Project Template:
Summary: Marching cubes & squares mesh generation
Description: * Sdf2DWorld for 2D layers * Sdf3DWorld for 3D volumes
Public: true
Compiler: {"RootNamespace":"Sandbox","DefineConstants":"SANDBOX;ADDON;DEBUG","NoWarn":"1701;1702;1591;","References":[],"DistinctReferences":[]}
Replace Tags: procgen mesh 3d 2d
new_releases Latest Update Sep 30, 2025
Changes on 2025-09-30
121787 Sep 30, 2025
Changes on 2025-09-30
114518 Aug 18, 2025
Changes on 2025-08-18
77682 Nov 19, 2024
Changes on 2024-11-19
77637 Nov 19, 2024
Changes on 2024-11-19
71520 Aug 31, 2024
Changes on 2024-08-31
70881 Aug 28, 2024
Changes on 2024-08-28
70398 Aug 27, 2024
Changes on 2024-08-27
62649 Aug 1, 2024
Changes on 2024-08-01
62647 Aug 1, 2024
Changes on 2024-08-01
62629 Aug 1, 2024
Changes on 2024-08-01
info Live API Passthrough & Removal Notice

This file manifest and asset metadata are retrieved live directly from the official Facepunch s&box public API. s&box Explorer does not host, store, or redistribute any package files. All download links route directly to Facepunch CDN servers.