2
\$\begingroup\$

[Purpose]:
I need to save the Unity camera view into a .exr file.

[Error]:

Remapping between formats 74 -> 73 is not supported

[What I've tried]:
I tried the official solution.

First, I set the renderTexture format as RenderTextureFormat.DefaultHDR to make sure that it stores HDR data.

renderTex = new RenderTexture(renderWidth, renderHeight, 16, RenderTextureFormat.DefaultHDR);

Then, I tried to save the renderTexture data into a .exr file.

Texture2D image = new Texture2D(2, 2, TextureFormat.RGB9e5Float, false, true);
image.ReadPixels(new Rect(renderWidth / 2, renderHeight / 2, 2, 2), 0, 0);
image.Apply();

byte[] bytes = image.EncodeToEXR(Texture2D.EXRFlags.CompressZIP);
File.WriteAllBytes(Application.dataPath + "/HDRs/"+tag+"reflectance.exr", bytes);

The error may be related to the RenderTexture and Texture2D format. I tried to change the Texture2D format to TextureFormat.RGBAFloat. The error changed:

Remapping between formats 74 -> 52 is not supported

It seems that the Texture2D format cannot store the HDR RenderTexture data, and the original data gets truncated. I've tried all the formats tagged "HDR" as listed in the TextureFormat documentation. None of them work, some of them are unsupported... What can I do to save a HDR camera view into a .exr file?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

There is a solution: have equivalent formats for both, ARGBFloat for the RT and RGBAFloat for the texture.

Thanks to @AcidArrow from this Unity forum.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .