[2.1] Random texture loading errors when changing assigned material

Problems building or running the engine, queries about how to use features etc.
Post Reply
Boost113
Gnoblar
Posts: 24
Joined: Sun Sep 08, 2013 6:39 pm
x 3

[2.1] Random texture loading errors when changing assigned material

Post by Boost113 » Sat Jan 05, 2019 1:38 pm

Ogre Version: 2.1 (22005:fa50ede7200b)
Operating System: Windows 10, Linux
Render System: OpenGL 3+

We have had a problem in a game, I'm working on, for a long while now where sometimes when we change the material on a mesh, and recreate an Item from it, the textures for that material fail to load.

This is what the log says (I omitted the startup, this happened roughly 10 minutes after starting the program):

Code: Select all

23:32:29: OGRE EXCEPTION(6:FileNotFoundException): Cannot open file: background/Thrive_iceshelf0.png in FileSystemArchive::open at c:\projects\leviathan\thirdparty\ogre\ogremain\src\ogrefilesystem.cpp (line 249)
23:32:29: Error loading texture background/Thrive_iceshelf0.png. Texture layer will be blank. Loading the texture failed with the following exception: OGRE EXCEPTION(6:FileNotFoundException): Cannot open file: background/Thrive_iceshelf0.png in FileSystemArchive::open at c:\projects\leviathan\thirdparty\ogre\ogremain\src\ogrefilesystem.cpp (line 249)
23:32:29: OGRE EXCEPTION(6:FileNotFoundException): Cannot open file: background/Thrive_iceshelf1.png in FileSystemArchive::open at c:\projects\leviathan\thirdparty\ogre\ogremain\src\ogrefilesystem.cpp (line 249)
23:32:29: Error loading texture background/Thrive_iceshelf1.png. Texture layer will be blank. Loading the texture failed with the following exception: OGRE EXCEPTION(6:FileNotFoundException): Cannot open file: background/Thrive_iceshelf1.png in FileSystemArchive::open at c:\projects\leviathan\thirdparty\ogre\ogremain\src\ogrefilesystem.cpp (line 249)
23:32:29: OGRE EXCEPTION(6:FileNotFoundException): Cannot open file: background/Thrive_iceshelf2.png in FileSystemArchive::open at c:\projects\leviathan\thirdparty\ogre\ogremain\src\ogrefilesystem.cpp (line 249)
23:32:29: Error loading texture background/Thrive_iceshelf2.png. Texture layer will be blank. Loading the texture failed with the following exception: OGRE EXCEPTION(6:FileNotFoundException): Cannot open file: background/Thrive_iceshelf2.png in FileSystemArchive::open at c:\projects\leviathan\thirdparty\ogre\ogremain\src\ogrefilesystem.cpp (line 249)
23:32:29: OGRE EXCEPTION(6:FileNotFoundException): Cannot open file: background/Thrive_iceshelf3.png in FileSystemArchive::open at c:\projects\leviathan\thirdparty\ogre\ogremain\src\ogrefilesystem.cpp (line 249)
23:32:29: Error loading texture background/Thrive_iceshelf3.png. Texture layer will be blank. Loading the texture failed with the following exception: OGRE EXCEPTION(6:FileNotFoundException): Cannot open file: background/Thrive_iceshelf3.png in FileSystemArchive::open at c:\projects\leviathan\thirdparty\ogre\ogremain\src\ogrefilesystem.cpp (line 249)
This is the material (most of the time it succeeds displaying fine):

Code: Select all

material Background_Iceshelf
{
    technique
    {
        pass
        {
            // scene_blend alpha_blend
            depth_write off
            depth_check off

            vertex_program_ref Background_VS
            {
            }
            fragment_program_ref Background_PS
            {
            }
            texture_unit 0
            {
            	tex_coord_set 0
                texture background/Thrive_iceshelf0.png 2d gamma
            }
            texture_unit 1
            {
            	tex_coord_set 1
                texture background/Thrive_iceshelf1.png 2d gamma
            }
            texture_unit 2
            {
            	tex_coord_set 2
                texture background/Thrive_iceshelf2.png 2d gamma
            }
            texture_unit 3
            {
            	tex_coord_set 3
                texture background/Thrive_iceshelf3.png 2d gamma
            }
        }
    }
}
Basically in our code we call

Code: Select all

subMesh->setMaterialName(material);
and then delete and create an Item from that mesh and then the texture is the error texture and it stays that way. Sometimes it fixes itself when another material is assigned.

This has happened for me once on Linux and for our Windows based developers and players this has happened many, many times.

The error seems very strange as the files have not changed on disk and nothing that we do in our game should prevent them from being read again.
So I guess maybe there is a bug in the Ogre file loading?

We have been tracking this issue on Github: https://github.com/Revolutionary-Games/ ... issues/639
And we made some changes to reduce the frequency at which the material is changed and the item is recreated and that seems to have made this happen less often.

Here is a screenshot of the single material having all of its layers be the error image:
Image

Any advice would be greatly appreciated.
1 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3877
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 156
Contact:

Re: [2.1] Random texture loading errors when changing assigned material

Post by dark_sylinc » Sun Jan 06, 2019 5:00 pm

Honestly I have no idea why that happens, at all. Sounds like a wrong group error.

Best I can say is that if you can repro the issue, to step in Renderable::setMaterialName and compare the differences in the codepath taken when it works vs when it fails.

Particularly step inside material->load() from Renderable::setMaterial, and get into TextureUnitState::_load.
0 x

Post Reply