Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Range of Motion Vectors

Discussion in 'Shaders' started by uncloned, Jul 9, 2020.

  1. uncloned

    uncloned

    Joined:
    Dec 15, 2015
    Posts:
    2
    Hello, currently, I'm working on a project with Unity's motion vectors. I'm reading the raw vectors from the texture and write these in a separate file. Can someone tell me in what range these vectors are? It seems that the vectors are in the range of -1 and 1 but what is the normalization term? Is U divided by the screen resolution width and V by the height? Under this assumption, the final pixel offset is a result of U * width and V * height but the result seems to be wrong when the camera moves, too.

    I've tried to visualize the problem in the attached image.
    flow.jpg

    It would be nice if someone can give me some more details about motion vectors because I can't find something in the docs.

    Thank you!
     
  2. Namey5

    Namey5

    Joined:
    Jul 5, 2013
    Posts:
    188
    Motion vectors are simply the screen space velocity of pixels between frames and are stored in 16-bit floating point, so there isn't actually any normalization. If a pixel is already on screen (i.e. between [0,1] in screen space) then its velocity will be somewhere in the range of [-1,1] depending on the direction of motion. However, if something was offscreen in the previous frame, then the motion vectors can actually be well outside that range.

    If you needed to normalize these vectors to store in an image file then you would probably want to convert the bits to from floating point to integer (by using something like asuint()).