- Home /
help packing 16 textures into a packedTexture using RenderTexture
I'm trying to figure out how to use RenderTexture ReadPixels and PackedTexture to pack textures most efficiently and quickly into a packedTexture.
I have an iphone screen that is 320x480. I want to use RenderTexture to render what the camera sees. Then capture that and put it into a packedTexture.
What numbers would I use for the RenderTexture size, readpixels size and packed texture size if I wanted to pack the info into a the packedTexture as fast and efficiently as possible?
Shouldn't I be able to get a 4x4 grid of 16 pictures all 256x256 this way?
Here are selected lines in the code that have numerical input.
rt = new RenderTexture(256,256,24);
textures[counter] = new Texture2D (256, 256, TextureFormat.RGB24, false);
textures[screencounter].ReadPixels (Rect(0, 0, 256, 256), 0, 0);
giantTexture.PackTextures(textures,0,1024,false);
var bytes = giantTexture.EncodeToPNG();
What I was hoping to end up with is a 4x4 grid of 256x256 pixels each images of the 320x480 image. But what I get each 256x256 has only part of the frame and they are not packed 4x4 but smaller and staggered.