summaryrefslogtreecommitdiffstats
path: root/pbr.cginc
diff options
context:
space:
mode:
Diffstat (limited to 'pbr.cginc')
-rw-r--r--pbr.cginc17
1 files changed, 16 insertions, 1 deletions
diff --git a/pbr.cginc b/pbr.cginc
index b7ed27d..6cc317d 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -291,7 +291,22 @@ float4 getLitColor(
#if defined(_CLEARCOAT)
// Direct lighting
- float cc_mask = _Clearcoat_Mask.SampleGrad(linear_repeat_s, i.uv, ddx(i.uv.x), ddy(i.uv.y));
+ // TODO add keywords to optimize away mask samples when not used
+ float cc_mask = 1;
+#if defined(_CLEARCOAT_MASK)
+ float cc_mask_tmp = _Clearcoat_Mask.SampleGrad(linear_repeat_s, i.uv, ddx(i.uv.x), ddy(i.uv.y));
+ if (_Clearcoat_Mask_Invert) {
+ cc_mask_tmp = 1 - cc_mask_tmp;
+ }
+ cc_mask *= cc_mask_tmp;
+#endif
+#if defined(_CLEARCOAT_MASK2)
+ float cc_mask2_tmp = _Clearcoat_Mask2.SampleGrad(linear_repeat_s, i.uv, ddx(i.uv.x), ddy(i.uv.y));
+ if (_Clearcoat_Mask_Invert) {
+ cc_mask2_tmp = 1 - cc_mask2_tmp;
+ }
+ cc_mask *= cc_mask2_tmp;
+#endif
{
float3 cc_L = direct_light.dir;
half3 cc_H = Unity_SafeNormalize(cc_L + view_dir);