Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

When does unity upload textures to the gpu?

Discussion in 'Shaders' started by keeperkai2, Oct 29, 2013.

  1. keeperkai2


    Oct 26, 2012
    I'm working on some kind of effect that needs to use one texture on all the different materials in the scene, it takes 20ms for the main thread to run, but after lowering the resolution of that texture it only takes 13ms for the main thread to run, yielding higher fps. So I'm wondering if:
    When we have a lot of objects with different materials in the scene, but the materials all use the same 2D texture(to be more clear, the materials have a lot of different properties, and one of the properties is a texture, and all the objects in the scene uses the same texture for that property), does unity re-upload the same texture each time it renders a different mesh?(assuming no batching is performed)

    I tried to set the property with a single Shader.setGlobalTexture() call and see if it will run faster, but unfortunately not....
    so I'm thinking even properties set with the Shader.setGlobal functions will still be re-uploaded for every different material that uses the same texture for that property?

    if so, is there anyway I can tell unity not to re-upload the texture every single time?
  2. reefwirrax


    Sep 20, 2013
  3. Lulucifer


    Jul 8, 2012
    Try OnPreRender()