Currently, I have a model loader heavily inspired by the one made in LearnOpenGL, which works fine when loading regular models. I made a simple cube in Blender, exported it as an OBJ and I'm able to load the cube with Assimp just fine. The problem is that I want to be able to render this same cube model with different textures. When I load the model with Assimp::Importer::ReadFile I can't change the material used for each mesh, so I'm only able to render the cube with one texture (I could use a material for each mesh, but that's not what I need). I want to know what would be the best way to adapt this model loader to support specifying a texture when loading the model and also keep the current behavior if I need to load a more complex model. These are the options I have considered:
- Add an option to ignore the materials from the scene and handle textures manually, which I don't think would mix well with the current code
- Duplicate the models and create new materials for each model (doable for now, but not really feasible if when there are too many possible combinations)
- Load an OBJ file into a buffer in memory with a placeholder material name after
usemtl, change that name to the material I want and pass the buffer toAssimp::Importer::ReadFileFromMemory. This seems like my the best option so far but still feels kinda weird
I'm not stuck to OBJ, so I could switch to another format if it's necessary. What could I do here?