16 textures

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

16 textures

Post 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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: 16 textures

Post 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.
griffin2000
Posts: 22
Joined: Mon Nov 15, 2010 9:18 pm

Re: 16 textures

Post 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);
        }
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: 16 textures

Post 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.
Post Reply