Hi,
What would be the best way to make the loaded geometries use my own material?
In my game I load textured models from .obj files provided by user. The OBJLoader
by default create materials based on Lighting.j3md
definition.
I’m creating my custom extension of Lighting.j3md
(it will contain all the parameters of Lighting.j3md
but I want to introduce some modifications into the fragment shaders used by this material definition).
I can probably iterate all geometries, and replace their materials with instances of my material class, and then copy all the values from materials created by OBJLoader
. I believe such approach was taken by someone succesfully here [Solved] How to change a Material's MatDef with code? (although I’m not yet sure what is the render-state, so I’m kinda reluctant, until I find out )
The MTLLoader
class doesn’t seem to provide any nice way for me to define which Material
class I want to use, but I could extend this class and override one method to fix that. However, I’m not sure how to alter the default behaviour of AssetManager
so that for all .mtl
files it is my custom MTLLoader
derived class that loads them? Is there a good way to do it?
In the future I might also want to do similar thing for .gltf models, which use yet another material by default.
Any advice how to proceed?
cheers, Elg’