Yo @Deltakosh … Can we please give the PBRMaterialBase as shader name property so we can subclass a PBR Shader and just have a custom pbr.fragment.fx and vertex.fx that we loaded in into the shaderstore.
I have to make a Terrain Splatmap shader for PBR Metallic and Specular as well as Standard materials… I will use the same texture properties but i just to apply my tweeks to the glsl shaders…
If we add a Shader name property then we can easily go
class MyCustomPBR extends BABYLON.PBRMaterial {
public constructor(...) {
this.shaderName = "my_pbr";
}
and have the easiest Custom PBR Shaders Ever… The Same thing with StandardMaterial.
And all we really have to do is change one call from using a hard coded “pbr” in the create effect at the end of the PBRMaterialBase _prepareEffect function:
return engine.createEffect("pbr", <EffectCreationOptions>{
attributes: attribs,
uniformsNames: uniforms,
uniformBuffersNames: uniformBuffers,
samplers: samplers,
defines: join,
fallbacks: fallbacks,
onCompiled: onCompiled,
onError: onError,
indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
}, engine);
we add a protected shaderName to the PBRMaterialClass that our SUBCLASSES can set on construction
protected shaderName:string = "pbr";
and just use that for the createEffect call:
return engine.createEffect(this.shaderName, <EffectCreationOptions>{
attributes: attribs,
uniformsNames: uniforms,
uniformBuffersNames: uniformBuffers,
samplers: samplers,
defines: join,
fallbacks: fallbacks,
onCompiled: onCompiled,
onError: onError,
indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
}, engine);
That should not negatively impact the codebase but give us the ability to write custom shaders WITHOUT having to COPY the whole PBR set of classes and changing the name EVERYWHERE just to supply a custom fragment and vertex program name to use for MY MATERIAL subclass…
What do think… PLEASE SAY YES…