---
title: "SDF Mesh Library - s&box library"
description: "Marching cubes & squares mesh generation"
canonical: "https://sbox.watch/ru/libraries/facepunch/libsdf/"
generated_at: "2026-10-09T11:31:14.758Z"
---

# SDF Mesh Library

Marching cubes & squares mesh generation

- Тип: библиотека
- Идентификатор: facepunch.libsdf
- Автор: Facepunch
- Канонический URL: https://sbox.watch/ru/libraries/facepunch/libsdf/
- Markdown: https://sbox.watch/ru/libraries/facepunch/libsdf/index.md
- sbox.game: https://sbox.game/facepunch/libsdf/
- Создано: 2026-10-09T11:31:14.758Z

## Статистика

- динамика за 24 ч: +0
- Terry Score: 90%
- Избранное: 30
- Положительные оценки: 25
- Отрицательные оценки: 0
- Обновлено: 30 сент. 2025 г.
- Создано: 27 апр. 2023 г.
- Размер: 503.7 KB
- Файлы: 57
- Теги: procgen, mesh, 3d, 2d

## Описание

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 );




## More by Facepunch

| Package | Идентификатор | Игроки | Избранное | Положительные оценки | Оценка | Markdown |
| --- | --- | --- | --- | --- | --- | --- |
| Player Controller | facepunch.playercontroller | 0 | 98 | 74 | 96% | https://sbox.watch/ru/libraries/facepunch/playercontroller/index.md |
| Sprite Tools (OBSOLETE) | facepunch.spritetools | 0 | 18 | 22 | 83% | https://sbox.watch/ru/libraries/facepunch/spritetools/index.md |
| Game Events | facepunch.libevents | 0 | 15 | 13 | 83% | https://sbox.watch/ru/libraries/facepunch/libevents/index.md |
| State Machines | facepunch.libstates | 0 | 13 | 17 | 86% | https://sbox.watch/ru/libraries/facepunch/libstates/index.md |
| Spline Tools | facepunch.splinetools | 0 | 12 | 17 | 86% | https://sbox.watch/ru/libraries/facepunch/splinetools/index.md |
| Movie Maker (Preview) | facepunch.moviemaker | 0 | 8 | 13 | 74% | https://sbox.watch/ru/libraries/facepunch/moviemaker/index.md |
