Search Unity

Calculate camera projection matrix so that it covers a specified rect

Discussion in 'General Graphics' started by customphase, Dec 6, 2019.

  1. customphase

    customphase

    Joined:
    Aug 19, 2012
    Posts:
    176
    We have a bunch of mirrors in our game, and we need to efficiently render reflections for all of them. Usual planar reflection probe algorithms dont account for the reflection surface area and as a result render more than necessary (and standard HDRP planar reflection probes dont align to the reflection vector at all, so you have to crank up the FOV to get reflections on grazing angles, which is obviously bad). How would i go about calculating the projection matrix that would only cover a specified rect? Heres the illustration of couple examples of what i mean (top-down view, green is the rect, blue is the frustum, black is the reflection camera). Also I dont need oblique projection, since im doing clipping in the shader and i need a proper control over far clip plane (since with oblique projection far clip plane doesnt clip as expected).
    ProjectionExample.png
     
  2. customphase

    customphase

    Joined:
    Aug 19, 2012
    Posts:
    176
unityunity