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

MSDF fonts perform pre-multiplied alpha, standard fonts don't #199

Closed
ZigZaggh opened this issue Mar 27, 2021 · 7 comments
Closed

MSDF fonts perform pre-multiplied alpha, standard fonts don't #199

ZigZaggh opened this issue Mar 27, 2021 · 7 comments
Labels
bug 😅 Juju did a bad thing

Comments

@ZigZaggh
Copy link

Hi I was working with the MSDF fonts and ran in to ".blend(colour, alpha)" not working as expected, I tested with a "normal" font, and that works.

It looks like it just blends with Black not matter what color you are setting.

I'm testing on Windows, with the latest stable GMS IDE and Runtime version, Scribble version 7.1.2pre002.

Sincerely

@ZigZaggh ZigZaggh changed the title Blending with MSDF font not working Blending with MSDF fonts not working Mar 27, 2021
@JujuAdams
Copy link
Owner

Could you show me what code you're using please?

@ZigZaggh
Copy link
Author

ZigZaggh commented Mar 27, 2021

Just for testing I'm doing the following:

scribble("[Font12][c_red]88888").blend(c_white, 1).draw(500, 240);
scribble("[Font12][c_red]88888").blend(c_white, 0.75).draw(500, 280);
scribble("[Font12][c_red]88888").blend(c_white, 0.5).draw(500, 320);
scribble("[Font12][c_red]88888").blend(c_white, 0.25).draw(500, 360);

scribble("[MSDF_Roboto_Medium][c_red]88888").blend(c_white, 1).draw(600, 240);
scribble("[MSDF_Roboto_Medium][c_red]88888").blend(c_white, 0.75).draw(600, 280);
scribble("[MSDF_Roboto_Medium][c_red]88888").blend(c_white, 0.5).draw(600, 320);
scribble("[MSDF_Roboto_Medium][c_red]88888").blend(c_white, 0.25).draw(600, 360);

And the attached picture is showing the result, left column "normal" font right is MSDF font.
Screenshot 2021-03-27 114855

@JujuAdams JujuAdams added bug 😅 Juju did a bad thing and removed help me! 😨 Argh labels Mar 27, 2021
@JujuAdams JujuAdams changed the title Blending with MSDF fonts not working MSDF fonts perform pre-multified alpha, standard fonts don't Mar 27, 2021
@JujuAdams JujuAdams changed the title MSDF fonts perform pre-multified alpha, standard fonts don't MSDF fonts perform pre-multiplied alpha, standard fonts don't Mar 27, 2021
@JujuAdams
Copy link
Owner

Huh, for some reason MSDF fonts are doing pre-multiplied alpha. Not sure why I did that! Easy fix though - comment out line 54 in the fragment shader for __shd_scribble_msdf. I'll put out a release with that in at some point

@ZigZaggh
Copy link
Author

If I comment out the line 54 I just get no blending at all!?
I'm not much into shaders, so I'm not completely sure what is happening :)

@JujuAdams
Copy link
Owner

JujuAdams commented Mar 27, 2021

narrows eyes

Yeah ok lol that makes sense. Try gl_FragColor.a *= v_vColour.a; instead.

@ZigZaggh
Copy link
Author

Works perfectly, thank you so much for the fast reply Juju 👌 😃

@JujuAdams
Copy link
Owner

Implemented publicly for v7.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 😅 Juju did a bad thing
Projects
None yet
Development

No branches or pull requests

2 participants