Comments (5)
What if you want a specific draw order in your layer? Say, Object A and B are both on the same layer, but you want B drawn over A whilst B having a lower texture ID?
from sparky.
Don't forget that this is a 3D engine so even if you use it to render 2D sprites their positions are still represented by 3D vectors. Easy to then use the Z coord to deal with this.
As a rule, the rendering of the scene should always and only be dictated by the data, not the order you submit things in.
from sparky.
Could you provide a example? Where and what vector do I need to sort. (i'm just being curious as i don't know how long the series are being halted for)
from sparky.
Ossadtchii - To my understanding this is not just a simple sorting of vector that ed is suggesting. It's also a wonderful idea and I will personally be implementing into my own engine (thank you and I can't believe I didn't think of it, but I guess that is why I went looking here for suggestions). In order to do it your self, you will need to change the submit method to store some key information about the renderable being submitted (I would use a struct that stored the shader id, the material id / name (if you are using them), and the texture id) alongside a pointer to the renderable and I would store that in the struct as well. Now when it comes to the flush method I would do as suggested and go down and sort the vector storing all of these structs first by shader id, then material id, then texture id. At the end you then just render the renderables in the new order obtained by this newly sorted vector. But I don't believe it is as simple as needing to sort a vector as the system just isn't built for it. The only way you could make such a simple change is in the Simple2DRenderer where we are still storing everything in a bulk manner. The batch renderer just ruins everything by rendering to the buffer on submission (yet again, not saying this is bad but it doesn't help in this scenario). With this suggested method you would just render them all to the buffer after sorting so you still get the benefit of the batching but also the benefits of the sorting.
Breakdown of efficiency improvements (+) and places where efficiency is hurt (-):
+submit now is doing much less (unless creating the struct and storing it in the vector is more costly than writing to the vector).
-flush is doing a lot more than just the draw call to render the buffer.
-sorting the vector will take some time.
-we are now doing all of the batching that was done each submission all in the flush method.
+draw calls (the things that take up the most time) have been drastically reduced and in my opinion should far outweigh the small inefficiencies stated above as they are all things that if they were to bring your engine to it's knees show a larger underlying problem.
I hope I was able to help.
from sparky.
Because 2D rendering doesn't define a canonical order (and, typically, requires fairly complex, order dependent alpha compositing), BatchRenderer provides a strict ordering guarantee in the form of submission order. The system is designed to perform well, even given that the input data isn't going to be optimal.
from sparky.
Related Issues (20)
- Metallic and Roughness workflow HOT 2
- Linux build HOT 15
- CLI wrapping HOT 2
- Still getting very low FPS count despite using Batch Rendering HOT 3
- In Test3d can't move camera neither walk on the scene HOT 2
- Bug in Mat4::Rotate
- Add Debug Log Levels HOT 2
- Unix build
- Emscripten
- Shaders on Intel graphics HOT 4
- Memory allocation alignment bug HOT 2
- Sparky, Also suitable for 3d games? HOT 1
- Crashing on Debug build of external app using Release build of Sparky at String HOT 2
- Software License Still Has Template String
- [OPTIONAL] Include guards HOT 4
- Where can I find help about my code? HOT 1
- ep 19 no text is rendering but it draws the black blocks of the letters HOT 2
- How does Sparky support Windows' DLL exports in the context of Unix systems?
- cling based C++ as scripting language / hot code reload
- Error right out of the box InputManager::ClearKeys() HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sparky.