gl_ModelViewProjectionMatrix vs gl_ModelViewMatrix

妖精的绣舞 提交于 2019-12-08 06:45:00

问题


I am beginner at GLSL. I was reading a vertex shader code and I don't understande this part of code:

out vec3 position;
...
gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex; 
position=vec3(gl_ModelViewMatrix*gl_Vertex); 

What are the differences between gl_ModelViewProjectionMatrix and gl_ModelViewMatrix?

What are the differences between gl_Position and position?


回答1:


As you might suspect, gl_ModelViewProjectionMatrix is gl_ModelViewMatrix with the addition of the projection -- that is, the perspective camera distortion.

gl_Position is a predefined variable meaning "the projected result of this vertex shader" (all vertex shaders are required to assign a value to gl_Position), while the value "position" is an extra programmer-defined value that comes along for the ride (why is impossible to say, depends on the entire shader)



来源:https://stackoverflow.com/questions/15045562/gl-modelviewprojectionmatrix-vs-gl-modelviewmatrix

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