NSprites is an open-source sprite rendering package. It uses ComputeBuffers
to sync data between your entities and GPU and Graphics.DrawMeshInstancedProcedural
to render entities.
Requirements
- entities v1.0.0-pre.65+
- unity 2022.2+
When you might want to use it
- Your project operate with numerous of sprites so you wanna make them native entities. + You want to have your sprites as individual entities.
- You want to minimize drawcalls, even probably render the most part in the same drawcall.
When you might not want to use it
- You don’t want to write your own instancing shaders
- You want more progressive solution with built-in animation / culling / etc systems. (you still can look at NSprites Foundation project or Age of Sprites sample project)
Readme and documentation on GitHub project. Also check Foundation with samples and tools to work with this package.
Notes
This package doesn’t contain any animation / culling / sorting / etc systems. So package provides very core feature - sprite rendering with automatic compute buffer data management. Though such systems can be easily built on top of it. You can inspect samples and use some tools by looking at sample project and foundation (which includes animation / sorting / culling / base rendering).
The main reason of such a pure solution is because developers often want to have unique code architecture and I don’t want to unnecessary limit anyone, because you may have no need in sorting at all, you may want to have simple sorting or nested sprites sorting or implement clever performant sorting algorithm (same with any other high level system).
Changelog
v4.0.1
Temporal fix for chunk components baking issues for unity6 / entities 1.2 compatibility
v4.0.0
Remove RegisterRender
overload with no Bounds
parameter.
This commit brings breaking changes. To upgrade to this version you need now use overload with explicit bounds parameter.
v3.2.0
- storage now test if archetype with same id already registered and log an error if it is
- client code now can clear storage which disposes all render archetypes (for example when you change game level and no more need previous archetypes)
v3.1.7
- Code refactoring
- Fix sprites didn’t get rendered until 1st reallocation
v3.1.2
Fix wrong reallocation with min capacity step greater than 1
v3.1.1
Fix invalid data sync for EachUpdate
mode properties
v3.1.0
Update to entities 1.0.0-pre.65. Error / obsolete API fixing.
- Fix asmdefs errors
- Fix using obsolete API in NSprtiesUtils baker AddSpriteRenderComponents method
v3.0.4
Fix add rendering components methods missed PropertyPointerChunk
component
v3.0.3
Add DebugSystem
(editor / development build only) which detect missed property-components for sprite renderers and wrong PropertyPointer
/ PropertyPointerChunk
composition (if it somehow was setted wrong)
You can use NSPRITES_DEBUG_SYSTEM_DISABLE
to fully disable debug system from compilation if you don’t need it
v3.0.1
Minor internal changes of how PoprertyPointer
/ PropertyPointerChunk
baked to entity
v3.0.0
You can use any blittable component as shader StructuredBuffer<T>
property. Previously only 1-filed component could be used. Update details. Using components as properties details.
Upgraid guide: There is no more PropertyFormat
so all your
InstancedPropertyComponent
should be used without PropertyFormat
parameter. So for example [assembly: InstancedPropertyComponent(typeof(SpriteColor), "_color", PropertyFormat.Float4)]
becomes [assembly: InstancedPropertyComponent(typeof(SpriteColor), "_color")]
v2.3.0
- You can now also register Mesh (quad by default as previously) and render bounds per render using new
RenderArchetypeStorage
methods. - Added
NSpritesException
for better exception analysis
v2.2.4
Bug fixes / improvements
v2.2.0
Add Window → Entities → NSprites window where you can inspect NSprites data. More.
v2.1.0
Add baker extension method for adding sprite render components driven by baking system. From now client code can use this.AddSpriteRenderComponents(int id)
from baker code.
v2.0.0
Upgrade codebase to 1.0 API. Details.
Upgrade guide: to register renders you should now use SystemAPI.ManagedAPI.TryGetSingleton<RenderArchetypeStorage>(out var renderArchetypeStorage)
instead of accessing directly to system instance like var renderSystem = World.GetSystem<SpriteRenderingSystem>();
v1.1.2
Minor typos / obsolete API / bug fixes + improvements
v1.0.0
Release version. From this point package has documentaton on github wiki and also samples.
alpha-v.2.0.0
Last alpha version when package was in deep developement. This version is hardly differ from next versions. It can be only used with entities v0.17 and has no documentation nor samples.
I highly appreciate any discussions / critique / questions / bug reports / pull requests!
You can join NSprites discord channel to fast contact with author and other package users!