GlPortal / RadixEngine

A free and open game engine.
zlib License
148 stars 58 forks source link

Implement large texture for all common small texture #181

Open wow2006 opened 6 years ago

wow2006 commented 6 years ago

In OpenGL world bind and unbind texture takes some time. I like to improve the performance of the game by export the scene to binary format and attach all models texture to one big texture 4k or 8k texture. Use UV of that 4k texture to fetch location at shader using the uniform buffer. @hhirsch @ElementW @JulianThijssen @Geertiebear I am not sure how to add this.

ElementW commented 6 years ago

This is similar to when we would bake lightmaps if we had them. It's a nice idea, you just have to consider color bleeding due to texture sampling interpolation, but spacing the textures out work around that problem. Not sure about the binary export format. While serializing the scenes is a great idea, I don't think exporting stitched textures with it (if that what's you mean) is interesting since it would take up a lot of disk space just for duplicate data that would need re-encoding and doesn't provide faster decoding than loading the textures individually. I'm OK however with exporting data about static geometry and models including having a texture stitch hint so the game doesn't have to compute the texture packing at run-time (especially since IIRC efficient space packing with arbitrary-sized elements is considered NP-hard), and just has to decode & move pixels around before sending the textures to the GPU. There's also ARB_bindless_texture and EXT_direct_state_access, we might want to leverage those instead if available.