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

prim_shared: Fix clip mask perspective interpolation. #3145

Merged
merged 2 commits into from Oct 1, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

prim_shared: Better fix for perspective interpolation, as suggested b…

…y Dzmitry.
  • Loading branch information
emilio committed Oct 1, 2018
commit de4cc3f517cc676d778129f063e2a432cff97447
@@ -121,14 +121,12 @@ VertexInfo write_vertex(RectWithSize instance_rect,
vec4 world_pos = transform.m * vec4(clamped_local_pos, 0.0, 1.0);

// Convert the world positions to device pixel space.
vec2 device_pos = world_pos.xy / world_pos.w * uDevicePixelRatio;
vec2 device_pos = world_pos.xy * uDevicePixelRatio;

// Apply offsets for the render task to get correct screen location.
vec2 final_pos = device_pos + snap_offset -
task.content_origin +
task.common_data.task_rect.p0;
vec2 final_offset = snap_offset - task.content_origin + task.common_data.task_rect.p0;

gl_Position = uTransform * vec4(final_pos, z, 1.0);
gl_Position = uTransform * vec4(device_pos + final_offset * world_pos.w, z * world_pos.w, world_pos.w);

VertexInfo vi = VertexInfo(
clamped_local_pos,
@@ -241,7 +239,8 @@ float do_clip() {
return 1.0;
}
// anything outside of the mask is considered transparent
vec2 mask_uv = vClipMaskUv.xy / vClipMaskUv.w;
//Note: we assume gl_FragCoord.w == interpolated(1 / vClipMaskUv.w)
vec2 mask_uv = vClipMaskUv.xy * gl_FragCoord.w;
bvec2 left = lessThanEqual(vClipMaskUvBounds.xy, mask_uv); // inclusive
bvec2 right = greaterThan(vClipMaskUvBounds.zw, mask_uv); // non-inclusive
// bail out if the pixel is outside the valid bounds
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.