Topic was automatically imported from the old Question2Answer platform.
Asked By
kutoman
Hello,
I’m relatively new to Godot. I couldn’t figure out how to draw a node on a texture.
For example, in my case, I try to draw a Polygon2Ds polygon on ImageTexture:
var tex = ImageTexture.new()
var poly: Polygon2D = $Polygon2D
# how to draw poly.polygon on tex ?
I know of draw_polygon, but that method draws on the game screen directly.
I need the texture in order to pass it to another node using textures.
I think you want to make sure your polygon is a child of the texture. That way it shows up on top of the texture and it’s connected to the texture
How can I add a polygon to a texture as a child? As far as I can see the Texture class doesn’t have any method to add a Node or alike. Or do you mean the texture’s node?
But actually it’s crucial that the polygon is actually drawn in the texture itself. To be more precise I need to use that texture as a mask texture having the shape of that polygon.
I had already checked the latter but the first one seems promissing. I’ve also found out that there is the possibility to capture textures by Viewports, as it is also pointed out in one of the answers from the link you’ve shared: Using Viewports — Godot Engine (stable) documentation in English