坐标系[-1,1] [英] Coordinate System [-1, 1]

查看:188
本文介绍了坐标系[-1,1]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对OpenGL坐标系的工作方式感到困惑.我知道您从对象坐标开始-一切都在其自己的系统中定义.然后,通过应用矩阵,坐标变为世界坐标.通过应用另一个矩阵,您可以获得视图坐标.然后,如果您使用的是3D模式,则可以应用透视矩阵.最后,您剩下一组可能不是[-1,1]的坐标. OpenGL如何知道如何从[-1,1]对它们进行规范化?它怎么知道该如何剔除它们?在着色器中,只是为glPosition提供了坐标,它不知道已经进行了多次转换.我知道归一化坐标矩阵的视图涉及平移和缩放,但是我们从来没有在OpenGL中显式地为其创建矩阵. OpenGL是否使用自己的隐藏矩阵将传递给glPostion的坐标转换为归一化的坐标?

I am confused on how the OpenGL coordinate system works. I know you start with object coordinates -- everything defined in its own system. Then by applying a matrix, the coordinates change to world coordinates. By applying another matrix, you have view coordinates. Then if you're working in 3D, you can apply a perspective matrix. In the end, you are left with a set of coordinates which likely are not from [-1, 1]. How does OpenGL know how to normalize them from [-1, 1]? How does it know what to clip them out? In the shader, glPosition is just given your coordinates, it doesn't know that there have been through several transformations. I know that a view to normalized coordinate matrix involves a translation and a scale, but we never explicitly make a matrix for that in OpenGL. Does OpenGL use its own hidden matrix to translate from coordinates passed to glPostion to normalized coordinates?

推荐答案

已弃用的固定函数顶点转换在中进行了说明https://www.opengl.org/wiki/Vertex_Transformation

Deprecated fixed function vertex transformations are explained in https://www.opengl.org/wiki/Vertex_Transformation

基于着色器的渲染可能在每个变换步骤中使用相同或非常相似的数学运算. glPosition和设备坐标之间缺少的步骤是透视划分(就像LJ快速注释一样),其中xyzw坐标转换为xyz坐标. xyzw坐标是3维坐标的齐次坐标,它使用4个分量表示位置.

Shader based rendering is likely to use same or very similar math for each transformation step. The missing step between glPosition and device coordinates is perspective divide (like LJ commented quickly) where xyzw coordinates are converted to xyz coordinates. xyzw coordinates are homogeneous coordinates for 3-dimensional coordinates that use 4 components to represent a location.

https://en.wikipedia.org/wiki/Homogeneous_coordinates

这篇关于坐标系[-1,1]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆