Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReimplement arbitrary rotation angles for linear gradients by clipping in the fragment shader. #164
Conversation
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Can be removed |
This comment has been minimized.
This comment has been minimized.
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
pcwalton commentedFeb 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.