About HDR support
coldwarrior5 opened this issue · 6 comments
Hi Keijiro, thank you so much for the demo code, it is very informative.
I have been playing with asyncGPUReadback and it is very useful however I am wondering if it supports HDR. I have tried using GetData with and I tried putting RenderTexture using both ARGBHalf a.k.a. DefaultHDR and ARGBFloat. Neither work, I just get an empty array, i.e. array of zeroes. And quite peculiar if I use ARGBHalf I get exactly half the pixels I should from GetData method, I guess it just combines two ARGBHalf into one ARGBFloat.
I have never tried it with the HDR formats, but personally I think they should work. So, could you submit a bug report about it from the Unity Editor? The graphics team will look into it.
I too think it should work, maybe I did something wrong.
I initialized textures like this:
_renderTexture = new RenderTexture(_frameWidth, _frameHeight, 24, RenderTextureFormat.DefaultHDR); _texture2D = new Texture2D(_frameWidth, _frameHeight, TextureFormat.RGBAHalf, false);
Then in OnPreRender i called:
_camera.targetTexture = _renderTexture;
In OnPostRender I did:
_camera.targetTexture = null; _requests.Enqueue(AsyncGPUReadback.Request(_renderTexture));
And in Update I did:
_colorNativeArray = request.AsyncGpuReadbackRequest.GetData<Color>(); _colorNativeArray.CopyTo(_colorArray); _tex.SetPixels(_colorArray); _tex.Apply(); SaveToDisk(_tex.EncodeToEXR(), _saveFormat);
Would you say I did something improperly?
Did it work when using non-HDR?
Yup, it did, well I'll report it. Thank you for the help.
You shouldn't use RenderTextureFormat.DefaultHDR
because the actual pixel format is not deterministic with it. If you use GetData<Color>()
, it should be 4 float component format, like ARGBFloat
.
Furthermore, you have to reorder the color components.
ARGBFloat
-> A, R, G, BColor
(C# struct) -> R, G, B, A
Personally I think it's better to use a compute shader to resample and reorder data.
I'm closing this issue now. Please feel free to reopen for further questions.