Search Unity

Question Jitter Calculation in HDRP

Discussion in 'High Definition Render Pipeline' started by nishikinohojo, May 19, 2023.

  1. nishikinohojo

    nishikinohojo

    Joined:
    Aug 31, 2014
    Posts:
    46
    Code (CSharp):
    1.  
    2. var planes = origProj.decomposeProjection;
    3.  
    4. float vertFov = Math.Abs(planes.top) + Math.Abs(planes.bottom);
    5. float horizFov = Math.Abs(planes.left) + Math.Abs(planes.right);
    6.  
    7. var planeJitter = new Vector2(jitterX * horizFov / actualWidth,
    8.     jitterY * vertFov / actualHeight);
    9.  
    10. planes.left += planeJitter.x;
    11. planes.right += planeJitter.x;
    12. planes.top += planeJitter.y;
    13. planes.bottom += planeJitter.y;
    14.  
    15. // Reconstruct the far plane for the jittered matrix.
    16. // For extremely high far clip planes, the decomposed projection zFar evaluates to infinity.
    17. if (float.IsInfinity(planes.zFar))
    18.     planes.zFar = frustum.planes[5].distance;
    19.  
    20. proj = Matrix4x4.Frustum(planes);
    21.  
    22.  
    How did you guys end up something like this.
    I know this jitter gives up very nice result. But what the hell is this!
    I hate plane calculation and died immediately, now I'm a ghost. Maybe someone very smart can tell me the detail of this calculation mathematically?

    Especially these lines look important. But so obscure for me.
    Code (CSharp):
    1. float vertFov = Math.Abs(planes.top) + Math.Abs(planes.bottom);
    2. float horizFov = Math.Abs(planes.left) + Math.Abs(planes.right);
     
  2. nishikinohojo

    nishikinohojo

    Joined:
    Aug 31, 2014
    Posts:
    46