- Home /
How can I copy an ARGBHalf RenderTexture to a Texture2D on Windows?
I'm rendering a texture full of debugging data; it has to be in the higher-precision ARGBHalf format to avoid various precision artifacts. The texture then needs to be written to a file, so I use Texture2D.ReadPixels() (yes, this drops the precision to only 8 bits per channel, but that's fine; I only need the higher precision during the intermediate stage). This works fine and dandy on OSX, but produces a blank texture on Windows. It's at least partly the fault of the render texture format, because changing that to ARGB32 at least produces some output (it's full of precision artifacts, but it's something).
Has anyone had success doing something like this on Windows?
Code snippet for what I'm doing so far follows. The DrawOutput() function renders some stuff to the active render texture; its actual contents are not relevant to the problem.
RenderTexture rt = RenderTexture.GetTemporary(imageWidth, imageHeight, 0, RenderTextureFormat.ARGBHalf);
RenderTexture.active = rt;
DrawOutput();
output.ReadPixels(new Rect(0, 0, imageWidth, imageHeight), 0, 0); output.Apply();
RenderTexture.ReleaseTemporary(rt);
RenderTexture.active = null;
File.WriteAllBytes("Output.png", output.EncodeToPNG());
Your answer
Follow this Question
Related Questions
ReadPixels returns RGBA(0,0,0,0) 0 Answers
RenderTexture turn my model to black, why ? 1 Answer
Render GUI elements to off screen camera 1 Answer
Assigning UV Map to model at runtime 0 Answers