HDRP-Custom-Passes
HDRP-Custom-Passes copied to clipboard
Issues with motion vector for camera rotation
Hello!
I've tried to run the CopyBuffer scene to see how motion vectors work. And there is something weird about them: when the camera is moving (translation), they seem to work correctly, with the objects being kind of visible in the motion vector display (picture 1). However, when the camera is simply looking around (no translation, rotation only), it seems that the objects don't appear (picture 2).
I'm not sure if this is just a misunderstanding of motion vectors from me or a real error, but any info about this matter would help me a lot!
Edit: I tried to copy the render texture to a normal texture in order to inspect the values using the following code, but it seems RGHalf is not the right format. The RenderTextureFormat is 29, which ... doesn't exist in the enum?
RenderTexture.active = motionVectors;
Texture2D tex = new Texture2D(motionVectors.width, motionVectors.height, TextureFormat.RGHalf, false);
tex.ReadPixels(new Rect(0, 0, motionVectors.width, motionVectors.height), 0, 0);
tex.Apply();
byte[] bytes = tex.EncodeToEXR(Texture2D.EXRFlags.CompressZIP);
System.IO.File.WriteAllBytes(path, bytes);
Camera translation:
Camera rotation only:
Unity: 2021.2.16f1 HDRP: 12.1.6
Could you provide the complete code?
What do you mean the complete code? I just ran the CopyBuffer scene from this repo with no modifications.