Separate Model and View Matrix

Hello everyone,

I am currently programming a demo using OpenGL 4.1 but am confused about moving models within the world.

I used to move the models by using separate ModelMatrix for moving the models and ViewMatrix to move the camera around the world and send those two matrices along with the ProjectionMatrix to the shader to be concatenated. The lighting was created and as far as my eyes could tell, it was correct.

Then I found that using that method is not optimal. According to “The Perils of World Space” the ModelViewMatrix should be concatenated at CPU level using doubles. While I do not need the accuracy he is looking for I agree that concatenating the matrices in the Vertex Shader is not optimal as it is done on a per-Vertex basis rather than a per-Object basis.

I concatenated them and sent them as one matrix but now my lights “move” with the camera. I’ve tried multiplying the light position with the ModelViewMatrix to get it into “Eye” space but I am pretty sure I need to get the lights into “World” space which is now unavailable to the shader.

So my questions are:

  1. How do I move objects around in OpenGL 4.0+?
  2. How do I make the lights stay in their proper positions?

What about simply sending eye space positions for lights ?

  1. http://www.flashbang.se/archives/133
  2. essentially you have to compensate for the movement of the camera by using an inverted matrix on the lights, though i disagree that the ModelViewMatrix have to me be concatenated on the CPU as the gpu does that basically for free, if it’s all you ever is going to use then go right ahead, but don’t if you really need world space.

I also disagree with his other points, 32 bit floats are good enough, at least for openGL based rendering.
If you would make a model 1000 miles that requires sub inch resolution, then yea his argument would be correct, assuming of course that you have a 2000K x 1000K display, but you dont, and that’s my point.
A. a model 1000 miles wide would be broken up in smaller parts using LOD and stuff like that and thus problem solved.
B. and even if it wasn’t it still wouldn’t matter as the precision error would be invisible unless you really mess it up.
C. the stuff you render doesn’t need to be at the same scale all the time, an FPS game and a rendering of a solar system doesn’t have to use the same units, even if you move from one to another.
D. if all else fails using the ancient art of CHI-TING is allowed, something the author of that article forgot.

I concatenated them and sent them as one matrix but now my lights “move” with the camera. I’ve tried multiplying the light position with the ModelViewMatrix to get it into “Eye” space but I am pretty sure I need to get the lights into “World” space which is now unavailable to the shader.

Lighting is the very next tutorial on that site. And it does lighting in camera space.