Menu

#138 More textures for shaders

closed
video (38)
6
2012-06-24
2011-12-09
M Gagnon
No

Hi,

I have first asked nicely on the forum, but not getting any reply from the core devs I'm getting more aggressive and am posting here ;)

when writing shaders, having _IRR_MATERIAL_MAX_TEXTURES_ at 4 is quite limitating. An example, for Supertuxkart I have an artist that would like to use 4 different terrain textures with splatting textures plus a lightmap, which would require 6 textures. I did my best to analyse the code and it seems to me that bumping the number of textures would be quite harmless; it would add a very minor memory and CPU increase to materials handling and, as far as I can tell, would have no other effect for as long as a project does not actually make use of the additional textures.

According to http://www.gamedev.net/topic/444809-use-more-than-4-textures-with-glsl/ , it's common for GPUs to support 16 textures when the OpenGL extensions are used (and I checked the irrlicht code, the multitexture extensions are indeed used).

Now I'm aware that we could just make our own irrlicht build, which is no problem on Windows and OSX. But on Linux distributions generally like to ship their own binaries and in this case they use the default settings.

Discussion

  • M Gagnon

    M Gagnon - 2011-12-26

    and now, I am appending a real bug to this ticket. GL_MAX_TEXTURE_UNITS is used to retrieve the maximum number of textures for BOTH multitexturing and shader textures. This is however incorrect according to http://www.gamedev.net/topic/544990-gl_max_texture_units-is-wrong/page__view__findpost__p__4513455 and also according to http://www.opengl.org/wiki/Texture_Sampling. According to these websites, GL_MAX_TEXTURE_IMAGE_UNITS should be used to retrieve the max number of textures for shaders. This can be quite limitating since many modern GPUs seem to actually drop multitexturing support in favor of shaders, for instance a guy in the team has a GPU that supports 96 shader textures with his very high-end GPU, but only 4 multitexturing textures.

    This definitely needs to be corrected since this limits the ability to use shaders in irrlicht

     
  • Christian Stehno

    • labels: --> video
     
  • Christian Stehno

    The problem is that we have to split texures and texture layer settings with this change. Each texture over the MAX_TEXTURES value for OpenGL does not support the usual things like automatically enabled texture coords etc. So we have to find a good way to let the user know where the automatic things stop and mayb make other things happen automatically upon shader usage.

     
  • M Gagnon

    M Gagnon - 2012-01-05

    Hi hybrid,

    I'm not sure I understand your point regarding texture coords, because irrlicht at this point supports only 2 layers of texture coords and that's quite clear from the docs. So atm irrlicht supports 2 layers with setttings and 2 more without settings. My request is to change that to 2 layers with setting and 6 more without settings. As far as I can tell this isn't more confusing than before, you just get more without settings.

     
  • Christian Stehno

    Sorry, the text should read texture clamp (maybe I was up to writing texture coord clamp). Actually I was even up for the texture matrix originally. It's basically every setting from ITextureLayer, which is not available to fixed pipeline anymore above the MAX_TEXTURES value. It might be enough to have a flag for fixed function and for shader textures, but I'm not sure. Simply exchanging the values is not possible, as we still have a major part running in fixed function pipeline.

     
  • Christian Stehno

    I am currently working on the texture pointer bug in OpenGL, but will come back to this one later on. Should still be possible to make it into 1.8

     
  • Christian Stehno

    • priority: 5 --> 6
     
  • M Gagnon

    M Gagnon - 2012-04-25

    Actually, taking a further look at it, it really seems that OpenGL does *not* tell the difference between Multitexturing and Shader textures - it's just that when you use multitexturing there may be less textures accessible. Otherwise the API seems to be the same, shader textures are set using (ext)GlActiveTexture, just like the current code already does for multitexturing. So I am not an OpenGL expert, but I *think* you can just replace GL_MAX_TEXTURE_UNITS with GL_MAX_TEXTURE_IMAGE_UNITS and everything will automagically work. As far as I can tell it's really all the same API, it's just that MT won't be able to make use of all textures you set

     
  • Christian Stehno

    Added to latest SVN revision. It will be part of the next
    stable Irrlicht release.

     
  • Christian Stehno

    Ok, the values of maximal textures should be ok now. However, the configurations may not properly work now for textures over the fixed function texture count. We will have to test and examine this some more.
    I started to allow more texture calls manually, thus supporting all 16 (or whatever) textures now by calling setTexture manually, ignoring the limitation set in IrrCompileConfig. The latter is just setting the number of texture configs now, which are automatically set by materials.
    the problem is basically, that texture image units and texture objects are not exactly the same, and stored differently in the drivers. But for a first try it should be ok now.

     
  • Christian Stehno

    • assigned_to: nobody --> hybrid
    • status: open --> closed
     

Log in to post a comment.