domenica 5 novembre 2017

Day 197: UBOs

I've not been updating the engine for a few months, but in the meantime I learned a lot about modern C++, graphics techniques and game engines. So I decided to continue this project, in order to improve things I did in the past, as well as experiment with new techniques.
I spent some time just going through the code, as my memories of it are a bit blurry, and I immediately noticed something I was doing in an inefficient way: all the uniforms in the game were sent individually to each shader. This is clearly not ideal, as it adds some bandwidth cost.So I did some research, and found out about uniform buffer obejects, which I never used in the past. They are a simple, read-only area of memory on the GPU, which can be accessed by all shaders. So I created a UBO containing all the global uniforms that most shaders rely on: matrices, time and camera positions for now. I updated all shaders to use them and the engine is now working with them.
I'm now thinking of adding a way to create custom UBOs, so that user-level shaders can benefit from the same technique. Basically what Unreal Engine does with the Collections of parameters.

Nessun commento:

Posta un commento