summaryrefslogtreecommitdiffstats
path: root/ssfd.cginc
diff options
context:
space:
mode:
Diffstat (limited to 'ssfd.cginc')
-rw-r--r--ssfd.cginc12
1 files changed, 12 insertions, 0 deletions
diff --git a/ssfd.cginc b/ssfd.cginc
index cc7d304..5d385c6 100644
--- a/ssfd.cginc
+++ b/ssfd.cginc
@@ -54,5 +54,17 @@ float ssfd(float2 uv, float scale, float max_fwidth, float2 uv_offset, texture3D
}
#endif // _SSFD
+void apply_ssfd(v2f i, float2 uv, LightData l, float3 normal, inout float3 albedo) {
+#if defined(_SSFD)
+ float ssfd_mask = ssfd(uv, _SSFD_Scale, _SSFD_Max_Fwidth, 0, _SSFD_Noise);
+ float ssfd_mask_fw = fwidth(ssfd_mask);
+ // TODO I think anti aliasing is probably broken
+ float light_amount = 1.0 - (dot(l.indirect.diffuse_dominant_dir, normal) * 0.5 + 0.5);
+ float ssfd_threshold = saturate(light_amount + _SSFD_Threshold);
+ ssfd_mask = smoothstep(ssfd_threshold - ssfd_mask_fw * 0.5, ssfd_threshold + ssfd_mask_fw * 0.5, ssfd_mask);
+ albedo += ssfd_mask * _SSFD_Tint.rgb;
+#endif
+}
+
#endif // __SSFD_INC