3d Textures

Started by
2 comments, last by Ashaman73 13 years, 3 months ago
Would storing the textures for a 2d game be faster using a 3d texture rather than storing each tile(32x32 for example) as a individual image in the GPUs memory?

I've tried using atlases to store my tiles but I ran into problems with texel bleeding so at the moment I'm just using intermediate mode.

I havent really found any tutorials that deal with 3d textures but I'm assuming that I could insert each tile into the 3d texture at different z levels then when I'm rendering I only have to bind the texture once and set the texture coordinates to the right z level?
Advertisement
1. There is a performance penalty with 3D textures. Perhaps performance doesn't matter if you are just making a simple game.
2. Mipmapping a 3D texture would blend your different layers together.
3. For 2D texture atlas, you need to have a certain amount of padding between the textures. 3 pixels should do it.
4. Yes, z level. It is actually controlled by the r component of the texcoord.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Is there any way to get 3D textures to have linear interpolation or anisotropic filtering without causing the blending of textures?

I was able to quickly implement 3D texturing in my engine and I see what you mean.

Last time I tried to use texture atlases, even with borders(transparent ones, and also 1-2 pixel borders of the same colour as the inner texture) I still got problems with making the tiles seam correctly.
Take a look at texture arrays which are similar to 3d textures but without the mipmapping/blending issues. Thought I would go for a padded atlas too.

This topic is closed to new replies.

Advertisement