summaryrefslogtreecommitdiffstats
path: root/decals.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-06-05 19:42:36 -0700
committeryum <yum.food.vr@gmail.com>2025-06-05 19:42:36 -0700
commit8b7ae8db808d76ddea503f94e142c7d37c1b43d3 (patch)
tree9c60f09943b314d47bd5f8df732465831d5a566d /decals.cginc
parent50b0b6c8b292e966a43fe56c6e0bf0a20c1d5b62 (diff)
more work on fog & c30
Diffstat (limited to 'decals.cginc')
-rw-r--r--decals.cginc10
1 files changed, 9 insertions, 1 deletions
diff --git a/decals.cginc b/decals.cginc
index cd71c73..b4f1151 100644
--- a/decals.cginc
+++ b/decals.cginc
@@ -89,7 +89,15 @@ float4 getDecalColor(DecalParams params, float2 uv) {
float4 sdf_sample = params.mainTex.SampleLevel(linear_repeat_s, uv, 0);
float sd = sdf_sample.r;
sd = params.sdf_invert ? 1 - sd : sd;
- sd = (sd > params.sdf_threshold ? 1 : 0);
+ // The fwidth+smoothstep anti-aliases the glyph outline. See
+ // "Noise is Beautiful" by Gustavson around page 34 for an
+ // explanation of this trick.
+#if 1
+ float step_wd = fwidth(sd) * 0.5;
+ sd = smoothstep(params.sdf_threshold - step_wd, params.sdf_threshold + step_wd, sd);
+#else
+ sd = step(params.sdf_threshold, sd);
+#endif
return params.color * sd;
}