Hello Guest

Optimization suggestions?

  • 0 Replies
  • 112 Views
Optimization suggestions?
« on: March 07, 2021, 09:45:38 »
Hello LWJGL forum,

First time here! I've been modding around in Minecraft for some time now and while the performance i got is decent, i was wondering if i could get a bit more. Any hint would be greatly appreciated!

In tech mods one can store energy in single blocks and that gets dull quickly, so i want to be able to do hydro-energy storage aka a dam. But to get this to a solid performance level i need to go around the render pipeline. And i did: Classic Minecraft tessalation (for my special fake water) happens in my geometry shader and i can render the water level whereever i want it with a uniform.

For this, i collect water blocks in a FloatBuffer separately for each 16x16x16 chunk and if the chunk contains any water the float buffer is dumped into a VBO with corresponding VAO. Whenever a chunk is not displayed any more i reassign the VAO+VBO so i don't need to reallocate the memory. Also each VAO is set up once per VBO and never touched again. VBO updates are done with glBufferSubData.

At render time i sort the chunks, bind the program and set its uniforms once for all draw calls. Then i execute the following code foreach chunk:
(First the back sides and then the front sides for proper alpha blending)
Code: [Select]
GL30.glBindVertexArray(vaoId);
GL11.glCullFace(GL11.GL_FRONT);
GL11.glDrawArrays(GL11.GL_POINTS, 0, numWaterBlocks);

GL11.glCullFace(GL11.GL_BACK);
GL11.glDrawArrays(GL11.GL_POINTS, 0, numWaterBlocks);
GL30.glBindVertexArray(0);

Does anyone know how to speed up this render process? I've picked up the term vao decoupling once. Does that might help here? I also did not find any possibility to batch call different VAOs or different VBOs with the same VAO on identical positions.

Again: Happy for every suggestion.

Cheers,
Sin