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

Need to be able to upate a texture partially #9571

Closed
Zylann opened this issue Jul 9, 2017 · 2 comments
Closed

Need to be able to upate a texture partially #9571

Zylann opened this issue Jul 9, 2017 · 2 comments

Comments

@Zylann
Copy link
Contributor

Zylann commented Jul 9, 2017

I'm writing a HeightMap module , and when the heights are edited it would be nice to be able to update only a sub-rectangle of the textures instead of the full 2048x2048 pixels (or the full 512x512 rects if the textures are chunked on superlarge terrains). My editing process is chunked already for memory efficiency, but uploading the textures would also make it faster with this feature (it's currently unbearable at size 2048)

Another use case would also be Virtual Textures, or a way to simulate huge textures by streaming it through an atlas.

@Zylann
Copy link
Contributor Author

Zylann commented Oct 11, 2017

@reduz Is this still possible to have in 3.0?

@Zylann
Copy link
Contributor Author

Zylann commented Nov 9, 2017

I had a read in RasterizerStorageGLES3 to see how texture data is uploaded, and I have to admit a few things:

  • The function already uses glTexSubImage2D with full rectangle (while I need sub-rectangle)
  • However it does that only if TEXTURE_FLAG_USED_FOR_STREAMING
  • Many other options come into play, including mipmaps
  • If I implement sub-region, it may come with incomplete support of these features, I don't know how feasible (or relevant) it is to handle them all (any advice?)

My use case stems from the fact that editing 8-bit and 16-bit texture on CPU is awfully slow currently, because uploading it as a whole in realtime to see the result is way too slow, and won't be an option at all with big terrains. But at the same time, I wonder if it's a good idea to implement sub-rect upload with limited features. I could subdivide the heightmap in plenty of smaller textures (which I might do in the future to support streamed terrains), however I fear that this affects performance...
I could also investigate GPU painting, which would be pretty fast but would limit texture size to renderbuffer size, and I'm not sure if that would work while keeping the same formats I currently use (RH for heights, RGB8 for normals, RGBA8 for splats, R8 for discard). Also i would be unable to paint on the alpha channel since there is no blending mode for it.
WDYT @reduz ?

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

No branches or pull requests

2 participants