瀏覽代碼

Fix Clear Coat tint without reflection

sebavan 5 年之前
父節點
當前提交
220af806d0
共有 1 個文件被更改,包括 9 次插入9 次删除
  1. 9 9
      src/Shaders/pbr.fragment.fx

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

@@ -688,6 +688,14 @@ void main(void) {
         // The order 1886 page 3.
         float clearCoatNdotV = absEps(clearCoatNdotVUnclamped);
 
+        #ifdef CLEARCOAT_TINT
+            // Used later on in the light fragment and ibl.
+            vec3 clearCoatVRefract = -refract(vPositionW, clearCoatNormalW, vClearCoatRefractionParams.y);
+            // The order 1886 page 3.
+            float clearCoatNdotVRefract = absEps(dot(clearCoatNormalW, clearCoatVRefract));
+            vec3 absorption = vec3(0.);
+        #endif
+
         // Clear Coat Reflection
         #if defined(REFLECTION)
             float clearCoatAlphaG = convertRoughnessToAverageSlope(clearCoatRoughness);
@@ -757,14 +765,6 @@ void main(void) {
                 environmentClearCoatRadiance.rgb = toLinearSpace(environmentClearCoatRadiance.rgb);
             #endif
 
-            #ifdef CLEARCOAT_TINT
-                // Used later on in the light fragment and ibl.
-                vec3 clearCoatVRefract = -refract(vPositionW, clearCoatNormalW, vClearCoatRefractionParams.y);
-                // The order 1886 page 3.
-                float clearCoatNdotVRefract = absEps(dot(clearCoatNormalW, clearCoatVRefract));
-                vec3 absorption = vec3(0.);
-            #endif
-
             // _____________________________ Levels _____________________________________
             environmentClearCoatRadiance.rgb *= vReflectionInfos.x;
             environmentClearCoatRadiance.rgb *= vReflectionColor.rgb;
@@ -929,7 +929,7 @@ void main(void) {
 
         clearCoatEnvironmentReflectance *= clearCoatIntensity;
 
-        #if defined(REFLECTION) && defined(CLEARCOAT_TINT)
+        #if defined(CLEARCOAT_TINT)
             // NdotL = NdotV in IBL
             absorption = computeClearCoatAbsorption(clearCoatNdotVRefract, clearCoatNdotVRefract, clearCoatColor, clearCoatThickness, clearCoatIntensity);