PDA

View Full Version : How to set up more than 32 Textures?



Freecraft
12-06-2011, 11:27 AM
Hi
The Subject already says it.
I want to use a single VBO to render many cubes (already works). But I want to use many different Textures for each cube! I think the only chance I have is to bind all Textures and send an index through the VBO. And then the shader has to select the right texture (depending on the index). The problem: I'm using much more than 32 Textures (max. active textures). So I have already thought of some solutions:

Texture Array. Problem: My target system doesn't support them! Texture3D. Problem: I think the Texture Layers are filtered linear! Anyway the 3D-texture mixes up with my MipMap-Levels I just bind one big Texture that contains all of my textures and select them with texture coordinates. Problem: If The Texture is rendered bigger than its real size or smaller than 1 pixel, it produces graphic errors, because I use MipMaps and linear filtering.
I'm glad about any suggestion

Thaks in advice!
regards Freecraft

Alfonse Reinheart
12-06-2011, 12:14 PM
Those pretty much are your options. Even high-end DX11 hardware doesn't have more than 16 texture units per shader stage (there are 32 enumerators, but the number of enumerators does not limit the number of textures). So you're not going to get this done by binding a bunch of individual texture objects.

A texture atlas is the only option that will allow you to do what you want on such hardware. Just don't fill in the entire mipmap chain. Also, try putting some empty space between the textures.

Freecraft
12-06-2011, 12:49 PM
Just don't fill in the entire mipmap chain.
I thought that you HAVE to set up the mipmaps down to 1x1 pixel?
I'm using:
glTexParameteri([..] GL_GENERATE_MIPMAP[...]); where do I have to set up the minimal MipMap resolution then? Is there a function like glTexParameteri(GL_MIN_MIPMAP_RESOLUTION);?

carsten neumann
12-06-2011, 01:05 PM
Almost, see the description of GL_TEXTURE_MAX_LEVEL for glTexParameter (http://www.opengl.org/sdk/docs/man4/xhtml/glTexParameter.xml).

Freecraft
12-06-2011, 03:35 PM
Hmmmm
I'm still getting some weird lines beetween the cubes when using the method above.
Isn't there a chance to get this to work with Texture3D?

Alfonse Reinheart
12-06-2011, 05:22 PM
Isn't there a chance to get this to work with Texture3D?

Not with mipmaps.

mhagain
12-06-2011, 05:41 PM
If all of your textures are square, the same size, and if they don't need to repeat, you could pack 6 into the faces of a cubemap.

_arts_
12-07-2011, 09:05 AM
If all of your textures are square, the same size, and if they don't need to repeat, you could pack 6 into the faces of a cubemap.

As a side note to the topic poster, that will imply to use 3D texture coordinates.

Texture atlases are certainly the most interresting things to do here. But I wonder if the "usual" way to do thing, ie, split the single rendering call to many, one for each texture and bind textures, won't be simpler and as fast since it will simplify texture unit management and shaders.

tksuoran
12-07-2011, 09:26 AM
Almost, see the description of GL_TEXTURE_MAX_LEVEL for glTexParameter (http://www.opengl.org/sdk/docs/man4/xhtml/glTexParameter.xml).

In addition to this, you could use a custom, tile aware mipmap generation routine.

Alfonse Reinheart
12-07-2011, 11:37 AM
But I wonder if the "usual" way to do thing, ie, split the single rendering call to many, one for each texture and bind textures, won't be simpler and as fast since it will simplify texture unit management and shaders.

He's drawing "many cubes": I read that as code-language for "Minecraft-clone". So that probably won't work.