Jelajahi Sumber

Possible fix for PBR Artifacts

dragonCASTjosh 8 tahun lalu
induk
melakukan
45d619e80c
2 mengubah file dengan 3 tambahan dan 2 penghapusan
  1. 1 1
      bin/CoreData/Shaders/HLSL/BRDF.hlsl
  2. 2 1
      bin/CoreData/Shaders/HLSL/IBL.hlsl

+ 1 - 1
bin/CoreData/Shaders/HLSL/BRDF.hlsl

@@ -26,7 +26,7 @@
     //VdotH     = the dot product of the camera view direction and the half vector 
     //VdotH     = the dot product of the camera view direction and the half vector 
     float3 Fresnel(float3 specular, float VdotH)
     float3 Fresnel(float3 specular, float VdotH)
     {
     {
-        return SchlickFresnel(specular, VdotH);
+        return SchlickGaussianFresnel(specular, VdotH);
     }
     }
 
 
     // Smith GGX corrected Visibility
     // Smith GGX corrected Visibility

+ 2 - 1
bin/CoreData/Shaders/HLSL/IBL.hlsl

@@ -229,7 +229,7 @@
 
 
     float GetMipFromRoughness(float roughness)
     float GetMipFromRoughness(float roughness)
     {
     {
-        float Level = 3 - 1.15 * log2( roughness );
+        float Level = 3 - 1.15 * log2(roughness);
         return 9.0 - 1 - Level;
         return 9.0 - 1 - Level;
     }
     }
 
 
@@ -264,6 +264,7 @@
     ///     ambientOcclusion: ambient occlusion
     ///     ambientOcclusion: ambient occlusion
     float3 ImageBasedLighting(in float3 reflectVec, in float3 tangent, in float3 bitangent, in float3 wsNormal, in float3 toCamera, in float3 diffColor, in float3 specColor, in float roughness, inout float3 reflectionCubeColor)
     float3 ImageBasedLighting(in float3 reflectVec, in float3 tangent, in float3 bitangent, in float3 wsNormal, in float3 toCamera, in float3 diffColor, in float3 specColor, in float roughness, inout float3 reflectionCubeColor)
     { 
     { 
+        roughness = max(roughness, 0.08);
         reflectVec = GetSpecularDominantDir(wsNormal, reflectVec, roughness);
         reflectVec = GetSpecularDominantDir(wsNormal, reflectVec, roughness);
         const float ndv = saturate(dot(-toCamera, wsNormal));
         const float ndv = saturate(dot(-toCamera, wsNormal));