diff options
| author | yum <yum.food.vr@gmail.com> | 2026-03-24 19:14:44 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-03-24 19:14:44 -0700 |
| commit | a5ac8d1093e0d54b7e2563eb3ea120e0e792481f (patch) | |
| tree | bead2b1a9aeb96c06468918d2be1013bf4ffc56e /ssfd.cginc | |
| parent | 58a8ad92f766baddb2c832597a43088def456d82 (diff) | |
Try to avoid NaN in dominant direction calculation
Diffstat (limited to 'ssfd.cginc')
| -rw-r--r-- | ssfd.cginc | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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 |
