Browse Source

Fix normal not normalized

Popov72 5 years ago
parent
commit
babb86b6fe
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.ts

+ 2 - 2
src/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.ts

@@ -835,9 +835,9 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
             state.compilationString += `vec3 viewDirectionW = normalize(${this.cameraPosition.associatedVariableName} - ${"v_" + worldPos.associatedVariableName}.xyz);\r\n`;
         }
 
-        state.compilationString += `vec3 geometricNormalW = ${this.worldNormal.associatedVariableName}.xyz;\r\n`;
+        state.compilationString += `vec3 geometricNormalW = normalize(${this.worldNormal.associatedVariableName}.xyz);\r\n`;
 
-        state.compilationString += `vec3 normalW = ${normalShading.isConnected ? normalShading.associatedVariableName + ".xyz" : "geometricNormalW"};\r\n`;
+        state.compilationString += `vec3 normalW = ${normalShading.isConnected ? "normalize(" + normalShading.associatedVariableName + ".xyz)" : "geometricNormalW"};\r\n`;
 
         state.compilationString += state._emitCodeFromInclude("pbrBlockNormalFinal", comments, {
             replaceStrings: [