Hi there,
I am just curious about something regarding how the Unity Camera, will “ingest” and “digest”, what is on the screen in regards to materials used.
Specifically, I am wondering, if I have a single 1024POT texture on MaterialA, this texture contains all game visual elements. VS, if I have 4 512POT textures on MaterialsA,B,C,D.
What I am wondering is, the game will have a game scene, a main menu, credits and a score scene. Each takes up a 512POT texture and 1 material, OR, each takes up 1/4 of the 1024POT texture and each use the same material.
Since not all are in the scene at one time, is there an advantage to using one method over the other and if so, why?
So, despite potentially, 3/4s of a 1024 sheet (texture) sitting unused, however, the computer must still process this material, as 1/4 of it is being rendered, why do I think it might be better to have a single 512 being processed and have the unused ones, unused in anyway, sitting quietly in the background, waiting their moment.
You do this with alarming regularity on the forums (premature optimisation questions). You should just finish the game then worry about if something is a problem if it ever becomes a problem (which it probably won’t be)
Regarding your problem:
ram consumption of a single 1024x1024 isn’t anything anyone worries about for a menu screen
if you want it to load faster, use a 512. But it might not end up being any faster in real world tests.
since you’re already arguing with me about it means you probably want to go with 512. So why don’t you?
The issue is I am transitioning everything from various atlases into the final ones. As the game is now mving from demo to finished. As far as alarming rate of “premature optimization”. For me, its that I can ask, hopefully get an answer and as a result not have to reset the atlases and amterials and all the corresponding sprites each, twice. Certainly a day or twos work.
And I am not arguing, I am asking.
Anyhow, I suppose the other question beyond texture memory is the number of materials. Granted, 1 material is better than 4, (beraring in mind, 4 materials is most likely minimal cost) but how much harder does the engine have to work to generate and maintain 3 extra materials.
I agree testing is the best way to find out, but my overall questions is like this…
If I have a scene, with 100 sprites, 25 “ABC”'s, 25 “ZYX”'s 25 “XTC”'s and 25 “SPC”'s, can one say which method is better? All one one texture and material, or each group with their own? Also, bonus points, if you keep in mind that the XYZ’s group pops in and out of scene.
What I am trying to get at is, is it harder for the engine’s rendering cpu to be have a group of new sprites entered into camera view, be part of a material that is already in view?
hippocoder is correct - you have nothing to worry about at these resource levels.
It’s just not worth worrying about for a simple scene - eg 4 textures and a few hundred quads.
I think you would benefit a little from understanding the gpu more, recommend googling.
But here is a Quick 2-second Summary:
Basically, every frame the gpu gets sent batches of vertices.
These are rasterized (projected to a 2d plane, fragments created for each pixel.) (VERTEX SHADER)
When the fragments are shaded, lighting equations can can calculate color, or a look up a pixel from a texture. (FRAGMENT SHADER)
The textures are preloaded onto the gpu before the frame. A typical mobile GPU has more than 8 texture units, the latest gtx 780 ti has 240! texture units.
All that being said, using texture atlases can help because it reduces the number of gl state changes.
So at the end of the day, 1 material with 1 texture is better than 2 materials with 2 textures.
CLEARLY Everything is much more involved than I am summarizing here.