Godot Version
Godot 4.4.1
Question
I’ve been doing a lot of experiments with shaders lately and I am currently working on a shader where, in the fragment step, I have to access individual information from each vertex that forms the triangle
I have worked a bit with geometry shaders previously, so I was surprised to learn that they’re a deprecated tech and that apparently you can use compute shaders to achieve the same results
I have also used compute shaders in the past, however all of my experience was with sending data from the CPU to be processed and then grabbing it back, nothing related to actual rendering
I’ve been reading about the compositor but right now I am not sure if it is what I need as it seems more about how the whole WorldEnvironment gets rendered, as opposed to what I need, which is simply having access to more information in a fragment shader
I’ve searched around a lot and the closest forum topic I could find was this one. However, they end up straying away from compute shaders.
For clarity, I am less interested in solving my specific problem and more in understanding technically how to use compute shaders to access (and possibly even modify) the geometry data from a mesh
The best I managed so far was writing a script that gets the vertex data from a mesh, sends it to a geometry shader, and later retrieves it back to the CPU and updates the an ArrayMesh accordingly. This is naturally extremely heavy in processing and does not solve at all the issue of accessing geometry data from a fragment shader. My guess is that I would probably need to write to some buffer the spartial shader reads from instead of the CPU
For a more concrete example, I would love to achieve is to have something like an uniform vec3 vertexPosition[3] where each element has data from a vertex that forms the triangle, the geometry, that fragment belong to. I’m using position as an example of course, ideally I would be able to do so with any other information contained within a vertex such as colors, normals or even customs.
Thanks!