gazebosim / gz-rendering

C++ library designed to provide an abstraction for different rendering engines. It offers unified APIs for creating 3D graphics applications.
https://gazebosim.org
Apache License 2.0
56 stars 51 forks source link

Textures from different models with same base name are reused in Ogre2 #139

Open chapulina opened 4 years ago

chapulina commented 4 years ago

The Ogre 2 plugin is using a texture's file name to uniquely identify each texture. This means that all textures called texture.png will be treated as the same, even if they're in different directories.

For example, all (most?) models in this collection have texture files called texture.png. This means that all models will use the texture from the first model. For example, load this world on ign-gazebo:

world.sdf

``` 3D View false docked ogre2 scene 1.0 1.0 1.0 0.8 0.8 0.8 -6 0 6 0 0.5 0 true 0 0 10 0 0 0 0.8 0.8 0.8 1 0.2 0.2 0.2 1 1000 0.9 0.01 0.001 -0.5 0.1 -0.9 true 0 0 1 0 0 1 100 100 0.8 0.8 0.8 1 0.8 0.8 0.8 1 0.8 0.8 0.8 1 https://fuel.ignitionrobotics.org/1.0/GoogleResearch/models/adizero_F50_TRX_FG_LEA 0 0.5 0 0 0 0 https://fuel.ignitionrobotics.org/1.0/GoogleResearch/models/adistar_boost_m ```

See how the 2nd model uses the 1st model's texture:

image

As a comparison, change ogre2 to ogre in the world, and see that each models loads its own texture:

image

I believe this can be fixed by using the whole texture path instead of just the basename here:

https://github.com/ignitionrobotics/ign-rendering/blob/46bf31837a347955a483de6dab3ad45e42370666/ogre2/src/Ogre2Material.cc#L441-L443


If I remember correctly, this was done on purpose so that all the cave tiles on SubT use the same texture. This should be resolved by allowing models to reference each other's textures (https://github.com/ignitionrobotics/ign-gazebo/issues/343) and then doing that for all the cave tiles.

iche033 commented 4 years ago

If I remember correctly, this was done on purpose so that all the cave tiles on SubT use the same texture. This should be resolved by allowing models to reference each other's textures (ignitionrobotics/ign-gazebo#343) and then doing that for all the cave tiles.

yes that's correct. Unfortunately we found a significant increase in subt's VRAM usage after changing the basename to whole texture path (since each texture is now treated as unique texture) so we were not able to apply the fix at the time.

chapulina commented 3 years ago

With SubT over, I'd like a path forward to closing this issue. Do you think we're ready for the proper fix, @iche033? I think that models that want to reuse textures should already be able to refer to those resources directly on the SDF, right?