Fix code style

This commit is contained in:
Wojtek Figat
2020-12-21 23:37:28 +01:00
parent d322015e6e
commit 2a29abcc39
13 changed files with 47 additions and 89 deletions

View File

@@ -127,30 +127,21 @@ float AreaLightSpecular(LightData lightData, float roughness, inout float3 toLig
BRANCH
if (lightData.SourceLength > 0)
{
// Energy conservation
float lineAngle = saturate(lightData.SourceLength * invDistToLight);
energy *= m / saturate(m + 0.5 * lineAngle);
// Closest point on line segment to ray
float3 l01 = lightData.Direction * lightData.SourceLength;
float3 l0 = toLight - 0.5 * l01;
float3 l1 = toLight + 0.5 * l01;
float a = Square(lightData.SourceLength);
float b = dot(r, l01);
float t = saturate(dot(l0, b * r - l01) / (a - b * b));
toLight = l0 + t * l01;
}
BRANCH
if (lightData.SourceRadius > 0)
{
// Energy conservation
float sphereAngle = saturate(lightData.SourceRadius * invDistToLight);
energy *= Square(m / saturate(m + 0.5 * sphereAngle));
// Closest point on sphere to ray
float3 closestPointOnRay = dot(toLight, r) * r;
float3 centerToRay = closestPointOnRay - toLight;
float3 closestPointOnSphere = toLight + centerToRay * saturate(lightData.SourceRadius * rsqrt(dot(centerToRay, centerToRay)));