It's been a while since I last posted here! If you follow my blog, you'll know I have been working on learning how to program a renderer.

I was very proud because I managed to bring my basic scene from 5.5k+ calls to just 292, with lights and shadows and stuff (see below)!

I achieved this through careful ECS and Material batching 1/3

Credits: Models are Tiny Treat's Pretty Park bundle, btw!
#gamedev #rendering #opengl #graphics

Which essentially means: Bind the material and its variables once, then draw everything that uses that material in one go.

To do this, I would sort primitives per material and solve their world matrices (that means, mesh transform, node local transform and parent transform) and just push everything together to the GPU in one call.

I felt like a pro!

But... 2/3

I was watching a video about making grass, and as it turns out, the GPU keeps the matrices between frames! So I am just wasting huge amounts of CPU time every frame recalculating everything.

Now I feel like an impostor. Sigh.

My next goal is to have some kind of cached state of the matrices I can consult so I only call the GPU to update those. I also know there's a way to ask the GPU for a pointer in memory and update that, but I'm not sure if it will fit my current architure that well