How to pass a render from a viewport to a shader?

Godot Version



I have a viewport set up to follow the player around! Like so:
Dont mind the HeightMapCamHolder and the OrbitPoint.

DepthQuad render this:
The capture cam is located 250m above this.

This object script has this:

func _process(delta):
	# Retrieve the captured Image using get_image().
	var img = get_viewport().get_texture().get_image()
	# Convert Image to ImageTexture.
	var tex = ImageTexture.create_from_image(img)

Which i guess means I have a render texture that I can somehow see in the resources when the game is running.

But i dont understand how to get the render texture from the CaptureCamera to the foliage/grass/whatever shader where i want to use the height map?`

Does anybody know?

I can do this:

# Set sprite texture.
	sprite.texture = tex

to show the texture on a sprite INSIDE of this asset, like so:
but it is by selecting it via the Godot interface, like so:
and that is not possible for me in the shader. :neutral_face:

Please if someone can share some intel on how to do this? :star_struck:

Something like this.

$MeshInstance3D.set_instance_shader_parameter("my_color", Color(0.3, 0.6, 1.0))

Which is an example found here