menu_bookDocumentation

Texture Generators - s&box Editor Documentation

calendar_today May 5, 2026 schedule ~1 min read person patrickjr verified 50

Texture Generators

Create procedural textures in code. Generate textures from shapes, gradients, text, or any algorithm.

Creating a Generator

Inherit from TextureGenerator:

CSHARP
[Title( "Circle" )]
[Icon( "palette" )]
public class CircleTextureGenerator : TextureGenerator
{
    [KeyProperty]
    public Color Color { get; set; } = Color.Magenta;
    
    public Color BackgroundColor { get; set; } = Color.White;
    
    [Hide, JsonIgnore]
    public override bool CacheToDisk => true;
    
    protected override ValueTask<Texture> CreateTexture( 
        Options options, 
        CancellationToken ct )
    {
        var bitmap = new Bitmap( 128, 128 );
        
        bitmap.Clear( BackgroundColor );
        bitmap.SetFill( Color );
        bitmap.DrawCircle( 64, 64, 40 );
        
        return ValueTask.FromResult( bitmap.ToTexture() );
    }
}

Properties

Mark properties with attributes:

  • [KeyProperty] — Main property shown in UI
  • [Range] — Numeric slider
  • [Color] — Color picker

Cache To Disk

CSHARP
public override bool CacheToDisk => true;

Cached textures save to disk and persist. Disable for runtime-only generators.

Code Location

Put texture generators in:

  • Game code — If needed at runtime
  • Editor project — If only for editor use

Usage

  1. Create texture in Asset Browser
  2. Select your generator
  3. Adjust properties
  4. Use in materials
Texture generators are powerful for procedural content and editor tooling.
Was this helpful?