Support for partial update ImageTexture #4017
ThreeMileJump
started this conversation in
2D
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I raised this about a year ago with reference to problems with LargeTexture. The suggested feature involves having a large texture (like a map or a pixel-paint for example) which is updated from an image that is smaller than the texture. The large texture may only be partially displayed on the screen (clipped). The modification of the Image needs to be done by the CPU, and changes may only affect a small area of the image. If the ImageTexture is very large, then a set_data(Image) can be quite resource intensive, and doing it every frame would not be a good idea.
OpenGL already has this feature - you can update a texture from a smaller image by passing an extra Vector_2 parameter in the set_data call. I expect that Vulkan also supports this feature. With this, you can create a small update image (think of a brush area in paint), copy the modified section of the large image, and then do a partial update to the texture. If your working image is 2048x2048 and you can confine your update to a 128x128 patch, the data transferred to the GPU in the set_data() is smaller by a factor of 256!
In Godot 4 LargeTexture has been deprecated. So far my workaround has been to create a target ViewportTexture in a new Viewport, and then use a small ImageTexture to copy into that ViewportTexture at an arbitrary position. This seems to work, but it is a bit over-complicated. I think one of the reasons for deprecating LargeTexture was that on any viable graphics card, textures up to 4Kx4K are supported. This is true, and if the texture is loaded from its Image once at startup, then no problem. That reason doesn't allow for dynamic modification of the texture as its Image is modified by code. Refreshing all of a very large texture is a big hit on CPU-->GPU bandwidth, and if only <1% of the image has changed, it is a waste of resources.
Maybe the reason this feature has not been included is due to GLES2 or GLES3? I don't know if they support partial texture update. Either way, with Godot 4 it seems reasonable to include this feature, even if doesn't work on GLES fallback renderers. I think that this feature would make Godot much more attractive for anyone wishing to write a pixel paint program, as well as other applications which display a mutable bitmap image.
Beta Was this translation helpful? Give feedback.
All reactions