فهرست منبع

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;
         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) {
         if (attributes && this._customAttributes && this._customAttributes.length > 0) {
             attributes.push(...this._customAttributes);
             attributes.push(...this._customAttributes);