Switching Texture in Shader or Script
I want to write a shader that has couple different sets of textures. I am planning to use a property field, or maybe #define to switch witch texture should be used. Alternatively, I might use a script that references these textures and swap it out into the material when needed. The question is which approach is better in the two situations and why:
-Being switched out constantly every couple seconds
-Being switched out only sometimes.
The reason why I am asking this is because I dont know if the textures get loaded into VRam if it is not used in the shader. If it does load all the textures referenced in the shader, it will be a big waste of memory bandwith I think? So in that case maybe using script is a better approach but its the same if it doesn't load it?
Thank you
Answer by Naphier · May 13, 2016 at 06:04 PM
I think you'll be hard pressed to find a direct answer to this here. My best suggestion to you is to test it out and observe the profiler.
The only problem is that I can't see the vram usage on the profiler so I don't know if it is taking up a lot of space.
In the profiler under the $$anonymous$$emory section the "Texture" memory is the key indicator for vram usage.
Your answer
![](https://koobas.hobune.stream/wayback/20220612080716im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Tree Creator textures seem missing 1 Answer
Tint a UI sprite with a gradient 0 Answers
Saving changes made on a material from an editor script 1 Answer
Custom split color font 0 Answers
Changing alpha channel of the tint color on a material 3 Answers