So, I'm finally working on a "material" system in my engine. Until now there was no need for it since there was just one scene shader, with the only object-unique uniform being the texture. The framebuffer and debug lines were special cases that bind their own shaders (1/?)
So, each "object" (I called it Model) was just Mesh, texture, and the model matrix. This was actually the whole scene rendering logic, I did some checks to see if models in sequence have the same texture or mesh to reduce unnecessary binds: (2/?)
But now with adding materials, I actually have to refactor almost everything, and turn the Model into a bigger beast, that has a Transform, Mesh and Material. With the only addition being ability to switch shaders (3/?)
But that adds a layer of complexity. First you need to add unknown-size properties to each material, meaning you'll have dynamic arrays scattered around. The easy way of optimizing like in the loop above becomes a more difficult. (4/?)
And I still want to keep the ability to have manually set property materials as I did with the old shader. I'm trying to use inheritance (for the first time in C++!) to be able to do that, but I don't like it so much. (4/?)
While the "dynamic" material is like this (using union as well for properties, which I discovered is actually a pretty cool concept :D):
The question is kind of, is the added complexity worth it? I thought the abstraction of Material might help, but now that I'm deep into it, I feel like the old system was just fine. I wanted to not need a special case framebuffer and debug lines, but they are special anyway (?/?)
Actually, I'm probably even going to have just a few shaders, an opaque one, cutout, transparent, maybe a triplanar one for ground. Skybox, lines, framebuffer are already special and completely out of the main scene loop anyway. (?/?)
And I'm not trying to make a AAA engine for customers. I want to have a thing where I can just go into the main loop and poke things DIRECTLY, instead of creating these abstractions. That's the benefit of a custom engine anyway! :D (end)
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.
