engine icon indicating copy to clipboard operation
engine copied to clipboard

Fix unpacking of msdf markup params

Open NewboO opened this issue 2 years ago • 4 comments

Fixes: https://github.com/playcanvas/engine/issues/4595

At the moment, unpacking function of text markup parameters isn't the exact inverse of packing, especially on shadow offset.

Simple example of the issue is to keep default settings for shadow (ie. white text with a black shadow at an offset of (0, 0)) and toggling markup without actually using any tag. It gives something like this (slightly visible on black background, obvious on white blackground): image

This is because an offset of (0, 0) is packed as 127 + 127 * 256 = 32639 but unpacked as ((32639 % 256) / 256 * 2 - 1, (32639 / 256 / 256) * 2 - 1) = (-0.008, -0.004).

This corrected function gives the expected rendering: image

Color unpacking error is barely visible but comes from the same kind of difference (packed by multiplying by 255, unpacked by dividing by 256).

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

NewboO avatar Aug 30 '22 15:08 NewboO

Is it related to this issue? https://github.com/playcanvas/engine/issues/4595

yaustar avatar Aug 30 '22 15:08 yaustar

Indeed, forgot to check if this was reported.

NewboO avatar Aug 30 '22 15:08 NewboO

That's an awesome find, thank you!

yaustar avatar Aug 30 '22 15:08 yaustar

@slimbuck @mvaligursky @GSterbrant Would you be able to check the PR please?

yaustar avatar Aug 30 '22 15:08 yaustar