High-performance afterimage effect for Unity 2D using GPU instancing
  • C# 82.2%
  • ShaderLab 17.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Yusuke Nakada 9f0782e166
Merge pull request #4 from nuskey8/update-inspector-image
chore: update inspactor image
2026-08-26 20:55:52 +09:00
Assets chore: bump up to 1.1.0 2026-08-26 20:37:04 +09:00
docs chore: update inspactor image 2026-08-26 20:55:35 +09:00
Packages Initial commit 2026-08-26 19:13:15 +09:00
ProjectSettings Initial commit 2026-08-26 19:13:15 +09:00
.gitignore Initial commit 2026-08-26 19:13:15 +09:00
LICENSE Initial commit 2026-08-26 19:13:15 +09:00
README.ja.md chore: Update README 2026-08-26 20:34:47 +09:00
README.md chore: Update README 2026-08-26 20:34:47 +09:00

SpriteAfterimage

High-performance afterimage effect for Unity 2D using GPU instancing

GitHub license Unity

English | 日本語

demo

SpriteAfterimage is a library that provides a component for rendering afterimages of SpriteRenderer in Unity.

By utilizing Unity 6.5's Graphics.RenderSpriteInstanced, it achieves high-performance afterimage rendering through GPU instancing, drawing them all together without generating a GameObject or SpriteRenderer for each afterimage.

Setup

Requirements

  • Unity 6.5 or later
  • Universal Render Pipeline (URP)

Installation

  1. Open Package Manager from Window > Package Manager
  2. Click the "+" button > Add package from git URL
  3. Enter the following URL:
https://github.com/nuskey8/SpriteAfterimage.git?path=Assets/SpriteAfterimage

Alternatively, open Packages/manifest.json and add the following to the dependencies block:

{
    "dependencies": {
        "com.nuskey8.spriteafterimage": "https://github.com/nuskey8/SpriteAfterimage.git?path=Assets/SpriteAfterimage"
    }
}

Quick Start

  1. Add the SpriteAfterimage component to the GameObject on which you want to display afterimages.
  2. Specify the target SpriteRenderer in Source. If added to the same GameObject, it will be set automatically when the component is added.
  3. Specify the appropriate shader for your use case in Shader.
    • SpriteAfterimage/Unlit: Afterimages unaffected by 2D Light
    • SpriteAfterimage/Lit: Afterimages affected by URP 2D Light
  4. Adjust Emit Interval, Lifetime, Color, and other settings.

Configuration Properties

inspector

Property Description
Source The SpriteRenderer used as the source for recording afterimages
Emission Enabled Whether to emit new afterimages
Emit Interval The interval (in seconds) at which afterimages are recorded
Lifetime The duration (in seconds) that each afterimage is displayed
Color The color of the afterimage
Color Mode Tint: Multiplies Color with the original sprite color
Solid: Fills with a solid Color
Fade The alpha value of the afterimage relative to its elapsed time
Use Unscaled Time When enabled, it is not affected by Time.timeScale
Shader The shader used to render afterimages
Sorting Layer Sorting Layer used to render afterimages
Order in Layer Order in Layer used to render afterimages

GPU Instancing

By default, SpriteAfterimage renders afterimages of the same sprite using Graphics.RenderSpriteInstanced; however, if the runtime environment does not support GPU instancing, it renders them individually using Graphics.RenderSprite. If performance becomes an issue in such environments, it is recommended to limit the number of afterimages.

License

MIT

The Unity-chan asset used in the demo is provided under the Unity-chan License Terms.

unitychan-logo