Using a compute shader generated texture in materials

Godot Version

4.2

Question

Hey, I have a compute shader generating and updating a texture that’s got information necessary for gameplay, so I can’t update it directly on the render thread since it needs to be consistently updated at specific points in gameplay
how can I use this texture in rendering as well? do I have to copy it on the CPU and recreate a copy of it for the rendering server every single time I update it? if yes, what’s the cheapest way to do it? I looked into Texture2DRD but it breaks rendering when the texture RID comes from a different rendering device than the main renderingserver one and I’m not really seeing other options

Check out this official demo for compute shaders:

This demo shows how to use compute shaders to populate a texture that is used as an input for a material shader.

I’ve seen the demo, he does the processing on the render thread & if I do the same thing I won’t be able to consistently update the texture specifically when I want & read from it for gameplay purpose
I want to control when the texture is updated from the game thread but have it be usable for rendering

1 Like