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

Fix unpacking of msdf markup params #4600

Merged
merged 1 commit into from
Sep 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/graphics/program-lib/chunks/common/vert/msdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ varying vec4 shadow_color;
varying vec2 shadow_offset;

void unpackMsdfParams() {
outline_color.rb = mod(vertex_outlineParameters.xy, 256.) / 256.;
outline_color.ga = vertex_outlineParameters.xy / 256. / 256.;
vec3 little = mod(vertex_outlineParameters, 256.);
vec3 big = (vertex_outlineParameters - little) / 256.;

outline_color.rb = little.xy / 255.;
outline_color.ga = big.xy / 255.;

// _outlineThicknessScale === 0.2
outline_thickness = vertex_outlineParameters.z / 255. * 0.2;
outline_thickness = little.z / 255. * 0.2;

vec3 little = mod(vertex_shadowParameters, 256.) / 256.;
vec3 big = vertex_shadowParameters / 256. / 256.;
little = mod(vertex_shadowParameters, 256.);
big = (vertex_shadowParameters - little) / 256.;

shadow_color.rb = little.xy;
shadow_color.ga = big.xy;
shadow_color.rb = little.xy / 255.;
shadow_color.ga = big.xy / 255.;

// vec2(little.z, big.z) * 2. srink from (0.5, 0.5) to (1, 1)
// vec2(little.z, big.z) / 127. - 1. remaps shadow offset from [0, 254] to [-1, 1]
// _shadowOffsetScale === 0.005
shadow_offset = (vec2(little.z, big.z) * 2. - 1.) * 0.005;
shadow_offset = (vec2(little.z, big.z) / 127. - 1.) * 0.005;
}
`;