[3.0x] Is there a faster way to read back a generated texture?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RaXaR
:warning: Old Version Published before Godot 3 was released.

I am currently generating a texture with a custom shader. I"ve got two scenes, my Main scene and a TextureGenerator scene.

The TextureGenerator scene has two Nodes, a Vieport as the root and TextureRect as the only child. The TextureRect uses my custom shader and I use the Viewport.get_texture() method to return a copy of the rendered view.

All of this works fine, but it seems a bit slow.
Does anyone know of a more performant way to do the above in Godot?
Maybe some direct rendering to a buffer or something? I dunno.

Thanks.

Documentation mentions:

  1. viewport.queue_screen_capture() and viewport.get_screen_capture()(takes a couple of frames).
  2. viewport.get_render_target_texture() when the viewport is used as a render target (rendering not visible onscreen).

snwflk | 2017-11-30 16:35

Those methods you mention are for the 2.x branch. :slight_smile:
Thanks anyway.

RaXaR | 2017-11-30 17:36

Literally “for nothing” :slight_smile: Indeed I haven’t tested them but the documentation should be amended. It is also for 3.x (latest version): Using Viewports — Godot Engine (latest) documentation in English
Although I don’t need it right now, I’m curious about this too as I’m going to need/use it very often.

snwflk | 2017-11-30 17:52