Skip to content

Commit

Permalink
[Fix] Fix to area lights (disk, sphere) occasionally generating -Inf …
Browse files Browse the repository at this point in the history
…pixels (#7015)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Oct 9, 2024
1 parent 39c261d commit bbae127
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scene/shader-lib/chunks/lit/frag/ltc.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ float LTC_EvaluateDisk(vec3 N, vec3 V, vec3 P, mat3 Minv, Coords points)
V2 *= sqrt(b);
}
vec3 V3 = cross(V1, V2);
vec3 V3 = normalize(cross(V1, V2));
if (dot(C, V3) < 0.0)
V3 *= -1.0;
Expand Down Expand Up @@ -356,7 +356,7 @@ float LTC_EvaluateDisk(vec3 N, vec3 V, vec3 P, mat3 Minv, Coords points)
float L1 = sqrt(-e2 / e3);
float L2 = sqrt(-e2 / e1);
float formFactor = L1 * L2 * inversesqrt((1.0 + L1 * L1) * (1.0 + L2 * L2));
float formFactor = max(0.0, L1 * L2 * inversesqrt((1.0 + L1 * L1) * (1.0 + L2 * L2)));
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
Expand Down

0 comments on commit bbae127

Please sign in to comment.