Skip to content

Instantly share code, notes, and snippets.

@ruby0x1
Last active February 13, 2022 05:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ruby0x1/d929ccabf4c81e289fde03b5e7e360c6 to your computer and use it in GitHub Desktop.
Save ruby0x1/d929ccabf4c81e289fde03b5e7e360c6 to your computer and use it in GitHub Desktop.
simple MSDF shader
float r = sample.r;
float g = sample.g;
float b = sample.b;
float median = max(min(r, g), min(max(r, g), b));
float signed_dist = median - 0.5;
float d = fwidth(signed_dist);
float opacity = smoothstep(-d, d, signed_dist);
//apply opacity to final alpha
color.a *= opacity;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment