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. #165
Conversation
f0746e4
to
db9bfa2
|
@glennw How's this? |
res/quad.fs.glsl
Outdated
| 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 Oops, I had that change made locally but forgot to commit. Fixed. |
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.
glennw
added a commit
that referenced
this pull request
Feb 2, 2016
Reimplement arbitrary rotation angles for linear gradients by clipping in the fragment shader.
|
Thanks! |
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.