- GPUSpriteInstancing is a Unity package that provides efficient GPU-based sprite rendering using compute buffers and instancing
- Optimized with Unity Burst compiler and Job System for high-performance sprite rendering
Sample demo running on Mac with 1,000,000 instances at > 100 FPS
Sample sprite source here (Free)
Core Features
- GPU Instanced Sprite Rendering
- Batched Drawing System
- Sprite Atlas Support
- Memory Management
- Buffer Management
- Job System Integration
- Burst Compilation
Components
- GPU Sprite Manager
- Instance Renderer
- Custom Shader
- Sprite Data Structure
- Unity 2022.3 or higher
- Burst Package
- Mathematics Package
- Open Package Manager from Window > Package Manager
- Click on the "+" button > Add package from git URL
- Enter the following URL:
https://github.com/centhoang/GPUSpriteInstancing.git?path=/Assets/GPUSpriteInstancing
Or open Packages/manifest.json and add the following to the dependencies block:
{
"dependencies": {
"com.centhoang.gpu_sprite_instancing": "https://github.com/centhoang/GPUSpriteInstancing.git?path=/Assets/GPUSpriteInstancing"
}
}
Important
Use tag(#)
to avoid auto-fetching undesired version
Example
https://github.com/centhoang/GPUSpriteInstancing.git?path=/Assets/GPUSpriteInstancing#1.1.0
- Add a GPUSpriteManager component to a GameObject in your scene
- Assign the GPUSpriteInstancingMat material (or your material which suits the system) to the manager
- Create your sprite atlas texture
- Use
GPUSpriteManager.UpdateSprites()
to render your sprites
// Create sprite data
var spriteData = new NativeArray<SpriteRendererData>(count, Allocator.Temp);
// Fill sprite data with positions, UVs, etc.
// Update and render sprites
spriteManager.UpdateSprites(spriteData, atlasTexture);
- Use shared texture atlases to minimize draw calls
- Keep sprite batches within the 1023 instance limit per draw call
- Dispose of NativeArrays when no longer needed
- Consider using object pooling for dynamic sprite systems
- Optimized for rendering hundreds of thousands of sprites
- Minimal CPU overhead using Job System
- Efficient memory usage with compute buffers
- Batched rendering to reduce draw calls