Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 252c021

Browse files
committed
Fix for avoiding division-by-zero cases on iOS/Metal.
On the original code, the XYZ-xyY functions are taking max between 1e-10 to avoid division-by-zero, but it doesn't take effect on iOS/Metal because of rounding errors, then they cause division-by-zero when nearly black colors are given. I pulled them up to 1e-4 because 1e-5 was not enough as far as I tried.
1 parent 1c8828e commit 252c021

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

PostProcessing/Resources/Shaders/ACES.cginc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,13 +620,13 @@ half3 Y_2_linCV(half3 Y, half Ymax, half Ymin)
620620

621621
half3 XYZ_2_xyY(half3 XYZ)
622622
{
623-
half divisor = max(dot(XYZ, (1.0).xxx), 1e-10);
623+
half divisor = max(dot(XYZ, (1.0).xxx), 1e-4);
624624
return half3(XYZ.xy / divisor, XYZ.y);
625625
}
626626

627627
half3 xyY_2_XYZ(half3 xyY)
628628
{
629-
half m = xyY.z / max(xyY.y, 1e-10);
629+
half m = xyY.z / max(xyY.y, 1e-4);
630630
half3 XYZ = half3(xyY.xz, (1.0 - xyY.x - xyY.y));
631631
XYZ.xz *= m;
632632
return XYZ;

0 commit comments

Comments
 (0)