Hello,
I am writing my own standard shader for my gltf meshes and I want to be able to apply the shader during mesh load instead of the PBRMaterial normally used by the glTF loader.
I found this snippet inside the glTF loader for babylon:
GLTFLoader.prototype._createDefaultMaterial = function (name, babylonDrawMode) {
var babylonMaterial = new PBRMaterial(name, this._babylonScene);
babylonMaterial.sideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation;
babylonMaterial.fillMode = babylonDrawMode;
babylonMaterial.enableSpecularAntiAliasing = true;
babylonMaterial.useRadianceOverAlpha = !this._parent.transparencyAsCoverage;
babylonMaterial.useSpecularOverAlpha = !this._parent.transparencyAsCoverage;
babylonMaterial.transparencyMode = PBRMaterial.PBRMATERIAL_OPAQUE;
babylonMaterial.metallic = 1;
babylonMaterial.roughness = 1;
return babylonMaterial;
};
This is a perfect point since all I need to do is override that method with something that reads the gltf material and then builds my material instead of the normal PBRMaterial.
However, I can’t figure out how to override this method after creating a GLTF file loader. Right now my code to do this looks like this:
let loader = new GLTFFileLoader();
/* Somehow override the material creation? */
SceneLoader.RegisterPlugin(<any>loader);
If someone has some advice on how I can do this please let me know!