Parcourir la source

uniforms / samplers / attributes not set in some cases

Popov72 il y a 5 ans
Parent
commit
62f245997b

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

@@ -98,5 +98,6 @@
 - Fix freeze (infinite loop) when disposing a scene that loaded some specific gLTF files ([Popov72](https://github.com/Popov72)
 
 - Fix submesh recreation when it should not ([Popov72](https://github.com/Popov72)
+- Fix `CustomMaterial` and `PBRCustomMaterial` not setting uniforms / samplers / attributes ([Popov72](https://github.com/Popov72)
 
 ## Breaking changes

+ 7 - 7
materialsLibrary/src/custom/customMaterial.ts

@@ -108,6 +108,13 @@ export class CustomMaterial extends StandardMaterial {
 
     public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]): string {
 
+        if (attributes && this._customAttributes && this._customAttributes.length > 0) {
+            attributes.push(...this._customAttributes);
+        }
+
+        this.ReviewUniform("uniform", uniforms);
+        this.ReviewUniform("sampler", samplers);
+
         if (this._isCreatedShader) {
             return this._createdShaderName;
         }
@@ -116,13 +123,6 @@ export class CustomMaterial extends StandardMaterial {
         CustomMaterial.ShaderIndexer++;
         var name: string = "custom_" + CustomMaterial.ShaderIndexer;
 
-        if (attributes && this._customAttributes && this._customAttributes.length > 0) {
-            attributes.push(...this._customAttributes);
-        }
-
-        this.ReviewUniform("uniform", uniforms);
-        this.ReviewUniform("sampler", samplers);
-
         var fn_afterBind = this._afterBind.bind(this);
         this._afterBind = (m, e) => {
             if (!e) {

+ 7 - 7
materialsLibrary/src/custom/pbrCustomMaterial.ts

@@ -104,6 +104,13 @@ export class PBRCustomMaterial extends PBRMaterial {
 
     public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]): string {
 
+        if (attributes && this._customAttributes && this._customAttributes.length > 0) {
+            attributes.push(...this._customAttributes);
+        }
+
+        this.ReviewUniform("uniform", uniforms);
+        this.ReviewUniform("sampler", samplers);
+
         if (this._isCreatedShader) {
             return this._createdShaderName;
         }
@@ -112,13 +119,6 @@ export class PBRCustomMaterial extends PBRMaterial {
         PBRCustomMaterial.ShaderIndexer++;
         var name: string = "custom_" + PBRCustomMaterial.ShaderIndexer;
 
-        if (attributes && this._customAttributes && this._customAttributes.length > 0) {
-            attributes.push(...this._customAttributes);
-        }
-
-        this.ReviewUniform("uniform", uniforms);
-        this.ReviewUniform("sampler", samplers);
-
         var fn_afterBind = this._afterBind.bind(this);
         this._afterBind = (m, e) => {
             if (!e) {