engine
engine copied to clipboard
Fix unpacking of msdf markup params
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):
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:
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.
Is it related to this issue? https://github.com/playcanvas/engine/issues/4595
Indeed, forgot to check if this was reported.
That's an awesome find, thank you!
@slimbuck @mvaligursky @GSterbrant Would you be able to check the PR please?