1

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?

peaceman
  • 203
  • 2
  • 7
  • 12
  • 2
    There are [many great online tutorials](http://www.opengl.org/wiki/Getting_started#Tutorials_and_How_To_Guides) for getting started with OpenGL. Why are you reading through random, undocumented GLSL code to figure it out? – Nicol Bolas Feb 23 '13 at 23:53

1 Answers1

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)

bjorke
  • 3,295
  • 1
  • 16
  • 20