Skip to content

Instantly share code, notes, and snippets.

@iomeone
Forked from ruby0x1/msdf.glsl
Created November 19, 2019 09:22
Show Gist options
  • Save iomeone/238eab1444253680e7def0d8030ae22f to your computer and use it in GitHub Desktop.
Save iomeone/238eab1444253680e7def0d8030ae22f 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