- C# 82.2%
- ShaderLab 17.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| Assets | ||
| docs | ||
| Packages | ||
| ProjectSettings | ||
| .gitignore | ||
| LICENSE | ||
| README.ja.md | ||
| README.md | ||
SpriteAfterimage
High-performance afterimage effect for Unity 2D using GPU instancing
English | 日本語
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
- Open Package Manager from Window > Package Manager
- Click the "+" button > Add package from git URL
- 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
- Add the
SpriteAfterimagecomponent to the GameObject on which you want to display afterimages. - Specify the target
SpriteRendererinSource. If added to the same GameObject, it will be set automatically when the component is added. - Specify the appropriate shader for your use case in
Shader.SpriteAfterimage/Unlit: Afterimages unaffected by 2D LightSpriteAfterimage/Lit: Afterimages affected by URP 2D Light
- Adjust
Emit Interval,Lifetime,Color, and other settings.
Configuration Properties
| 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
The Unity-chan asset used in the demo is provided under the Unity-chan License Terms.