- Home /
which TextureFormat should I use for new Texture2D on iphone
Which texture format should I use for a new Texture2D on iphone.
var screenShot = new Texture2D(320,480, TextureFormat.RGB24, false);
file:///Applications/Unity/Documentation/ScriptReference/TextureFormat.html Should I use the ios ones? or the standard ones like RGB24.
TextureFormat.RGB24
PVRTC_RGB2
PowerVR (iOS) 2 bits/pixel compressed color texture format. PVRTC_RGBA2
PowerVR (iOS) 2 bits/pixel compressed with alpha channel texture format PVRTC_RGB4
PowerVR (iOS) 4 bits/pixel compressed color texture format. PVRTC_RGBA4
PowerVR (iOS) 4 bits/pixel compressed with alpha channel texture format
Answer by KvanteTore · Mar 23, 2012 at 07:42 AM
Generally, you should use a compressed texture if you can get away with it, as they are both smaller in download size and faster to render. Compressing the textures introduces some artifacts though, and really it depends on your quality requirements if it's acceptable.
If the 2bits per pixel ones look ok for your game, then that's good, otherwise try the 4bpp. Use RGB24 or ARGB32 only if the compressed textures look unacceptable.
I'm trying to use EncodeToPNG after I grab the pixels. The docs say EncodeToPNG works only on RGB24 texture formats. I'm trying to grab screenshots as fast as possible using RenderTexture. So far on the iphone I get about 3 per second using the RGB24 code. Is there someway to use EncodeToPNG with the ios textures? OR maybe is there another encoding function that could use them?
rt = new RenderTexture(320, 480, 16);
in the update loop... var screenShot = new Texture2D(320,480, TextureFormat.PVRTC_RGB2, false);
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, 320, 480), 0, 0);
var bytes:byte[] = screenShot.EncodeToPNG();
actually this line is bugging out as bad thread access. Am I missing some other setting before using this texture type on iphone?
var screenShot = new Texture2D(320,480, TextureFormat.PVRTC_RGB2, false);
I'm also getting a bat thread access with PVRTC_RGB2. Did you solve this issue?
Unity changed the behaviour of reading pixels from the screen lately (last paragraph of http://docs.unity3d.com/Documentation/ScriptReference/Texture2D.ReadPixels.html). Try yielding and reading the pixels the next frame.
Your answer
![](https://koobas.hobune.stream/wayback/20220613065436im_/https://answers.unity.com/themes/thub/images/avi.jpg)