which format of textures is best suitable for unity .which support both mobile and webplayer
TGA
OR
PNG
which format of textures is best suitable for unity .which support both mobile and webplayer
TGA
OR
PNG
It doesn’t really matter what you import them as, Unity will compress them to the required format when you build your game.
I’d stick with TGA, it’s a solid format and doesn’t have the alpha/transparency confusions that PNG can have.
I’ve learned that the most important thing is to use dimensions that are powers of two (i.e. 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, …) because Unity will (at least sometimes) rescale textures to such dimensions (instead of padding them).
Only if you have “Non Power of 2” set to something other than “None”.
–Eric
OK, but as far as I understand it, it is set to something else (“ToNearest”) by default, and one has to choose the “Advanced” Texture Type to change this default.(Actually, now I wonder what happens if the GPU doesn’t support non-power of 2 dimensions.)
Unfortunately, I think the reality of NPOT textures in Unity is far worse than this. I spoke with Aras about this at the beginning of the year (Jan 26, 2012) :
But regardless of whether it is only done on-demand in Unity 4, NPOT textures will be a scaled-up, POT texture if you use them on anything but Unity GUI stuff.
A texture doesn’t know if you’re using it for Unity GUI stuff or not so I’m not sure I follow that.
–Eric
I guess Daniel meant unless you set the texture type to GUI. Where from what i’ve read Unity will create two versions, one upscaled to fit POT, one ‘placed’ on the next POT so it isn’t scaled, but still uses a POT texture. AFAIK Unity simply doesn’t support NPOT textures other than rendertextures?
As for PNG vs TGA, it makes no difference since the source format is irrelevant to Unity. It is of course very relevant in terms of maintaining quality before Unity get it, so lossy compression is generally a bad idea (e.g jpeg). However neither PNG or TGA is lossy so it doesn’t matter. Personally I prefer PNG for the improved lossless compression it offers, but as mentioned it can be a pain to work with due to how different programs deal with alpha.
Right, the actual source texture format does not matter. Use whatever is the most convenient for you.
Now, about power-of-two things: currently (Unity 3.5 and 4.0), when a texture size ends up being non power of two (inspector shows that), then at runtime two textures will be created, at next power of two in size. One of them padded with empty space (used in GUI), another bilinearly upscaled to power of two size (used in any 3D context).
This makes NPOT texture sizes be not exactly efficient, in both loading speed and memory usage.
However! It looks like in Unity 4.1 we’ll be fixing that. Which means, on a GPU that can support NPOT texture sizes (most modern PC mobile GPUs can), all this silliness of slow loading time and upscaling will go away. So that’s better. Keep in mind that internally on the GPU a NPOT texture is still not as efficient as POT sized one (uses slightly more memory, possibly slower at sampling), but at least the major stupidity of us creating two textures behind the scenes will be gone. On old GPUs or less capable platforms (Flash), the old way will still be the case, since there NPOT textures just don’t exist.
That is great news Aras.
Just one small point, could you add a flag to the texture to allow the developer to query it to see if a texture is single NPOT or if Unity has been forced to use the fallback to the old way. In the past i’ve had to work with NPOT textures in Unity and the code is based on the assumption that two textures would have been made. I think in order for my code to continue to work i’d need to know whether Unity has made a single NPOT texture or using the old (2 texture) method.
Thanks