瀏覽代碼

Merge pull request #7673 from Popov72/pbr-fix-linearspecularreflection

Fix bug in PBR shader when reflectionTexture.linearSpecularLOD=true
David Catuhe 5 年之前
父節點
當前提交
9be6d0c6b8
共有 3 個文件被更改,包括 3 次插入2 次删除
  1. 1 0
      dist/preview release/what's new.md
  2. 1 1
      src/Shaders/ShadersInclude/pbrBRDFFunctions.fx
  3. 1 1
      src/Shaders/pbr.fragment.fx

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

@@ -344,6 +344,7 @@
 - Fix `HDRCubeTexture` construction, `generateHarmonics` was not properly taken into account ([Popov72](https://github.com/Popov72))
 - VideoTexture poster respects invertY ([Sebavan](https://github.com/sebavan/)
 - Fix for bug where round-tripped glTF imported scenes have incorrect light orientation, and duplicated parent nodes ([#7377](https://github.com/BabylonJS/Babylon.js/issues/7377))([drigax](https://github.com/drigax))
+- Fix bug in PBR shader when `reflectionTexture.linearSpecularLOD` is `true`  ([Popov72](https://github.com/Popov72))
 
 ## Breaking changes
 

+ 1 - 1
src/Shaders/ShadersInclude/pbrBRDFFunctions.fx

@@ -99,7 +99,7 @@ float fresnelSchlickGGX(float VdotH, float reflectance0, float reflectance90)
 
 #ifdef CLEARCOAT
     // Knowing ior clear coat is fix for the material
-    // Solving iorbase = 1 + sqrt(fo) / (1 - sqrt(fo)) and f0base = square((iorbase - iorclearcoat) / (iorbase - iorclearcoat))
+    // Solving iorbase = 1 + sqrt(fo) / (1 - sqrt(fo)) and f0base = square((iorbase - iorclearcoat) / (iorbase + iorclearcoat))
     // provide f0base = square(A + B * sqrt(fo)) / (B + A * sqrt(fo))
     // where A = 1 - iorclearcoat
     // and   B = 1 + iorclearcoat

+ 1 - 1
src/Shaders/pbr.fragment.fx

@@ -436,7 +436,7 @@ void main(void) {
         #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
             float reflectionLOD = getLodFromAlphaG(vReflectionMicrosurfaceInfos.x, alphaG, NdotVUnclamped);
         #elif defined(LINEARSPECULARREFLECTION)
-            float refractionLOD = getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x, roughness);
+            float reflectionLOD = getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x, roughness);
         #else
             float reflectionLOD = getLodFromAlphaG(vReflectionMicrosurfaceInfos.x, alphaG);
         #endif