|
@@ -726,6 +726,17 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
|
public readonly sheen = new PBRSheenConfiguration(this._markAllSubMeshesAsTexturesDirty.bind(this));
|
|
|
|
|
|
/**
|
|
|
+ * Custom callback helping to override the default shader used in the material.
|
|
|
+ * @param shaderName The default shader name.
|
|
|
+ * @param uniforms The default shader uniforms.
|
|
|
+ * @param uniformBuffers The default shader uniform buffers.
|
|
|
+ * @param samplers The default shader samplers.
|
|
|
+ * @param defines The default shader defines.
|
|
|
+ * @returns string - The custom shader name to use for the material
|
|
|
+ */
|
|
|
+ public customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
|
|
|
+
|
|
|
+ /**
|
|
|
* Instantiates a new PBRMaterial instance.
|
|
|
*
|
|
|
* @param name The material name
|
|
@@ -777,14 +788,6 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Gets the name of the material shader.
|
|
|
- * @returns - string that specifies the shader program of the material.
|
|
|
- */
|
|
|
- public getShaderName(): string {
|
|
|
- return "pbr";
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
|
|
|
*/
|
|
|
@serialize()
|
|
@@ -1182,6 +1185,8 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
|
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
|
|
MaterialHelper.PrepareAttributesForMorphTargets(attribs, mesh, defines);
|
|
|
|
|
|
+ var shaderName = "pbr";
|
|
|
+
|
|
|
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "visibility", "vReflectionColor",
|
|
|
"vFogInfos", "vFogColor", "pointSize",
|
|
|
"vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
|
|
@@ -1228,8 +1233,12 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
|
maxSimultaneousLights: this._maxSimultaneousLights
|
|
|
});
|
|
|
|
|
|
+ if (this.customShaderNameResolve) {
|
|
|
+ shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
|
|
|
+ }
|
|
|
+
|
|
|
var join = defines.toString();
|
|
|
- return engine.createEffect(this.getShaderName(), <EffectCreationOptions>{
|
|
|
+ return engine.createEffect(shaderName, <EffectCreationOptions>{
|
|
|
attributes: attribs,
|
|
|
uniformsNames: uniforms,
|
|
|
uniformBuffersNames: uniformBuffers,
|