Large, dynamic texture

Hi All,

I would like to have a large plane with a dynamically updated texture. Some objects would move on the plane, and I want to highlight their path on the field.
I have figured out how to use GetPixels and SetPixels for this, I can draw lines on the texture. However if I create a small texture, the rendered lines on the plane are rough because the field is huge, and the texture is small ( I tried to impelment some anti-aliasing algorithm, but it did not really help). If I increase the size of the texture ( > 2048 x 2048 pixels), then the game starts to lag. I would like to inquire, what is the best practice for problems like that? I am thinking now on dynamically creating some meshes on the top of the field (if the field is at y=0, it could go to y=0.00001, so it would be above the field), but I am not sure f it will be rendered correctly.

Thanks for the help!

I haven’t worked much with shaders, but if you’re looking to manipulate textures at runtime, using GetPixels() and SetPixels() is a no go as that leads to slow calculations since those are CPU methods. But even worse is that the GPU is communicating to the CPU via GetPixels(), which is always a bad thing if you’re looking for performance.

I believe the most often use case for updating textures visually is using Graphics.Blit() and Graphics.CopyTexture() methods, since all of the copying takes place on the GPU.

1 Like

As a suggestion, i wouldn’t actually create footprints via writing to the texture. Using decals is much easier.

1 Like

Thank you for your valuable hints!

Decals are easier, but if you have many changes that you want to make, use a RenderTexture and lines to it or whatever you need.
Don’t do anything on the CPU related to textures unless there is no alternative.