Browse Source

Version bump, example shader update

Viktor Chlumský 8 years ago
parent
commit
208e76c9a1
4 changed files with 8 additions and 5 deletions
  1. 4 1
      README.md
  2. 1 1
      main.cpp
  3. 1 1
      msdfgen-ext.h
  4. 2 2
      msdfgen.h

+ 4 - 1
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);
 }
 ```

+ 1 - 1
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
  *

+ 1 - 1
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
  *

+ 2 - 2
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 {