| 122 | |
---|

| 123 | So we need to do the inverse of this process by rearranging to solve for '''n''': |
---|

| 124 | |
---|

| 125 | {{{ |
---|

| 126 | #!latex-math-hook |
---|

| 127 | |
---|

| 128 | \begin{equation*} |
---|

| 129 | \label{eqn:vp to ndc} |
---|

| 130 | {\boldsymbol n} = \begin{pmatrix} |
---|

| 131 | \frac{ 2{\boldsymbol v}_x }w - 1\\ |
---|

| 132 | \frac{ 2{\boldsymbol v}_y }{h}\\ |
---|

| 133 | 2{\boldsymbol v}_z - 1\\ |
---|

| 134 | 1 |
---|

| 135 | \end{pmatrix} |
---|

| 136 | \end{equation*} |
---|

| 137 | }}} |
---|

| 138 | |
---|

| 139 | Okay, not so bad. The only real question is the {{{z}}} component of '''v'''. We can either calculate that value by reading it back from the framebuffer, or ignore it by substituting 0, in which case we'll be computing a ray passing through '''v''' that we'll then have to intersect with world geometry to find the corresponding point in 3-space. |
---|

| 140 | |
---|

| 141 | From here we need to go to clip coordinates, which, if you recall, are the homogeneous versions of the NDC coordinates (i.e. ''w'' != 1.0). Since ''w'' is already 1.0 and the transformation back to clip |
---|

| 142 | coordinates is a scale by ''w'', this step can be skipped and we can assume that our NDC coordinates are the same as our clip coordinates. |
---|

| 143 | |
---|

| 144 | === Clipping Space to View Space === |