Godot Version 4.4.1
Question
How do you pass a subviewport output as a uniform to a compute shader?
I think I’m only finding old info on this because the reddit comments I can find on this use functions that don’t exist anymore. I have the following code:
var canvas_texture: Texture2D = canvas_subviewport.get_texture()
var canvas_texture_rid = canvas_texture.get_rid()
var canvas_sampler : RDUniform = RDUniform.new()
canvas_sampler.uniform_type = RenderingDevice.UNIFORM_TYPE_IMAGE
canvas_sampler.binding = 1 # As declared in the shader (binding = 1)
canvas_sampler.add_id(canvas_texture_rid)
uniforms.append(canvas_sampler)
Also on the compute shader side, the uniform is declared as:
layout(set = 0, binding = 1, rgba8) uniform image2D canvas; //CANVAS
I think the problem might be the way I’m getting the RID for the subviewport, but I’m not sure. I know the problem is not with the rest of the shader code because it works if I remove this portion.
does anyone have any idea?