Textures - limitation?

Hello all, I am creating objects and assign textures like this:

        QFileInfo textureFilename(validPathToTextureFile);
        if (textureFilename.exists())
            TCollection_AsciiString aFile(textureFilename.absoluteFilePath().toStdString().c_str());

This works great to a certain amount (~20 - see attached picture) of objects and when this limit is reached no textures are shown on the new ones anymore.

Is there a parameter to give some memory to textures or so? I run it on a nvidia-rtx with plenty of memory.


Kirill Gavrilov's picture

I'm curios what kind of limit you may hit here - 20 doesn't look like a big number to me (as long as this is not 16384x16384 images easily occupying tremendous amount of memory). Practically speaking, OpenGL doesn't normally fail for 64-bit applications due to GPU memory limits - instead, rendering becomes just painfully too slow.

As for your screenshot, I don't see 20 textures there, only a couple. When you assign textures to presentation like that, each presentation would load a copy. This is not what you normally expect when mapping the same texture to many objects. To do this in optimal way, it is better creating a single Graphic3d_Texture2D instance and reuse it across presentations, or utilize implicit sharing mechanism based on unique texture id (Graphic3d_TextureRoot::GetId()).

For instance, when displaying an XCAF document using XCAFPrs_AISObject, it creates XCAFPrs_Texture/Image_Texture out of visualization styles with texture id generated from file name.

Daniel Duesentrieb's picture

Thanks Kyrill, it works perfect now!

I read somewhere that AIS_TextureShape is obsolete and changed m_aisDisplayfrom AIS_TextureShape to AIS_Shape

m_texture = OccGraphics::instance()->texture();
m_aisDisplay->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn (true);
m_aisDisplay->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (m_texture);

Getting the texture from a single instance and all seems to work now.

Thanks again - you made my day (again)