Handmade Hero»Forums»Code
Oliver Marsh
179 posts / 1 project
A budding game developer and programmer
Drawing multiple textures in one draw call

I was wondering how Casey ended up drawing multiple textures in one draw call? I remember he talked about that texture atlases are just one way of doing it, but never saw what Casey did.

My only understanding of how to do it is use a texture array and have an index for each instance. Is this a reasonable solution? What's the usual approach without using texture atlases? Are bindless textures relate to this?

Thanks 🙂

Mārtiņš Možeiko
2265 posts / 2 projects
Drawing multiple textures in one draw call
Edited by Mārtiņš Možeiko on

He's doing array texture for that.

Alternative to that is doing texture atlas - then you need to be careful with padding & mipmaps. If you don't need mipmaps, then things are simple - do 1 extra padding if you're doing linear filtering (or do simple math in shader to clamp to item borders).

Bindless textures also help if you're ok with non-core extension, and not supporting older GPU's / driver versions. It allows to pass handle to texture inside vertex attribute or vertex buffer or any other kind of data structure you have in UBO/SSBO or otherwise. This way you can use different texture per each element you draw in the same draw call.

Oliver Marsh
179 posts / 1 project
A budding game developer and programmer
Drawing multiple textures in one draw call
Edited by Oliver Marsh on

Thanks Martins, is the texture array Casey used sampler2darray?

Mārtiņš Možeiko
2265 posts / 2 projects
Drawing multiple textures in one draw call
Edited by Mārtiņš Možeiko on
Replying to OliverMarsh (#25748)

Yes. You need to use sampler2DArray for array texture.