1

In my program I have objects with different textures, that are in the same vbo. I cant have an array of samplers in my shaderprogram, so i have to use a texture atlas. I have seen some ways to make a texture atlas out of PNGs, but that would mean that I'll have to load those textures twice. Is there a way to put two textures together in one atlas? For example i have:

id = 1;
width = 32;
height = 32;

and

id = 2;
width = 32
height = 32

I want something like this

int atlas = createTexture(t1.width + t2.width, t1.height + t2.height);
glBindTexture(GL_TEXTURE_2D, atlas)
//add(offset x, y, id)
glAdd(0,0,t1.id);
glAdd(t1.width, t1.height, t2.id);

I am not ooking for a texture packing algorithm! I need a way to create an atlas out of textures loaded to the GPU (OpenGL)

l'arbre
  • 245
  • 1
  • 9
  • So...you are not looking for packing algorithm, but rather a...packing algorithm? More precisely how to implement it on GPU. I would suggest you rephrase your question then. I dont think bringing something like this ojn GPU would benefit you performance-wise because texture packing does not seem very good parallelizable. – wondra Aug 31 '15 at 15:17
  • Ok :), I'm not looking for any algorithm, I just want to know if there is an OpenGL implemented way of putting textures into a texture atlas using only the OpenGL texture ids, without accessing the image buffer – l'arbre Aug 31 '15 at 15:20
  • No. As far as I know, because there is no reason such thing existed - why would anyone who needs performance do on GPU steps that can be easily precomputed offline? There are other techniques discussed in this very famous presentation though. – wondra Aug 31 '15 at 15:28
  • ok, I'll then probably load the textures directly to the atlas! Thanks! – l'arbre Aug 31 '15 at 19:30

0 Answers0