Home › Forums › GAMES在线课程(现代计算机图形学入门)讨论区 › 作业一的投影矩阵推导问题 Tagged: 作业一 This topic has 2 replies, 3 voices, and was last updated 3 months, 3 weeks ago by fluentcg. Viewing 2 reply threads Author Posts 2022年9月7日 at 下午6:00 #12780 Score: 0 竹名茂Participant 目前用webgl写作业。 作业中near和far的值都为正数,和课程里的不一样。 推出的矩阵怎么都有问题,百度了一大堆也没啥用。 推了一下午终于解决了。 首先把n和f都置反,和课程里的一样。 但在推导persp->ortho矩阵的时候,因为n和f都是负数,需要n平面的点乘以-n,f平面的中心点乘以-f。 结果正确了!!! 2022年11月3日 at 下午2:00 #14700 Score: 0 DSXParticipant projection << (1 / tan(eye_fov/2 * MY_PI / 180) / aspect_ratio), 0, 0, 0, 0, (1 / tan(eye_fov/2 * MY_PI / 180)), 0, 0, 0, 0, -(zFar + zNear) / (zFar – zNear), (-2 * zFar * zNear) / (zFar – zNear), 0, 0, -1, 0; This reply was modified 4 months, 4 weeks ago by DSX. 2022年12月7日 at 下午8:41 #16019 Score: 0 fluentcgParticipant 我推了下根上面不太一样呢 假设n,f 还是课中那样定义,都是负数,那么: t = -n*tan(theta/2) r = -aspect*n*tan(theta/2) b = -t l = -r (theta是eye_fov, aspect是aspect_ratio) 那么最终投影矩阵应该是: ( -1/(aspect*tan(theta/2)), 0, 0, 0, 0, -1/(tan(theta/2), 0, 0, 0, 0, (n+f)/(n-f), 2*n*f/(f-n), 0, 0, 1, 0 ) Author Posts Viewing 2 reply threads You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In