I’m experimenting with AsyncGPUReadbackRequest and have pulled the code from AsyncCaptureTest/Assets/AsyncCapture.cs at master · keijiro/AsyncCaptureTest · GitHub
The request is pulled out of a queue like this:
var req = _requests.Peek();
var buffer = req.GetData();
When I try to use the buffer to populate a texture, I get this:
SetPixels32 called with invalid number of pixels in the array
UnityEngine.Texture2D:SetPixels32(Color32[ ])
Capture:SaveBitmap(NativeArray`1, Int32, Int32, Int32, String, Int32) (at Assets/Capture.cs:113)
Capture:Update() (at Assets/Capture.cs:64)
and when I check the sizes:
buffer size is 1425424 texture size is 712712
In other words, the NativeArray buffer returned by the request is twice as big as the texture I created to hold it (the texture is the expected size)
If I trim the array to the right size then go ahead and encode it to a png, when I look at it the image it looks vaguely correct but as though every pixel has been interleaved with some other data.
I’m on 2018.2 - any ideas?