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

前端 未结 2 1220
一个人的身影
一个人的身影 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条回答
  •  -上瘾入骨i
    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

提交回复
热议问题