Top Related Projects
Procedural generation library for Unity
Quick Overview
SabreCSG is a Unity plugin for creating and editing 3D levels directly within the Unity editor. It provides a set of tools for constructive solid geometry (CSG) operations, allowing developers to quickly prototype and build complex 3D environments using simple shapes and boolean operations.
Pros
- Intuitive and fast level design workflow within Unity
- Real-time CSG operations for quick iteration
- Supports both primitive shapes and custom brushes
- Integrates seamlessly with Unity's existing tools and workflow
Cons
- Learning curve for users unfamiliar with CSG concepts
- Performance can degrade with very complex geometry
- Limited documentation and community support compared to some alternatives
- May require additional optimization for final game builds
Code Examples
// Creating a new CSG brush
CSGBrush newBrush = CSGBrush.Create(PrimitiveBrushType.Cube);
newBrush.transform.position = Vector3.zero;
newBrush.transform.localScale = Vector3.one * 2f;
// Performing a boolean subtraction operation
CSGBrush baseBrush = CSGBrush.Create(PrimitiveBrushType.Cube);
CSGBrush cuttingBrush = CSGBrush.Create(PrimitiveBrushType.Sphere);
CSGBooleanOperationsUtility.Subtract(baseBrush, cuttingBrush);
// Applying a material to a CSG brush
CSGBrush brush = CSGBrush.Create(PrimitiveBrushType.Cylinder);
Material newMaterial = Resources.Load<Material>("MyCustomMaterial");
brush.SetMaterial(newMaterial);
Getting Started
- Import the SabreCSG package into your Unity project.
- In the Unity menu, go to "Window" > "SabreCSG" to open the SabreCSG toolbar.
- Select the "Draw Brush" tool and click in the scene view to create a new brush.
- Use the CSG tools in the toolbar to manipulate and combine brushes.
- When finished, click "Build" in the SabreCSG toolbar to generate the final mesh.
For more detailed instructions and advanced usage, refer to the official SabreCSG documentation and examples provided in the GitHub repository.
Competitor Comparisons
Procedural generation library for Unity
Pros of ProceduralToolkit
- More comprehensive procedural generation toolkit with a wider range of features
- Better documentation and examples for easier integration
- Active development and regular updates
Cons of ProceduralToolkit
- Steeper learning curve due to its broader scope
- May include unnecessary features for specific use cases
- Less focused on CSG operations compared to SabreCSG
Code Comparison
SabreCSG:
CSGBrush brush = new CSGBrush();
brush.SetShape(PrimitiveBrushType.Cube);
brush.Transform.position = new Vector3(0, 0, 0);
brush.Transform.localScale = new Vector3(2, 2, 2);
ProceduralToolkit:
MeshDraft draft = MeshDraft.Cube(Vector3.one);
draft.Move(Vector3.zero);
draft.Scale(Vector3.one * 2);
Mesh mesh = draft.ToMesh();
Both examples create a cube, position it, and scale it. SabreCSG uses a CSG-specific approach, while ProceduralToolkit offers a more general-purpose mesh generation method.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
SabreCSG
SabreCSG is a set of level design tools for building complex levels quickly inside Unity.
Using Constructive Solid Geometry techniques SabreCSG allows you to add and subtract brushes to create great levels without needing to understand 3D art packages.
SabreCSG was originally sold on the Unity Asset Store, but as of 14th October 2016 has been open sourced under the MIT License (see LICENSE for details). It is now maintained on this Github repository.
Core Features:
- Boolean CSG algorithm supporting partial rebuilding.
- Draw tools to rapidly create levels by drawing brushes directly.
- Resize tools allow you to resize spaces intuitively.
- Vertex tools to refine and add precision details.
- Change materials or edit UVs with surface tools built for level design.
- Clip planes allow you to bevel brushes or even split them in two.
- Export built geometry to .OBJ for use in external 3D tools.
- Vertex Colors - Apply vertex colors per face which are baked into the built meshes.
- Experimental Code API - Experimental support for procedurally generating levels through code.
Documentation and videos on how to use SabreCSG are available at the SabreCSG Learn website or the wiki.
Download
Documentation
Donations:
If you love SabreCSG and wish to say thanks then please feel free to make a donation. Your donations are a huge motivator to continue the development of SabreCSG.
Top Related Projects
Procedural generation library for Unity
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot