-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebGLTexture: Basic support for gl.texStorage2D(). #22790
Conversation
It seems the implementation has problems with video textures. When starting rendering, video textures have a 0 width and height. These are no valid values for
Since textures defined via |
There is also issue when updating existing textures.
|
Second commit with the fixes is more-or-less exactly what I would expect to see from an implementation of this feature. 👍 Does Three allow users to change a texture to an entirely different image after it's been created? As in: with different dimensions or format? If so then the way to handle that with texStorage is to simply delete the old GL texture handle when those mutable properties change and replace it with a new one. Sounds heavyweight, but it's essentially what texImage2D is doing behind the scenes when you reshape the texture. |
Technically it's at least possible. In the following fiddle, the initial 1024x1024 texture image is replaced with a 256x256 image: https://jsfiddle.net/ufyrwt5m/ However, I'm not sure if we ever defined some sort of policy about this. E.g. with buffer attributes we have stated that it's not possible to replace or resize the internal array buffer after the creation. We could define something similar for textures. If we state that certain properties like the image (or at least its dimensions) and other structural data like texture format or type are considered to be immutable after the textures creation (or initial use), it should be easier to adapt Personally, I would prefer such a policy since we could benefit from certain assumptions in the engine that makes it easier to implement optimized code like the usage of Besides, why would someone suddenly change the data type or format of a texture? It seems more natural to me to create a new texture object if I want to use a different image. |
Adopting a policy like that would definitely align better with the backend graphics APIs. With WebGPU, for example, all textures have immutable dimensions and formats. I'd encourage it! |
@mrdoob @WestLangley @donmccurdy @sunag Would you be okay if we add the following statement (or something similar) to the
I would also add this note to the migration guide. Having this policy in place would make it easier to build the engine on top of WebGPU and |
Something like
|
Would this affect the pattern below? material.map = textureLoader.load('image.png');
render(); Presumably the texture will be 'rendered' a few times before the image is downloaded and assigned to the texture, is that OK? Note this also applies to compressed textures. Otherwise I think I'm fine with saying that a texture cannot be resized. |
Yes, that works. The PR does not affect this behavior.
three.js/src/renderers/webgl/WebGLTextures.js Line 341 in 8bf2f21
Only then |
Thanks! |
I suggest to expand the support of |
Related issue: #21874
Description
Introduces the usage of the WebGL 2 API
texStorage2D()
. Only normal textures are supported right now (so no data, compressed or cube textures). Before rolling out it everywhere I thought we could do it an incremental fashion and thus easier spot potential issues.The PR helps to mitigate #22758.