How can I draw a pattern on to a Panel Node?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By eddex

Goal

I want to achieve something similar to this animation:

example

What I have

My project tree looks like this:

Control > Panel > Path2D > PathFollow2D > Node2D > Sprite & (Node > Line2D)

The Panel is the green background. The Path2D together with the PathFollow2D move the Sprite along the desired route.

My idea is to draw the pattern using multiple Line2D nodes. First I tried to just use one single long line for the full path but after adding ~5100 Vector2 objects to the Line2D.Points property, the line stopped working. Some of the first few points (except the very first one) disappear and adding new points to the Line2D.Points property has no effect at all.

I also ran into the error ERROR: _draw_polygon: Condition ' buffer_ofs > data.polygon_buffer_size ' is true. a couple of times.

Question

What other options are there to achieve something similar to this?

I think you can use sprites of those 2 stripes and use shaders to make them visible when that machine moves over them.

supper_raptor | 2020-04-14 06:22

Hi @supper_raptor, thanks for your answer. Unfortunately I have no clue about shaders… Can you recommend any resources to get started?

eddex | 2020-04-16 06:53