瀏覽代碼

Small roughness tweek under area lights

dragonCASTjosh 8 年之前
父節點
當前提交
417ad2966a
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      bin/CoreData/Shaders/HLSL/PBR.hlsl

+ 4 - 2
bin/CoreData/Shaders/HLSL/PBR.hlsl

@@ -13,6 +13,8 @@
         float specEnergy = 1.0f;
         float specEnergy = 1.0f;
 
 
         float radius = cLightRad / 100;
         float radius = cLightRad / 100;
+        float rough2 = max(roughness, 0.08);
+        rough2 *= rough2;
 
 
         float radius2           = radius * radius;
         float radius2           = radius * radius;
         float distToLightSqrd   = dot(lightVec,lightVec);
         float distToLightSqrd   = dot(lightVec,lightVec);
@@ -30,7 +32,7 @@
 
 
         float sphereAngle = saturate(radius * invDistToLight);
         float sphereAngle = saturate(radius * invDistToLight);
                             
                             
-        specEnergy = (roughness * roughness) / saturate((roughness * roughness) + 0.5f * sphereAngle);
+        specEnergy = rough2 / (rough2 + 0.5f * sphereAngle);
         specEnergy *= specEnergy;                           
         specEnergy *= specEnergy;                           
 
 
         float3 R = 2 * dot(toCamera, normal) * normal - toCamera;
         float3 R = 2 * dot(toCamera, normal) * normal - toCamera;
@@ -96,7 +98,7 @@
         float ndv = saturate(dot(normal, toCamera));
         float ndv = saturate(dot(normal, toCamera));
 
 
         float distL      = length(closestPoint);
         float distL      = length(closestPoint);
-        float alpha      = roughness * roughness;
+        float alpha      = max(roughness, 0.08) * max(roughness, 0.08);
         float alphaPrime = saturate(radius / (distL * 2.0) + alpha);
         float alphaPrime = saturate(radius / (distL * 2.0) + alpha);
 
 
        const float3 diffuseFactor = Diffuse(diffColor, roughness, ndv, ndl, hdv)  * ndl;
        const float3 diffuseFactor = Diffuse(diffColor, roughness, ndv, ndl, hdv)  * ndl;