-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
"Passing Shader Uniforms" example #1021
Comments
@JetStarBlues What browser are you using? Everything looks correct on my screen. |
@aferriss Hey, the screenshot you posted failed to upload... Also curious which browser you were using. |
@JetStarBlues Oops! Re-uploaded. I was using chrome 90, but I also checked in firefox (v88) and safari (v14.03) and it was looking fine in all of those as well. I'm on OSX 10.15 (Catalina) |
@aferriss
Thanks for your time! |
|
Hmm, I'm seeing very different things than you are. We can skirt the issue entirely by not relying on the resolution values to calculate the shape's position. Here's an updated example that should work the same on every platform |
Oh, I see! Thank you for pinpointing the problem! 🎉🎉
I was expecting the results you got. (The matrix-aware version centers correctly on your screen.) But I was mistaken as to why! (Has nothing to do with use of matrix, but rather use of resolution independent calculations as you have pointed out!) |
The new version of the code only works with a 1:1 aspect ratio. Otherwise, the shape is stretched.
// move the coordinates to where we want to draw the shape
vec2 pos = vec2(x,y) - coord;
// force 1:1 ratio...
float ax = resolution.x / resolution.y;
float ay = resolution.y / resolution.x;
if ( ax > ay )
{
pos.x *= ax;
}
if ( ay > ax )
{
pos.y *= ay;
} |
See discussion on issue processing#1021.
I have update the linked PR accordingly. |
Ah yea, good catch on the scaling! |
Actual Behaviour
In the "Passing Shader Uniforms" example, the generated image is off-center.
Expected Behaviour
Image is centered.
I think somewhere along the way, the original values got lost.
Would you like to work on the issue?
Yes
The text was updated successfully, but these errors were encountered: