Page 1 of 1

16 textures

Posted: Mon Oct 24, 2011 5:28 pm
by Valmond
Hi all!

Back in the 'ol Irrlich 1.6 days you could quite easily change the 4-texture limit to 16 textures.
With the 1.7 I can only use 8 textures, does anyone have a 'hack' for even more (I'd upgrade to a more
recent Irrlicht if that is needed)?

Thanks!

Valmond

Re: 16 textures

Posted: Mon Oct 24, 2011 9:21 pm
by hybrid
There was never the possibility to use 16 textures. Simply because this requires a different texture access and enabling scheme. And that was never used in Irrlicht so far. So it was always just the fixed pipeline texture max. Before 1.7 you usually got problems with texture matrices above 4 textures, though. This is now fixed.

Re: 16 textures

Posted: Mon Oct 24, 2011 10:59 pm
by griffin2000
One thing I notice OpenGL driver is that I needed to change how MaxSupportedTextures is set up in the COpenGLExtensionHandler() ctor. Currently its:

Code: Select all

        if (Version>102 || FeatureAvailable[IRR_ARB_multitexture])
        {
                glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num);
                MaxSupportedTextures=static_cast<u8>(num);
        }
Actually GL_MAX_TEXTURE_UNITS will always return 4 according to the GL spec, to actually work out how many textures you can have in one shader you need to change this to:

Code: Select all

        if (Version>102 || FeatureAvailable[IRR_ARB_multitexture])
        {
                glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &num);
                MaxSupportedTextures=static_cast<u8>(num);
        }

Re: 16 textures

Posted: Tue Oct 25, 2011 8:53 am
by hybrid
Unless this was changed in a very recent change of the GL specs, the method will not always return four. It will return at least 1. And it will return the number of maximally supported texture units in the fixed function pipeline. This is usually 6-8, but some drivers chose to return only 4 even though they support much more for the shader pipeline. The full specs are:
GL_MAX_TEXTURE_UNITS

params returns a single value indicating the number of conventional
texture units supported. Each conventional texture unit includes both a texture coordinate set
and a texture image unit. Conventional texture units may be used for fixed-function (non-shader)
rendering. The value must be at least 2. Additional texture coordinate sets and texture
image units may be accessed from vertex and fragment shaders.
See glActiveTexture and
glClientActiveTexture.
Please note that this is a more recent OpenGL version, which has multi-texturing supported by default. Of course this means that you will get at least 2 supported textures.

You're of course right in that we'd need a check for the texture_image units as well, and provide some way to handle these textures. But this is not yet implemented, so you have to live with the fixed functions maximum for now.