Someone asked for an example on how to use render target resources in GUI in some thread a while back. And it turned out it was a bit tricky so we needed to add / fix a small thing related to render target resources in the engine (Add attachment texture resource path into resource.get_render_target_… · defold/defold@9a0000d · GitHub).
Anyway, here’s a small example on how you can use a render target in a GUI:
GH: https://github.com/Jhonnyg/my-public-defold-examples/tree/master/render-target-resource
HTML5: Render Target Resource 1.0
The setup is somewhat simple:
- A dummy atlas is created with a single animation, which is added to the GUI and a box node is set to use the dummy animation/texture in the editor
- The dummy atlas animation is updated once in runtime - the backing texture of the atlas is set to the render target resource and the animation is updated to match the dimensions of the render target
- The render script renders the map (and applies a post-process effect) onto the RT every frame, which is now successfully connected to the render target resource texture!