2
\$\begingroup\$

I'm using LibGDX on top of OpenGL and currently my game engine does something along the lines of the following per frame

  1. Bind a terrain texture sprite atlas and a set of transparency masks in another texture atlas
  2. Render terrain tiles using the 2 bound textures to a FBO
  3. Bind a character and item texture sprite atlas
  4. Render characters over the terrain to the same FBO
  5. Bind the same transparency mask atlas and a normal map texture for the terrain
  6. Draw the same terrain tiles' normal map version to a different FBO
  7. Bind the character and item normal map texture atlas
  8. Render character normal maps over the terrain normal map FBO
  9. Bind this normal map FBO as a texture
  10. Render lighting information to a different FBO using the normal map texture information
  11. Bind the diffuse and lighting FBOs as textures
  12. Use these to render the combined final image to the main display

So in summary, each frame I'm binding a total of 9 different textures, one or two at a time.

Should I look into changing my code so all 9 textures are always bound, and the correct one is referenced at the right time? Or is this a reasonable amount of texture binds per frame that isn't going to impact overall performance to a noticable effect? Assume I'm aiming for 60fps and there's a fair amount of other calculations going on per frame.

\$\endgroup\$
1
\$\begingroup\$

From my experience, it's not expensive to bind textures. I have a program that binds about 30 textures per frame and it runs pretty smooth. Since you're using only 9 textures and VBOs on top of that, I imagine your game actually runs very well.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.