HDRP-Custom-Passes icon indicating copy to clipboard operation
HDRP-Custom-Passes copied to clipboard

Issues with motion vector for camera rotation

Open adepierre opened this issue 2 years ago • 2 comments

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: image

Camera rotation only: image

Unity: 2021.2.16f1 HDRP: 12.1.6

adepierre avatar Mar 23 '22 16:03 adepierre

Could you provide the complete code?

HsiangYangChu avatar May 31 '22 05:05 HsiangYangChu

What do you mean the complete code? I just ran the CopyBuffer scene from this repo with no modifications.

adepierre avatar May 31 '22 09:05 adepierre