Landscape by means of 3D-Texture

Hello all. Sorry for my poor english. I use 3D-Texture for creating gradual change of textures (grass into stones, for example). If I don’t use mip-mapping, all is OK. But if I enable mip-mapping, on N-th LOD, my grass, stone, and other layers of 3d-texture mix giving a constant color.
Help me, please!!

Just to be sure, did you provide correctly all the 3D mip LOD levels up to the single texel ?

Yes, I am sure. I provide correctly all of the 3D Mip LOD. If I don’t decrees twice depth of 3D texture, texture doesn’t render. Why?

The mipmap filter operates on all three texture axes. For instance, if your 3D texture is 128x128x8, your mipmap levels will be 64x64x4, 32x32x2, 16x16x1, 8x8x1, 4x4x1, 2x2x1, 1x1x1.

Notice how you lose one of three dimensions at the third mipmap level already, and how the last level is effectively a single constant color. This means that once you reach the lowest mipmap level, the output color is going to be the average color of all the slices in your 3D texture. There is no way around this, since you can’t specify separate minification filters for individual texture coordinate axes.

http://www.delphi3d.net/articles/viewarticle.php?article=terraintex.htm describes an approach that doesn’t suffer from this problem.

– Tom

Wait a second…

Originally posted by evgen-rus61:
Yes, I am sure. I provide correctly all of the 3D Mip LOD. If I don’t decrees twice depth of 3D texture, texture doesn’t render. Why?
Are you saying that it simply turns white if the texture exceeds a certain resolution? In that case you’re probably just out of texture memory. glGetError() will tell you if this is the case. My previous comment still stands, though – the mipmapping will cause your different terrain types to blend together in the distance.

– Tom

May be I don’t understand? But why isn’t it possible to assign an arbitrary resolution for any LOD? Is it a feature of videocard? If so, what for 3d-textures can be used?

But why isn’t it possible to assign an arbitrary resolution for any LOD?
Each LOD is half the resolution, in each dimension, of the previous LOD. This applies to all types of textures. If the level 0 image of a 1D texture is 128 texels, the level 1 image must be 64 texels. The same applies to 2D textures, cubemaps, and 3D textures. The only texture type that doesn’t get this treatment is rectangle textures , which cannot use mipmapping.

Any texture whose mipmap levels do not follow the size requirements is “incomplete”. Page 167 (180 of the PDF) of the OpenGL 1.5 spec says, “If a texture unit… has an invalid or incomplete texture (as defined in section 3.8.10) bound to it, then blending is disabled for that unit…the results of texture blending are undefined.” The real meat is somewhat hidden in the middle of page 151 (page 164 of the PDF), “Level-of-detail numbers proceed from level_base for the original texture array through p=max{n,m,l}+level_base with each unit increate indicating an array of half the dimensions of the previous one as already described.” (emphasis mine)

So, if the sizes of the successive LODs of your texture don’t follow the rules, the implementation is free to draw whatever texel values it wants.