Writing to a pixel using compute shader

Godot Version

4.5.1 NET

Question

i know (or as far as i understand) compute shader can’t directly write to a pixel, therefore has to store the write to a texture and display it on a texturerect over the screen.

currently i’m using ImageTexture for it, but i’m just wondering, is there a better way to go about this?

var frame_texture = rd.texture_get_data_async(output_texture_frame, 0, texReady)

func texReady(data:PackedByteArray):
	var frame_img = Image.create_from_data(1366, 768, false, Image.FORMAT_RGBA8, data)
	texAssign(frame_img)
	
func texAssign(frame_img_fetch:Image):
	frame_path.texture = ImageTexture.create_from_image(frame_img_fetch)

#a snippet of my code

You can use a Texture2DRD instead to avoid copying from GPU to CPU and back to GPU.

1 Like

perfect, thank you so much