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

雨燕双飞 提交于 2019-12-01 04:20:05

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!