1
$\begingroup$

I am trying to implement clipping in my simple renderer, but i have a trouble with setting the boundaries. I used the same projection matrix that is in OpenGL. The problem is, the vertices that are behind the camera(z<near) when mapped to NDC are bigger than 1(but they should be less than -1), so i can't use vertex.z > w. enter image description here

$\endgroup$
2
  • $\begingroup$ This is the expected behavior of a perspective transformation. Anything beyond the far plane is mapped to the range (1, 2f/(f-n)) and anything behind the camera gets mapped to (2f/(f-n), infinity). If you want test for "behind the camera", you can check to see if the value is greater then 2f/f-n. Once an object has been transformed into clip space it is usually not examined further. Are you implementing a software pipeline? $\endgroup$
    – pmw1234
    Jul 29, 2020 at 12:43
  • $\begingroup$ I decided to clip near plane in world space and for other planes in NDC. Works quite well. Thanks for reply, though! $\endgroup$ Jul 30, 2020 at 13:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.