Texture2DArrays for Compute Shaders #12637
BurningFluffer
started this conversation in
Engine Core
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am making a complex voxel terrain with a complex generation code. Each chunk is stored as a Texture2DArray (equally could be a Texture3D, but that has more limitations). For this use case, it makes a lot of sence to use compute shaders to handle all the complex generation.
Thus, I need to pass a Texture2DArray as a uniform to a shader, and then extract it and convert into Texture2DArray again.
Here come the problems:
1) According to documentation, there are some methods that involve Texture2DArray (or similar), but none that can be used to pass the Texture2DArray as a uniform. Normal shaders can easily use those, so I assume that is a functionality that has either not been exposed, documented, or requires a lot more clarity/tutorial.
2) After the compute shader finished processing, it returns everything as bytes, which need to be converted into the desired format. There is no method for converting bytes into a Texture2DArray. Unfortunately, I could not find anything that would seem appropriate for this.
I believe that storing data as textures is the most optimal way for both memory and processing speed. So, while I have no idea how that could be implemented on a technical level, I believe that this is a vital functionality that is unclear/missing from Godot. The documentation has already improved a lot on compute shaders, and I believe that this is a gap that was approached yet not finalized.
Having Texture2DArrays/Texture3Ds processed by compute shaders would help both in voxel generation, animation editing, modifying mesh textures that are composed of multiple textures and co-dependent masks, and other uses. Putting data into a single sampler2Darray is way better than splitting everything into a layer per uniform and trying to figure out how to reference them all for looping, before spending more time reassembling the Texture2DArray manually, especially with hundreds of layers.
Beta Was this translation helpful? Give feedback.
All reactions