0

http://www.cs.uaf.edu/2007/spring/cs481/lecture/01_23_matrices.html

I have just finished reading this, but i have 2 questions about multiplications.

gl_Position = gl_ProjectionMatrix*gl_ModelViewMatrix*gl_Vertex

This is the final screen coordinates (x,y) when i multiply them all. What if i only multiply gl_ModelViewMatrix*gl_Vertex or gl_ProjectionMatrix*gl_Vertex ? And what does gl_Vertex mean alone ?

BЈовић
  • 62,405
  • 41
  • 173
  • 273
deniz
  • 2,427
  • 4
  • 27
  • 38
  • In order to understand the full depth of what this line means, I'd really recommend to get an understanding of different coordinate spaces prevalant in 3D applications like model space, world space, eye/camere space, clip space, projection space, normalized device coordinate space, etc. http://www.glprogramming.com/red/chapter03.html – legends2k Feb 08 '13 at 10:49

2 Answers2

2

gl_Vertex is the vertex coordinate in world space. vertices and the eye may be arbitrarily placed and oriented in world space.

After multiplication with ModelViewMatrix, you get a vertex coordinate in 'eye-space', a coordinate system with the eye at 0,0,0. Multiplying by the projection matrix(and doing that homogenous coordinate system division thingy) gives you coordinates in screen space. Those are not pixel-coordinates yet, but some normalized coordinate system with 0,0,0 in the center of the screen/window. Viewport transform is last. It maps the image to window (pixel?) coordinates.

An explanation is given in:

http://www.srk.fer.hr/~unreal/theredbook/ chapter 3.

limbo
  • 21
  • 1
1

What if i only multiply gl_ModelViewMatrix*gl_Vertex or gl_ProjectionMatrix*gl_Vertex ?

Then the projection matrix (the 1st case) or model-view matrix (the 2nd case) will not take effect. If they are identity matrices, you will not see effect. If they are not, then your view angle or position might be wrong.

And what does gl_Vertex mean alone ?

gl_Vertex is the vertex coordinate that is passed to the input of the pipeline.

BЈовић
  • 62,405
  • 41
  • 173
  • 273
  • Thanks but will gl_ModelViewMatrix*gl_Vertex return something significant i can use in the future ? – deniz Feb 08 '13 at 10:26
  • @deniz Yes, it returns the vertex position after applying the model-view transformation. [This article](http://www.songho.ca/opengl/gl_transform.html) explains nicely the transformations – BЈовић Feb 08 '13 at 10:28