What's the best practices to modify a Texture2D efficiently by CPU?
I know that shader is the fast way to modify a texture . However, I'm trying to implement the 'fog of war'. The revealing information is store in a texture. And because I have a huge map, the performance is very important. Every time when I want to modify the texture, I need invoke Texture2D.GetPixels() and get a Color array. After the array is modified, I need invoke Texture2D.SetPixels() and convert it to Texture2D. It is very inefficiency. And the sizeof Color is 4*float = 16bytes. But a 32bit image is just 4bytes a pixel!
So is there any way to modify a Texture efficiently? Or I just use it in a wrong way?
Your answer
![](https://koobas.hobune.stream/wayback/20220612133933im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to load a folder of textures automatically to an array of Raw Images? 2 Answers
1024x1024 Texture2D Takes up over 8MB of memory 0 Answers
Convert Texture to Texture2d takes a lot of time in android device. 0 Answers
How do I use a sliced 2D sprite as the repeating texture on a 3D object? 0 Answers
shader graph messes up the texture (2D) 0 Answers