-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sprite z-ordering #114
Comments
Appears to be related to #31 |
This is a good idea! |
I tried adding a
The ideal way to do this would probably be to pass z info down into opengl (or other backend) and have it deal with it. I'm pretty sure this is a thing opengl is good at. Blocker for this appears to be An alternate method would to be provide |
Sorting in draw loops should be fast enough. Can't handle sorting by depth in the backend if the blending operation is not communative. Additive blending supports this but not normal alpha blending. Therefore any sorting should happen before sending it to |
Passing down the z values to OpenGL may not perform as well as sorting the scene tree. OpenGL will render the correct scene with the right visibility, nevertheless, this comes a the price of redrawing the same pixels and writing in the z-buffer. In the worst case, we can end up drawing each sprite just to be overwritten with the next one drawn. Of course, this performance issue may only be noticeable with very large number of overlapping sprites. Sorting the scene tree is usually a good technique. In any case, I see a great value on implementing a z value for the sprites. Looking forward to see this feature. |
Currently to control z-ordering I remove a sprite from a scene then re-add it to place it on top (example). This is kind of hackish.
Did you envision this library handling such a thing? I might have a crack at it if you're interested. I was thinking of adding a z-attr to
Sprite
then sorting by that before drawing at https://github.com/PistonDevelopers/sprite/blob/master/src/scene.rs#L84Thanks!
Xavier
The text was updated successfully, but these errors were encountered: