summaryrefslogtreecommitdiffstats
path: root/decal.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-03-07 16:04:04 -0800
committeryum <yum.food.vr@gmail.com>2026-03-07 16:04:04 -0800
commit94a91e950a02958488b4a223fab8f436d924f7de (patch)
treec6d77ea32de6347f4f0f482bd07984d6c8a189d3 /decal.cginc
parenta4b006dc873906d30f32eef15d730c31bb6bd608 (diff)
Add sdf mode to decals
Diffstat (limited to 'decal.cginc')
-rw-r--r--decal.cginc7
1 files changed, 7 insertions, 0 deletions
diff --git a/decal.cginc b/decal.cginc
index 069a42f..10b2f7a 100644
--- a/decal.cginc
+++ b/decal.cginc
@@ -35,6 +35,13 @@ float2 decal_rotate(float2 uv, float rotation) {
uv -= _Decal##N##_MainTex_ST.zw; \
uv *= _Decal##N##_MainTex_ST.xy; \
float4 albedo = decal_sample(_Decal##N##_MainTex, uv, _Decal##N##_UV_Mode); \
+ if (_Decal##N##_SDF_Enabled) { \
+ float sd = _Decal##N##_SDF_Invert ? 1 - albedo.r : albedo.r; \
+ float d = sd - _Decal##N##_SDF_Threshold; \
+ float w = fwidth(d) * 0.5; \
+ albedo.rgb = sd; \
+ albedo.a = smoothstep(-w, w, d); \
+ } \
albedo *= _Decal##N##_Color; \
albedo.a *= _Decal##N##_Opacity; \
if (_Decal##N##_Mask_Enabled) { \