From 208e76c9a17da58b0a8b3e6a81528b2360990ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Chlumsk=C3=BD?= Date: Sun, 23 Jul 2017 22:57:13 +0200 Subject: [PATCH] Version bump, example shader update --- README.md | 5 ++++- main.cpp | 2 +- msdfgen-ext.h | 2 +- msdfgen.h | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d9895563..ce800e6d 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ The following is an example GLSL fragment shader including anti-aliasing: in vec2 pos; out vec4 color; uniform sampler2D msdf; +uniform float pxRange; uniform vec4 bgColor; uniform vec4 fgColor; @@ -159,9 +160,11 @@ float median(float r, float g, float b) { } void main() { + vec2 msdfUnit = pxRange/vec2(textureSize(msdf, 0)); vec3 sample = texture(msdf, pos).rgb; float sigDist = median(sample.r, sample.g, sample.b) - 0.5; - float opacity = clamp(sigDist/fwidth(sigDist) + 0.5, 0.0, 1.0); + sigDist *= dot(msdfUnit, 0.5/fwidth(pos)); + float opacity = clamp(sigDist + 0.5, 0.0, 1.0); color = mix(bgColor, fgColor, opacity); } ``` diff --git a/main.cpp b/main.cpp index ef4a4c82..498fc226 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,6 @@ /* - * MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.4 (2017-02-09) - standalone console program + * MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.5 (2017-07-23) - standalone console program * -------------------------------------------------------------------------------------------- * A utility by Viktor Chlumsky, (c) 2014 - 2017 * diff --git a/msdfgen-ext.h b/msdfgen-ext.h index 3b1f82ce..8cb4c9a8 100644 --- a/msdfgen-ext.h +++ b/msdfgen-ext.h @@ -2,7 +2,7 @@ #pragma once /* - * MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.4 (2017-02-09) - extensions + * MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.5 (2017-07-23) - extensions * ---------------------------------------------------------------------------- * A utility by Viktor Chlumsky, (c) 2014 - 2017 * diff --git a/msdfgen.h b/msdfgen.h index a80dde3d..b09392b5 100644 --- a/msdfgen.h +++ b/msdfgen.h @@ -2,7 +2,7 @@ #pragma once /* - * MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.4 (2017-02-09) + * MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.5 (2017-07-23) * --------------------------------------------------------------- * A utility by Viktor Chlumsky, (c) 2014 - 2017 * @@ -24,7 +24,7 @@ #include "core/save-bmp.h" #include "core/shape-description.h" -#define MSDFGEN_VERSION "1.4" +#define MSDFGEN_VERSION "1.5" namespace msdfgen {