瀏覽代碼

Fix normal not normalized

Popov72 5 年之前
父節點
當前提交
babb86b6fe
共有 1 個文件被更改,包括 2 次插入2 次删除
  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: [