How to do a fragment shader hack, for no compute shader support?

Godot Version

^4.4

Question

Currently, you can do SubViewport/ColorRect, with the SubViewport.clear = Never (or Next Frame) and apply the shader to the ColorRect. To read the processed image, read the screen texture in the shader, or call sub_viewport.get_texture().get_image() on the next frame.

So you can only read it on the next frame, whether with the screen texture, or from ViewportTexture.

I’m basically asking, how to read the image in a single frame? or how to request my specific viewport to draw?

1 Like

It’s not possible. Draw commands are gathered, and optimized and rendered at once. You need to wait at least to RenderingServer.frame_post_draw for the viewports to update.

2 Likes

That’s basically working on the next frame if you need to display something on top of its data.

I think that’s it. After all, even compute shaders execution delays a lot. Need to wait for another frame? not a big deal.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.