浏览代码

Merge pull request #9723 from MackeyK24/master

PBR Custom Material
sebavan 4 年之前
父节点
当前提交
f3922706c1
共有 2 个文件被更改,包括 18 次插入7 次删除
  1. 6 6
      Playground/libs/babylon.manager.js
  2. 12 1
      materialsLibrary/src/custom/pbrCustomMaterial.ts

文件差异内容过多而无法显示
+ 6 - 6
Playground/libs/babylon.manager.js


+ 12 - 1
materialsLibrary/src/custom/pbrCustomMaterial.ts

@@ -109,7 +109,18 @@ export class PBRCustomMaterial extends PBRMaterial {
         return arr;
     }
 
-    public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]): string {
+    public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string {
+        if (options) {
+            options.processFinalCode = (type: string, code: string) => {
+                if (type === "vertex") {
+                    return code;
+                }
+                const sci = new BABYLON.ShaderCodeInliner(code);
+                sci.inlineToken = "#define pbr_inline";
+                sci.processCode();
+                return sci.code;
+            };
+        }
 
         if (attributes && this._customAttributes && this._customAttributes.length > 0) {
             attributes.push(...this._customAttributes);