I have a project in Godot that renders billboarded quads on top of enemies. The quads(meshinstances) are children nodes of the enemy nodes. I want to render just the quads to a viewport for post-processing, but the quads need to have the same position on screen that the enemies have (like a target reticle). How can I apply a shader effect to the billboards only and not to the rest of the scene?
-
1It might be possible to put the HUD elements in a separate tree and use [`RemoteTransform`](https://docs.godotengine.org/en/stable/classes/class_remotetransform.html) to keep them in the right place. Render the HUD tree to a texture and apply it to a Viewport so you can add your own custom postprocessing shader. – Thomas May 28 '22 at 14:55
1 Answers
The Camera
has a cull_mask
property that lets you filter which layers it will see. And VisualInstance
s (such as MeshInstance
s) have a layers
property that lets you specify to which layers they belong (by default they all belong to the first layer).
You can configure the layers names in Project Settings -> General -> Layer Names -> 3d Render. Do not confuse them with 3d Physics.
Thus, you can give a different layer to those quad MeshInstance
you want, and then setup a new Viewport
with a new Camera
as child (make sure it is current
) with a cull_mask
that will only render that layer. That way only those MeshInstance
will be rendered on that Viewport
.
You probably want to to keep the properties of the Camera
in sync with the Camera
on main Viewport
(not only its global_transform
, but also fov
or any other property you might change). You can archive this by copying its properties on _process
of a script attached to the Camera
which is inside the new Viewport
.

- 31,890
- 5
- 57
- 86