I have a psuedo light2d that uses gradient2d as its texture. When I try to tamper with the raw data using gradient.set_color or gradient.set_offset it causes immense lag. I’m constantly changing the values of these to imitate a flicking light and color transition. What am I doing wrong?
As @alex2782 posted, changing the gradient allocates memory and “bakes” it again for quick future access. Changing it (potentially every frame?) is really inappropriate.
Maybe you could get away with defining multiple gradients ahead of time and switching between them?
Or make multiple lights and turn those on/off maybe?
Thanks for the replies! I was able to solve my issue by doing anything but change the raw data. For the flickering light that I wanted, I just adjusted the sprite’s scale value. As for the color changes, I was able to get it done through shaders.