I'd like to create a painting program where the user can click and drag with the mouse to lay down a stroke of paint. Basically, I have one texture representing the head of my brush and as the user drags the mouse across the canvas, for each InputEventMouseMotion event I draw an instance of this brush head texture onto another texture I'm using as a buffer for the entire stroke.

I'm trying to figure out how to do this using Godot's architecture. I don't want to simply create a whole lot of Sprite nodes and place them on my canvas - I want this all composited into a single texture. I'd also like to use a shader when I draw the brush head so I have control over opacity, rotation, scale and could even try advanced blending equations such as overlay, screen, dodge, burn, etc.

Is there a way to directly composite into a single texture or viewport? As far as I can tell, the only way to render images on top of one another is by setting up a node hierarchy and letting Godot's rendering system do the work.

This tutorial I came across is far from giving you everything you want, but it might be a good place to start:

There is also this thread from a few years ago where another dev was trying to accomplish something similar to what you're after: https://godotforums.org/d/22141-blitting-textures/5

If you go down a ways you'll find code he shared after he figured out how to do it. You should feel free to go with his approach, but personally I would go with a combination of the two: use an array as a buffer for when the user is creating a stroke, and then "blit" it when they release the stroke.