Projecting a 3D point to 2D screen space using a perspective camera matrix

前端 未结 2 1221
一个人的身影
一个人的身影 2021-01-12 09:57

I am attempting to project a series of 3D points onto the screen using a perspective camera matrix. I do not have world space (or consider it being an identity matrix) and m

相关标签:
2条回答
  • 2021-01-12 10:51

    Your problem is that you forget to perform the perspective division.

    Perspective division means that you divide x, y and z component of your point by its w component. This is required for transforming your point from Homogeneous 4D Space to Normalized Device Coordinates System (NDCS) in which each component x, y or z falls between -1 and 1, or 0 and 1.

    After this transformation, you can do your viewport transformation (multiply points by screen width, heigth etc).

    There's a good view of this transformation pipeline in Foley's book (Computer Graphics: Principles and Practice in C), you can see it here:

    http://www.ugrad.cs.ubc.ca/~cs314/notes/pipeline.html

    0 讨论(0)
  • 2021-01-12 10:59

    For questions such as this one I would suggest an excellent resources: http://scratchapixel.com/lessons/3d-advanced-lessons/perspective-and-orthographic-projection-matrix/ It really goes in the detail of the projection matrix. They are more lessons on the topic of camera, constructing camera rays, etc. You will need to do some digging.

    0 讨论(0)
提交回复
热议问题