antoshidza / nsprites Goto Github PK
View Code? Open in Web Editor NEWUnity DOTS Sprite Rendering Package
License: Other
Unity DOTS Sprite Rendering Package
License: Other
The rendering performance is impressive but I noticed that computing sort value is slow compared to the rendering.
Maybe the sorting work could be done on GPU and the result could be consumed in sprite shader thus no CPU is involved.
I found this repo https://github.com/hiroakioishi/UnityGPUBitonicSort/tree/master and have a simple performance test:
3 GHz 6 core Intel Core i5
Radeon Pro 570X 4 GB
Unity 2021.3.14
Running in Editor
buffer size: 262144
sorting cost (no ComputeBuffer.GetData): 0.0783 ms
This is just a suggestion.
The following line uses Graphics to draw.
NSprites/Rendering/Common/RenderArchetype.cs
Line 576 in abf1821
One could also add it back to Graphics when desired
https://docs.unity3d.com/ScriptReference/Graphics.ExecuteCommandBuffer.html
or add to specific desired camera
https://docs.unity3d.com/ScriptReference/Camera.AddCommandBuffer.html
This would provide support for hybrid rendering
Thanks for NSprite.
I have a sprite sheet with multiple animations. I was wondering if you'd consider skipping "0 second length" frames in SpriteUVAnumationSystem. So, "walk" could be frames 0-3 and "idle" could be frames 4-7.
Here's one proposal to check the nextFrameDuration. I would add an escape clause to the loop in case someone accidentally create an AnimationSet where all frames are set to 0.
A better way might be to change SpriteAnimatedRendererAuthoring to not load them into the animationSet. That would avoid checking each frame.
if (timerDelta >= 0f)
{
ref var animData = ref animationSet.value.Value[animationIndex.value];
var frameCount = animData.FrameDurations.Length;
frameIndex.value = (frameIndex.value + 1) % frameCount;
var nextFrameDuration = animData.FrameDurations[frameIndex.value];
////// added. Would need an escape clause in case all frames are set to 0.
while (nextFrameDuration == 0f)
{
frameIndex.value = (frameIndex.value + 1) % frameCount;
nextFrameDuration = animData.FrameDurations[frameIndex.value];
}
if (timerDelta >= animData.AnimationDuration)
{
var extraTime = (float)(timerDelta % animData.AnimationDuration);
while (extraTime > nextFrameDuration)
{
extraTime -= nextFrameDuration;
frameIndex.value = (frameIndex.value + 1) % frameCount;
nextFrameDuration = animData.FrameDurations[frameIndex.value];
}
nextFrameDuration -= extraTime;
}
Opening the sample project or trying to use the package on macOS (tested on M1 Pro, macOS Monterey) fails to compile and shows multiple errors in the console like: "Library/PackageCache/com.tonymax.nsprites@aedf3b9/Rendering/Common/RenderArchetype.cs(205,71): error CS1519: Invalid token '�' in class, record, struct, or interface member declaration"
converting the encoding in Rider for example to UTF8 does not fix the issue.
edit: seems to be the "C" character in "ChunkBaseEntityIndices" is invalid/corrupted
How to reproduce:
SpriteRendererAuthoring
EachUpdate
I'm using 1.016 Entities and Entities Graphics with NSprite 4.0.0 and NSprite Foundation 6.0.3
SImply add one GameObject to the subscene and add SpriteAnimatedRendererAuthoring with those Animation from Age-of-Sprites Project, the Sprite Frame Animation dosen't show as expected neither editor mode nor runtime mode
It would be helpful to have an example implementation of a valid render archetype or shader. I'm unsure how to handle the matrices property in a custom shader.
p.s. I really appreciate you working on this and making it public! Its a very noticeable gap in the DOTS ecosystem
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.