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

fixed https://github.com/projectM-visualizer/projectm/issues/825 #830

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ precision mediump float;
layout(location = 0) in vec2 vertex_position;
layout(location = 1) in vec2 rad_ang;
layout(location = 2) in vec4 transforms;
layout(location = 3) in vec2 center;
layout(location = 4) in vec2 distance;
layout(location = 3) in vec2 center2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain why changing this fixes it?

Copy link
Member

@kblaschke kblaschke Aug 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question. The only explanation I could come up with is that Android's shader Compiler somehow has center and distance as keywords.

Edit: yeah, only OpenGL ES has a distance() function, so this would cause compilation issues. Actually haven't seen other GLES compilers give me an error, which is strange.

I'd not postfix those variables with a 2 in the case, as there's clearly no 1 here. We could instead rather prefix the variables with in_ or something, which would both fix the potential keyword issue and not make the names look weird.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess renaming the distance variable should suffice, as I cannot find any keyword or function center in any GL standard.

Could you try that, keeping center as-is and for example rename distance to warpDistance?

layout(location = 4) in vec2 distance2;
layout(location = 5) in vec2 stretch;

uniform mat4 vertex_transformation;
Expand Down Expand Up @@ -47,8 +47,8 @@ void main() {
pos.y * 0.5 + 0.5 + texelOffset.y);

// Stretch on X, Y
u = (u - center.x) / stretch.x + center.x;
v = (v - center.y) / stretch.y + center.y;
u = (u - center2.x) / stretch.x + center2.x;
v = (v - center2.y) / stretch.y + center2.y;

// Warping
u += warp * 0.0035 * sin(warpTime * 0.333 + warpScaleInverse * (pos.x * warpFactors.x - pos.y * warpFactors.w));
Expand All @@ -57,17 +57,17 @@ void main() {
v += warp * 0.0035 * sin(warpTime * 0.825 + warpScaleInverse * (pos.x * warpFactors.x + pos.y * warpFactors.w));

// Rotation
float u2 = u - center.x;
float v2 = v - center.y;
float u2 = u - center2.x;
float v2 = v - center2.y;

float cosRotation = cos(rot);
float sinRotation = sin(rot);
u = u2 * cosRotation - v2 * sinRotation + center.x;
v = u2 * sinRotation + v2 * cosRotation + center.y;
u = u2 * cosRotation - v2 * sinRotation + center2.x;
v = u2 * sinRotation + v2 * cosRotation + center2.y;

// Translation
u -= distance.x;
v -= distance.y;
u -= distance2.x;
v -= distance2.y;

// Undo aspect ratio fix
u = (u - 0.5) * invAspectX + 0.5;
Expand Down
Loading