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

Cubemap uses only first texture #228

Open
mserege opened this issue Oct 16, 2023 · 3 comments
Open

Cubemap uses only first texture #228

mserege opened this issue Oct 16, 2023 · 3 comments

Comments

@mserege
Copy link

mserege commented Oct 16, 2023

Hi,

First, thanks a lot for this lib !

Just figured out that creating a cubemap texture based on non power of two images does not work propertly in Chrome on MacOS. Safari is fine, Chrome on Windows is also fine.

Here is the repro.

I checked loadCubemapFromUrls code and it seems to me that the fact that gl.generateMipmap(target) is called after each image upload might be the issue.

Is there a reason to do so ? If I move the call on the last image upload, it fixes the issue.

Let me know.

Thanks

@greggman
Copy link
Owner

This is a bug in Chrome. I will file the bug. It appears to only happen in Intel based Macs, not M1/M2 Macs

The reason it calls generateMipmap is because the images each take a different amount of time to load. So, when you call twgl.createTexture it returns a 1x1x1 cube map and then loads the images. When the first image is loaded (it could be any one of the 6). It copies that image to all 6 faces because otherwise the cubemap would stop working. All 6 faces have to be the same size and if they are not you'd get an error. Further, it calls generateMipmap because if you have filtering that needs mips it would fail suddenly. As each of the remaining 5 images comes in it applies them to the correct face and calls generateMipmap since otherwise the mips for that face would still be based on the first image loaded.

In any case, this a bug in Chrome. I'll post back here once I've made a smaller repo

@greggman
Copy link
Owner

Update, so it's got nothing to do with npot vs pot. It's a size issue, 2048x2048 also fails. It fails for me at 1813x1813 where as 1812x1812 works. Here's my repo, no twgl. And it only happens with images. If I use canvas it works.

On the other hand I just checked Chrome Canary and it works there so maybe there's no reason to file the bug. Just wait for a new version of Chrome.

@greggman
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants