Skip to content

Commit 54427d2

Browse files
[PPV2] Fix HLSL 2021 non-scalar logical operations (#8007)
* Fix HLSL 2021 non-scalar ternary condition * Update changelog
1 parent dab9852 commit 54427d2

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Diff for: com.unity.postprocessing/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
### Fixed
1313
- Fixed obsolete FormatUsage error
14+
- Fixed non-scalar logical operation error
1415
- Fixed MSVO to support platforms with limited storage texture support
1516
- Fixed compute based effects not supported on WebGL and Android OpenGL (IN-2999)
1617
- Fixed grid gizmo is visible through geometry when Post Process Layer is enabled (IN-10318)

Diff for: com.unity.postprocessing/PostProcessing/Shaders/ACES.hlsl

+6-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ half3 ACES_to_ACEScc(half3 x)
220220
x = clamp(x, 0.0, HALF_MAX);
221221

222222
// x is clamped to [0, HALF_MAX], skip the <= 0 check
223-
return (x < 0.00003051757) ? (log2(0.00001525878 + x * 0.5) + 9.72) / 17.52 : (log2(x) + 9.72) / 17.52;
223+
return half3((x.x < 0.00003051757) ? (log2(0.00001525878 + x.x * 0.5) + 9.72) / 17.52 : (log2(x.x) + 9.72) / 17.52,
224+
(x.y < 0.00003051757) ? (log2(0.00001525878 + x.y * 0.5) + 9.72) / 17.52 : (log2(x.y) + 9.72) / 17.52,
225+
(x.z < 0.00003051757) ? (log2(0.00001525878 + x.z * 0.5) + 9.72) / 17.52 : (log2(x.z) + 9.72) / 17.52);
224226

225227
/*
226228
return half3(
@@ -678,7 +680,9 @@ half roll_white_fwd(
678680

679681
half3 linear_to_sRGB(half3 x)
680682
{
681-
return (x <= 0.0031308 ? (x * 12.9232102) : 1.055 * pow(x, 1.0 / 2.4) - 0.055);
683+
return half3(x.x <= 0.0031308 ? (x.x * 12.9232102) : 1.055 * pow(x.x, 1.0 / 2.4) - 0.055,
684+
x.y <= 0.0031308 ? (x.y * 12.9232102) : 1.055 * pow(x.y, 1.0 / 2.4) - 0.055,
685+
x.z <= 0.0031308 ? (x.z * 12.9232102) : 1.055 * pow(x.z, 1.0 / 2.4) - 0.055);
682686
}
683687

684688
half3 linear_to_bt1886(half3 x, half gamma, half Lw, half Lb)

Diff for: com.unity.postprocessing/PostProcessing/Shaders/Colors.hlsl

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ half3 SRGBToLinear(half3 c)
179179
#else
180180
half3 linearRGBLo = c / 12.92;
181181
half3 linearRGBHi = PositivePow((c + 0.055) / 1.055, half3(2.4, 2.4, 2.4));
182-
half3 linearRGB = (c <= 0.04045) ? linearRGBLo : linearRGBHi;
182+
half3 linearRGB = half3((c.x <= 0.04045) ? linearRGBLo.x : linearRGBHi.x, (c.y <= 0.04045) ? linearRGBLo.y : linearRGBHi.y, (c.z <= 0.04045) ? linearRGBLo.z : linearRGBHi.z);
183183
return linearRGB;
184184
#endif
185185
}
@@ -212,7 +212,7 @@ half3 LinearToSRGB(half3 c)
212212
#else
213213
half3 sRGBLo = c * 12.92;
214214
half3 sRGBHi = (PositivePow(c, half3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
215-
half3 sRGB = (c <= 0.0031308) ? sRGBLo : sRGBHi;
215+
half3 sRGB = half3((c.x <= 0.0031308) ? sRGBLo.x : sRGBHi.x, (c.y <= 0.0031308) ? sRGBLo.y : sRGBHi.y, (c.z <= 0.0031308) ? sRGBLo.z : sRGBHi.z);
216216
return sRGB;
217217
#endif
218218
}

0 commit comments

Comments
 (0)