Home

Awesome

GPU Sprite Instancing :zap:

I. Overview

<br /> <p align="center"> <img src="/Assets/DocResources/Gifs/SampleDemo.gif" width="1000"> </p> <p align="center"> Sample demo running on Mac with <u><strong>1,000,000 instances</strong></u> at <u><strong>> 100 FPS</strong></u> </p> <p align="center"> Sample sprite source <a href="https://cupnooble.itch.io/sprout-lands-asset-pack">here</a> (Free) </p>

II. Features

<details> <summary>Core Features</summary> </details> <details> <summary>Components</summary> </details>

III. Setup

> Requirements

> Installation

  1. Open Package Manager from Window > Package Manager
  2. Click on the "+" button > Add package from git URL
  3. 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

<sub>Example</sub>

https://github.com/centhoang/GPUSpriteInstancing.git?path=/Assets/GPUSpriteInstancing#1.1.0

> Intergration

  1. Add a GPUSpriteManager component to a GameObject in your scene
  2. Assign the GPUSpriteInstancingMat material (or your material which suits the system) to the manager
  3. Create your sprite atlas texture
  4. Use GPUSpriteManager.UpdateSprites() to render your sprites

IV. Usage

> Basic Implementation

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

> Best Practices

V. Performance