From 8b7ae8db808d76ddea503f94e142c7d37c1b43d3 Mon Sep 17 00:00:00 2001 From: yum Date: Thu, 5 Jun 2025 19:42:36 -0700 Subject: more work on fog & c30 --- decals.cginc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'decals.cginc') 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; } -- cgit v1.2.3