Browse Source

Merge pull request #6013 from MackeyK24/master

Add getShaderName Function
sebavan 6 years ago
parent
commit
c0e46a33e7
2 changed files with 10 additions and 1 deletions
  1. 1 0
      dist/preview release/what's new.md
  2. 9 1
      src/Materials/PBR/pbrBaseMaterial.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -8,6 +8,7 @@
 - Added [support for AmmoJS](https://doc.babylonjs.com/how_to/using_the_physics_engine) as a physics plugin (Composite objects, motors, joints) ([TrevorDev](https://github.com/TrevorDev))
   - Added support for soft bodies, which are 3D softbody, 2D cloth and 1D rope, in Ammo physics plugin. [Doc](https://doc.babylonjs.com/how_to/soft_bodies) ([JohnK](https://github.com/BabylonJSGuide))
   - Added support for [Convex Hull Impostor][https://github.com/kripken/ammo.js/blob/master/bullet/src/BulletCollision/CollisionShapes/btConvexHullShape.h] using Ammo.js plugin ([MackeyK24](https://github.com/mackeyk24))
+  - Added getShaderName to PBRMaterialBase to allow subclasses to specify custom PBR shaders [MackeyK24](https://github.com/mackeyk24))
 - Added support for [WebXR](https://doc.babylonjs.com/how_to/webxr) ([TrevorDev](https://github.com/TrevorDev))
   - Add customAnimationFrameRequester to allow sessions to hook into engine's render loop ([TrevorDev](https://github.com/TrevorDev))
   - camera customDefaultRenderTarget to allow cameras to render to a custom render target (eg. xr framebuffer) instead of the canvas ([TrevorDev](https://github.com/TrevorDev))

+ 9 - 1
src/Materials/PBR/pbrBaseMaterial.ts

@@ -776,6 +776,14 @@ 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()
@@ -1220,7 +1228,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
         });
 
         var join = defines.toString();
-        return engine.createEffect("pbr", <EffectCreationOptions>{
+        return engine.createEffect(this.getShaderName(), <EffectCreationOptions>{
             attributes: attribs,
             uniformsNames: uniforms,
             uniformBuffersNames: uniformBuffers,