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

Reimplement arbitrary rotation angles for linear gradients by clipping in the fragment shader. #164

Closed
wants to merge 1 commit into from

Conversation

@pcwalton
Copy link
Collaborator

pcwalton commented Feb 2, 2016

This reintroduces the clip-in rect in the FS. Since we'll need it anyway
when we have arbitrary matrix/clip stacks, this seems harmless.

Color strips for non-axis-aligned linear gradients are submitted as
axis-aligned rects centered at the appropriate point, just as
axis-aligned ones are. However, we reuse one of the vertex fields to
store the rotation angle. The vertex shader detects this condition,
rotates the rectangle around its midpoint, and passes the clip rect on
to the fragment shader.

Additionally, this patch eliminates the ugly (-10000,10000) spans for
linear gradient strips that we had before. It was necessary to tighten
this up in order to avoid needless fragment shader invocations in the
non-axis-aligned case, so I went ahead and fixed it everywhere.

Closes #161.

@pcwalton pcwalton closed this Feb 2, 2016
@pcwalton pcwalton deleted the gradient-rotation branch Feb 2, 2016
in the fragment shader.

This reintroduces the clip-in rect in the FS. Since we'll need it anyway
when we have arbitrary matrix/clip stacks, this seems harmless.

Color strips for non-axis-aligned linear gradients are submitted as
axis-aligned rects centered at the appropriate point, just as
axis-aligned ones are. However, we reuse one of the vertex fields to
store the rotation angle. The vertex shader detects this condition,
rotates the rectangle around its midpoint, and passes the clip rect on
to the fragment shader.

Additionally, this patch eliminates the ugly (-10000,10000) spans for
linear gradient strips that we had before. It was necessary to tighten
this up in order to avoid needless fragment shader invocations in the
non-axis-aligned case, so I went ahead and fixed it everywhere.

Closes #161.
if (PointInRect(vPosition, vClipOutRect.xy, vClipOutRect.zw)) {
discard;
}

// Clip in.
if (vClipInRect != vec4(0.0) && !PointInRect(vPosition, vClipInRect.xy, vClipInRect.zw)) {

This comment has been minimized.

@glennw

glennw Feb 2, 2016

Member

I don't think you need this if () condition - I'm fairly sure it wasn't in the shader last time?

This comment has been minimized.

@glennw

glennw Feb 2, 2016

Member

Oh I see what's happening - perhaps just set it to a large value in the VS to avoid a conditional in the FS?

@@ -65,6 +65,8 @@ impl NodeCompiler for AABBTreeNode {
builder.push_clip_in_rect(clip_rect);
builder.push_complex_clip(&display_item.clip.complex);

println!("clip rect={:?}", clip_rect);

This comment has been minimized.

@glennw

glennw Feb 2, 2016

Member

Can be removed

@glennw

This comment has been minimized.

Copy link
Member

glennw commented on src/node_compiler.rs in 2841cce Feb 2, 2016

Can be removed

@glennw

This comment has been minimized.

Copy link
Member

glennw commented on res/quad.fs.glsl in 2841cce Feb 2, 2016

Can we remove the conditional here by making the VS specify a very large clip rect instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.