How to get CanvasItem.draw_polygon() to draw the texture with repeat tiling?

Godot Version

4.5

Question

I want to draw a polygon in my Node2D, but am finding that the texture parameter I’m passing is drawn with clamping. I want the texture to repeat instead. Is there a way to do this?

draw_polygon(points, colors, uvs, tex)

I was also thinking of maybe creating a custom material for this polygon, but I cannot see any way to draw the polygon with a specified material. My _draw() method is drawing a variety of things, so I can’t just set the material parameter of my Node2D. I also cannot make it a child node, since then it will overlap/cover up stuff drawn in the node’s _draw method.

It looks like setting texture_repeat = TEXTURE_REPEAT_ENABLED on the CanvasItem will do the trick.

Enable texture_repeat for for the canvas item you’re drawing on.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.