1

Does Unity's renderer read the entire texture, or only the pixels the UVs overlap?

For example, in the following texture with the following UVs, only rows C, D, E and F are needed. Disregarding the extra storage space the rest of the texture occupies, are there any drawbacks to doing this?

Color grid partially covered with UVs

Does the renderer read the entire texture or only the relevant pixels?

Bip901
  • 590
  • 6
  • 22

1 Answers1

4

Unity would keep the whole texture in memory. Texture mapping is done in shaders.

That's why its recommended to try and occupy as much UV space as possible. You can even go further and use same texture for multiple objects.

Even tho this only covers opengl, it is a good resource for understanding how all of this works. https://learnopengl.com/Getting-started/Textures

b23v
  • 86
  • 1
  • 4
  • So if I understand correctly, the renderer stores the pixels but does nothing with them - that's the shader's job. Would that affect performance (noticeably, in a real-time game)? – Bip901 Aug 04 '20 at 10:55
  • Textures are stored in the video memory. Yes a lot of drawcalls will affect the performance. You should really be trying to keep the number of drawcalls as low as possible. This looks like a good article for learning about drawcalls https://gamedev.net/tutorials/programming/general-and-gameplay-programming/your-guide-to-reducing-draw-calls-in-unity-2020-r5302/ So to answer your question. One way to reduce drawcalls is to use same material and textures for multiple objects. There are various techniques to help with that. For example tile sheets. – b23v Aug 04 '20 at 11:28
  • 1
    A larger-than-necessary texture should not slow down the run-time access for shaders that use it. However, it will take longer to load into video memory, and of course it will occupy video memory that could otherwise be used for something else. – comingstorm Aug 05 '20 at 06:05