Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues rendering MSDF generated with msdf-bmfont #21

Closed
danrossi opened this issue Aug 14, 2017 · 6 comments
Closed

Issues rendering MSDF generated with msdf-bmfont #21

danrossi opened this issue Aug 14, 2017 · 6 comments

Comments

@danrossi
Copy link

I have tested out generating both the Roboto Bold font and custom WebFonts from icomoon. However it seems the MSDF shader provided generates outline for colors and doesn't generate properly.

The msdf shader supplied with msdf-bmfont works ok but its obviously different and like to stick with this one.

fonts

SDF font generation with the tool and using the supplied SDF shader seems to be ok however.

sdffont

Just an example what I'm trying to achieve with the webfont icons also

iconfont

Actual msdf texture looks like this for the Roboto bold font.

roboto-bold 0

I'm not sure who to task first.

@danrossi
Copy link
Author

according to my test. the only difference with the other shader is on this line.

https://github.com/Jam3/three-bmfont-text/blob/master/shaders/msdf.js#L49

if I remove the subtraction it works ie

vec3 sample = texture2D(map, vUv).rgb;

@danrossi
Copy link
Author

I'm not sure what the foreground and background colors are supposed to do in the other shader here but I changed it back to a normal color vector

void main() {
        vec3 sample = texture2D(map, vUv).rgb;
        float sigDist = median(sample.r, sample.g, sample.b) - 0.5;
        float alpha = clamp(sigDist/fwidth(sigDist) + 0.5, 0.0, 1.0);
        gl_FragColor = vec4(color.xyz, alpha * opacity);
      }

@donmccurdy
Copy link
Contributor

donmccurdy commented Feb 10, 2018

Opened a PR adding a negate option for the shader: #24

e.g.

const createTextGeometry = require('three-bmfont-text');
const createMSDFShader = require('three-bmfont-text/shaders/msdf');

createMSDFShader({
  map: texture,
  color: 0x000000,
  negate: false
});

@danrossi
Copy link
Author

Should I close this ?

I have fixed up all issues and refactored to es6 so I can bundle with three.js. my fork is here

https://github.com/danrossi/three-bmfont-text/tree/es6

@danrossi
Copy link
Author

@donmccurdy
Copy link
Contributor

Were there other issues related to msdfgen 1.4, or something else? It would be nice to get PRs in, I think (e.g. A-Frame depends on this library) if @mattdesl would have time to review them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants