Skip to content

Commit

Permalink
fixed issues with offsets and rotation in bars shader
Browse files Browse the repository at this point in the history
  • Loading branch information
Dougal-s committed Feb 13, 2020
1 parent 9aa5143 commit 7df5afd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/modules/bars/1/shader.vert
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ layout(constant_id = 3) const int height = 1;

layout(constant_id = 18) const float limit = 1;

layout(constant_id=19) const float boxWidth = 2;
layout(constant_id=20) const float boxHeight = 1;
layout(constant_id=19) const float boxWidth = 1;
layout(constant_id=20) const float boxHeight = 0.5;

// degrees
layout(constant_id=21) const float rotation = 0;
Expand All @@ -29,7 +29,7 @@ layout(location = 0) out vec2 position;

void main() {
mat2 transform = mat2(cos(rotation), sin(rotation), -sin(rotation), cos(rotation))
* mat2(boxWidth/2, 0, 0, limit*boxHeight/2);
gl_Position = vec4(transform*positions[gl_VertexIndex]+vec2(xOffset, yOffset+(1-limit)*boxHeight/2), 0.0, 1.0);
position = vec2(width*boxWidth/4, -limit*boxHeight/4)*(vec2(0, -1)+positions[gl_VertexIndex]);
* mat2(boxWidth, 0, 0, limit*boxHeight);
gl_Position = vec4(transform*positions[gl_VertexIndex]+vec2(xOffset+sin(rotation)*(1-limit)*boxHeight, yOffset+cos(rotation)*(1-limit)*boxHeight), 0.0, 1.0);
position = vec2(width*boxWidth/2, -limit*boxHeight/2)*(vec2(0, -1)+positions[gl_VertexIndex]);
}
Binary file modified src/modules/bars/1/vert.spv
Binary file not shown.
4 changes: 2 additions & 2 deletions src/modules/bars/config
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

(id=18) float limit = 0.8

(id=19) float width = 2
(id=20) float height = 1
(id=19) float width = 1
(id=20) float height = 0.5

// radians clockwise
(id=21) float rotation = 0
Expand Down

0 comments on commit 7df5afd

Please sign in to comment.