I want to experiment with some new stuff about modern rendering techniques and in that way I'm trying to implement a custom GI (somewhere between pathtracing and instant radiosity). My scene is a bit less than 1,000,000 tris and my algorithm requires to render the same scene a lot of times into different tiny textures (let's call them "bounces").
I've began my implementation in a naive way so I rapidly ran into some performance problems:
With my 1TFlops laptop GPU I can render my 1M poly scene I can have 200 "bounces" before dropping bellow 30FPS which is far from enough.
My "naive" algorithm looks like this in pseudo code:
for (unsigned int i = 0; i < res ; ++i) {
UpdateCameraUniform(i);
glBindFramebuffer(GL_FRAMEBUFFER, BounceFbo[i]);
glDrawBuffers(1, renderBuffer[i]);
for (Mesh& m : Scene) {
m.render();
}
}
with
Mesh::render() {
UpdateTransformUniform();
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ebo);
glDrawElements(GL_TRIANGLES, size, GL_UNSIGNED_INT, 0);
}
The full code is here (the depot is really messy for now...).
I need to find a new strategy to render my scene so I searched what I could do.
I think I have 2 strategies:
Trying to reduce the number (or the performance) of my drawcalls. It seems that there is some magic function like glMultiDraw* (I've found it in a post on "OpenGL superbible" here). But I don't really understand what this does:
- Does this render multiple times the same mesh?
- Different mesh but with one shader?
- Different mesh with different shader but just with low CPU overhead?
Trying to reduce the render time while rendering multiple times the same mesh in "Bounces" using the same technique as this but I have absolutely no idea how it works or even if it can apply to me...
Obviously I am open to any other suggestions.
Edit: I can reach 200 "bounces" not 35