浏览代码

Fix crash in PBR with clearcoat

Popov72 4 年之前
父节点
当前提交
33d3e002d1

+ 2 - 2
src/Engines/Processors/shaderCodeInliner.ts

@@ -425,7 +425,7 @@ export class ShaderCodeInliner {
                     this._sourceCode = partBefore + type + " " + retParamName + ";\n" + funcBody + "\n" + partBetween + retParamName + partAfter;
 
                     if (this.debug) {
-                        console.log(`Replace function call by code. Function '${name}' (type=${type}). injectDeclarationIndex=${injectDeclarationIndex}`);
+                        console.log(`Replace function call by code. Function '${name}' (type=${type}). injectDeclarationIndex=${injectDeclarationIndex}, call parameters=${paramNames}`);
                     }
                 } else {
                     // simple case where the return value of the function is "void"
@@ -434,7 +434,7 @@ export class ShaderCodeInliner {
                     startIndex += funcBody.length - (callParamsEndIndex + 1 - functionCallIndex);
 
                     if (this.debug) {
-                        console.log(`Replace function call by code. Function '${name}' (type=${type}). functionCallIndex=${functionCallIndex}`);
+                        console.log(`Replace function call by code. Function '${name}' (type=${type}). functionCallIndex=${functionCallIndex}, call parameters=${paramNames}`);
                     }
                 }
 

+ 3 - 0
src/Materials/Node/Blocks/PBR/clearCoatBlock.ts

@@ -313,6 +313,9 @@ export class ClearCoatBlock extends NodeMaterialBlock {
                     ambientMonochrome,
                 #endif
             #endif
+            #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
+                (gl_FrontFacing ? 1. : -1.),
+            #endif
                 clearcoatOut
             );
         #else

+ 3 - 0
src/Shaders/pbr.fragment.fx

@@ -422,6 +422,9 @@ void main(void) {
                 ambientMonochrome,
             #endif
         #endif
+        #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
+            (gl_FrontFacing ? 1. : -1.),
+        #endif
             clearcoatOut
         );
     #else