-
Notifications
You must be signed in to change notification settings - Fork 368
Circle / ellipse no geo shader #2715
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
Merged
+105
−177
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 0 additions & 68 deletions
68
arcade/resources/system/shaders/shapes/ellipse/filled_unbuffered_geo.glsl
This file was deleted.
Oops, something went wrong.
34 changes: 32 additions & 2 deletions
34
arcade/resources/system/shaders/shapes/ellipse/filled_unbuffered_vs.glsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,37 @@ | ||
| #version 330 | ||
|
|
||
| in vec2 in_vert; | ||
| uniform WindowBlock { | ||
| mat4 projection; | ||
| mat4 view; | ||
| } window; | ||
|
|
||
| uniform vec2 center; | ||
| uniform int segments; | ||
| // [w, h, tilt] | ||
| uniform vec3 shape; | ||
|
|
||
| const float PI = 3.141592; | ||
|
|
||
| void main() { | ||
| gl_Position = vec4(in_vert, 0.0, 1.0); | ||
| int triangle_id = gl_VertexID / 3; | ||
| int vertex_id = gl_VertexID % 3; | ||
|
|
||
| // Calculate rotation/tilt | ||
| float angle = radians(shape.z); | ||
| mat2 rot = mat2( | ||
| cos(angle), -sin(angle), | ||
| sin(angle), cos(angle) | ||
| ); | ||
| // Calculate the positions for the full triangle in the current segment | ||
| vec2 positions[3] = vec2[3]( | ||
| vec2(0.0, 0.0), | ||
| vec2(sin((float(triangle_id) + 1.0) * (PI * 2.0 / float(segments))), | ||
| cos((float(triangle_id) + 1.0) * (PI * 2.0 / float(segments)))) * shape.xy, | ||
| vec2(sin(float(triangle_id) * (PI * 2.0 / float(segments))), | ||
| cos(float(triangle_id) * (PI * 2.0 / float(segments)))) * shape.xy | ||
| ); | ||
|
|
||
| mat4 mvp = window.projection * window.view; | ||
| vec4 pos = vec4(rot * positions[vertex_id] + center, 0.0, 1.0); | ||
| gl_Position = mvp * pos; | ||
| } |
76 changes: 0 additions & 76 deletions
76
arcade/resources/system/shaders/shapes/ellipse/outline_unbuffered_geo.glsl
This file was deleted.
Oops, something went wrong.
42 changes: 40 additions & 2 deletions
42
arcade/resources/system/shaders/shapes/ellipse/outline_unbuffered_vs.glsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,45 @@ | ||
| #version 330 | ||
|
|
||
| in vec2 in_vert; | ||
| uniform WindowBlock { | ||
| mat4 projection; | ||
| mat4 view; | ||
| } window; | ||
|
|
||
| uniform vec2 center; | ||
| uniform int segments; | ||
| // [w, h, tilt, thickness] | ||
| uniform vec4 shape; | ||
|
|
||
| const float PI = 3.141592; | ||
einarf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| void main() { | ||
| gl_Position = vec4(in_vert, 0.0, 1.0); | ||
| // Two triangles per line segment of the outline | ||
| int segment_id = gl_VertexID / 6; | ||
| int vertex_id = gl_VertexID % 6; | ||
|
|
||
| // Calculate rotation/tilt | ||
| float angle = radians(shape.z); | ||
| mat2 rot = mat2( | ||
| cos(angle), -sin(angle), | ||
| sin(angle), cos(angle) | ||
| ); | ||
|
|
||
| // sin(v), cos(v) travels clockwise around the circle starting at 0, 1 (top of circle) | ||
| float st = PI * 2.0 / float(segments); | ||
|
|
||
| // calculate the four points of the line segment | ||
| // Inner and outer points for the start of line segment | ||
| vec2 p0 = vec2(sin(float(segment_id) * st), cos(float(segment_id) * st)) * shape.xy; | ||
| vec2 p1 = vec2(sin(float(segment_id) * st), cos(float(segment_id) * st)) * (shape.xy - vec2(shape.w)); | ||
|
|
||
| // Inner and outer points for the end of line segment | ||
| vec2 p2 = vec2(sin((float(segment_id) + 1.0) * st), cos((float(segment_id) + 1.0) * st)) * shape.xy; | ||
| vec2 p3 = vec2(sin((float(segment_id) + 1.0) * st), cos((float(segment_id) + 1.0) * st)) * (shape.xy - vec2(shape.w)); | ||
einarf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| vec2 position[6] = vec2[6]( | ||
| p1, p0, p2, // first triangle | ||
| p1, p2, p3 // second triangle | ||
| ); | ||
| mat4 mvp = window.projection * window.view; | ||
| gl_Position = mvp * vec4(rot * position[vertex_id] + center, 0.0, 1.0); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.