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
TextureMatrix not functioning correctly #42
Comments
Hey @ajayns! Are you by any chance instancing your plane before the window load event actually occurs? Because this could lead to some wrong plane sizes calculations. You could try to use the |
I did try using the Since I really don't have much else to provide to showcase the issue, do you have any insights into how I could generate the matrix manually or do something similar based on the size of the plane dom element? Hopefully, I might be able to find the cause of the problem when I try that. |
Well, that's weird! You could still pass your plane and texture width and height values as two vec2 uniforms to your vertex shader, and calculate the ratios in there and apply them to your I'd still like to find out what could go wrong there! Cheers, |
Ahh that looks like it could solve the issue for my case even though it is a hacky fix.
Same it's a pretty weird bug where even I'm unsure what's going wrong even with my going all around the problem and attempting a simplified reproduction. Thanks a bunch for the help :) |
So to sum up, all the sizes values are correct, so there's no reason the texture matrix calculations could be wrong either. Actually I've just made a quick test locally with a plane and texture of the exact same sizes. Got the same texture matrix, and the rendered texture looks just fine. I honestly don't know what could be wrong here. |
I doubted that myself and so I ran it using the most basic vertex and fragment shaders which basically just passing the varying vTextureCoord and then using that the image is displayed. Still, the issue persisted. From what I see I believe there's something going wrong with the calculations itself as I'd mentioned the uTextureMatrix seems to mess it up while me using a custom ratio to aTextureCoord seem to get the image to display. But yes, I still have no clue what exactly is going wrong either, so I'll put this on hold, try other things, and eventually maybe I could spot what's happening here. |
Allright, then maybe the texture matrix uniform is not being updated somehow? |
Sheesh, I found and resolved the error, that was quite the headache. I'm sorry for all the trouble but you were right, it had to do with the shaders. In my local repo, I've added a couple of textures to the plane and I'm switching between them like your async textures loading example. Since I was using a bunch of images of the exact same size, I'd assumed I could just use the texture matrix of just one of them for all the images as the size and fit were the same. And that's where I went wrong haha, I added the individual matrices for each texture and that fixed the issue. Also, any clue why my assumption was wrong? If textures are of exact same size, shouldn't the matrices be similar? Sorry, if this is a dumb question and I'm completely unaware of something |
Closing the issue, and I'm sorry again for all the trouble! |
Glad you found the bug :) If the textures all have the exact same sizes, they should indeed have the same texture matrices as well. |
Yes, I'll take some time to look into that as well. Now knowing that my assumption was right, it is indeed a very weird bug. |
I've tried reproducing the issue in a simpler environment but was unfortunately unable to do so in the first attempt, so I'm hoping you have so insight just by reading the details of my problem itself.
This is how the layout looks like (it has no error but almost similar thing shows up an error in my local env): https://codepen.io/ajayns/pen/XWmQLNL
The plane's image unlike how it's expected to be (like
object-fit: cover
) it's showing up in stretched dimensions or zoom in and other glitches. Any input on how I can correct theuTextureMatrix0
uniform?I have a feeling it was something to do with the layout but then I recreated that in the codepen in which it seems to work fine, now I suspect it's got something to do with the shader and that's why I'm looking for ideas.
The text was updated successfully, but these errors were encountered: