- Home /
Texture.ReadPixels() pixelated
Hi,
excuse my english. I try to create thumbnails for my menu. So I generate the Obj i want, and ReadPixel from a renderTexture on my Camera. In the Editor all looks fine, winBuild looks fine too, but if I build the Project for webGL I have 2 results:
the texture is in the right resolution and is pixelated(AA doesn't work)(mipmaps false).
IEnumerator createThumbNails()
{
int resolution = 260;
for (int i = 0; i < thumbNailsData.Count; i++)
{
//generateOBJ
//...
yield return new WaitForEndOfFrame();
RenderTexture renderTexture = createImageCamera.targetTexture;
RenderTexture.active = renderTexture;
Texture2D TempTexture = new Texture2D(resolution, resolution, TextureFormat.ARGB32, false);
createImageCamera.rect = new Rect(0, 0, resolution, resolution);
createImageCamera.Render();
TempTexture.ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0, false);
TempTexture.Apply();
thumbNailsSprites[i] = Sprite.Create(TempTexture, new Rect(0, 0, resolution, resolution), new Vector2(resolution / 2, resolution / 2));
createImageCamera.rect = new Rect(1, 40f / Screen.height, resolution / Screen.width, resolution / Screen.height);
}
}
the texture is in half resolution(mipmaps true).
IEnumerator createThumbNails()
{
int resolution = 260;
for (int i = 0; i < thumbNailsData.Count; i++)
{
//generateOBJ
//...
yield return new WaitForEndOfFrame();
RenderTexture renderTexture = createImageCamera.targetTexture;
RenderTexture.active = renderTexture;
Texture2D TempTexture = new Texture2D(resolution, resolution, TextureFormat.ARGB32, true);
createImageCamera.rect = new Rect(0, 0, resolution, resolution, true);
createImageCamera.Render();
TempTexture.ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
TempTexture.Apply();
thumbNailsSprites[i] = Sprite.Create(TempTexture, new Rect(0, 0, resolution, resolution), new Vector2(resolution / 2, resolution / 2));
createImageCamera.rect = new Rect(1, 40f / Screen.height, resolution / Screen.width, resolution / Screen.height);
}
}
Can someone help me out, how i will get 260x260 sprite not pixelated with AA like in the editor?
Thanks
Your answer
Follow this Question
Related Questions
Using Texture2D.ReadPixels with a RenderTexture that has AntialiasingAsPostEffect 0 Answers
How can I copy an ARGBHalf RenderTexture to a Texture2D on Windows? 0 Answers
RenderTexture turn my model to black, why ? 1 Answer
Can a Texture2D be created at runtime from a snapshot of a RenderTexture? 3 Answers
How do I get the raw pixels of a RFloat RenderTexture on the CPU? 5 Answers