模型坐标转换到NDC
1.模型坐标到世界坐标
2.世界坐标到观察坐标
3.观察坐标到裁剪坐标
4.裁剪坐标透视除法转换为NDC(归一化设备坐标)
透视投影
其中:
nearClipPlaneHeight = 2 * Near(摄像机到近裁剪平面的距离)*tan(FOV/2)
farClipPlaneHeight = 2 * Far(摄像机到远裁剪平面的距离)tan(FOV/2)
Aspect = nearClipPlaneWidth/nearClipPlaneHeight = farClipPlaneWidth/farClipPlaneHeight
设当前物体所在观察坐标坐标为V(x,y,-z)则此时所在
视椎体平面的高度:height = (-z)tan(FOV/2)
视椎体平面的宽度:width = Aspect * height = Aspect * (-z)tan(FOV/2)
则当:
-height < y < height => z < y * cot(FOV/2) < -z
-width < x < width => z <( x * cot(FOV/2))/Aspect < -z
near < z < far => z < -z(Far + Near)/(Far - Near) - 2NearFar/(Far - Near) < -z