Hello everyone Ive been working on optimizing my rendering technique for my 2D game. Right now I render quads in the most modern way I can find using VAO for vertices, indices etc. my rendering looks like this:
public void render(Map<TexturedModel,List<Entity>> entities)
{
for(TexturedModel model : entities.keySet())
{
if(model!= null)
{
prepareTexturedModel(model);
List<Entity> batch = entities.get(model);
for(Entity entity : batch)
{
prepareInstance(entity);
GL11.glDrawElements(GL11.GL_TRIANGLES,model.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT,0);
}
unbindTexturedModel();
}
}
}
PrepareTexturedModel(model) simply binds a texture to the quad, prepareInstance(entity) simply sets transformation matrix and other attributes of the entity to be drawn. Currently the game Im making creates 2D terrain using Simplex Noise and creates a new Quad of width 16 and height 16 and ONLY the quads on screen are rendered so depending on the size of the screen more or less quads will be rendered, which increases or decreases performance respectively.
The image above should show how tiles are separated, the water doesnt show a border because its a collection of 32x32 quads instead of 16x16, just to make the texture look bigger.
My main question is how could I go about optimizing the rendering of those tiles, also just a side not they dont have to be individually editable, one idea I was thinking about was grouping similar tiles together and just making one larger tile and then texturing that, which would decrease the number of vertices but I im stumped on how I could go about doing that as well.
Thanks in advance for you help!