I know that openGL only has the concept of the ModelView Matrix which converts vertex positions directly from object to eyeSpace.
Anyways, I am rendering multiple glutSolidSpheres (just for testing) at different positions using glTranslate(). Now in my GLSL shader I want to write each fragments World position to a texture but I have only access to the gl_ModelViewMatrix which brings things one step too far.
Is there any quick of way doing that with openGLs functionality or would I have to roll my own transformation matrices?
Aren’t Eye Space and World Space the same thing, since in OpenGL, the eye is always considered to be at vec3(0.0,0.0,0.0)? Or am I getting confused with my terminology again?? I know the names for the different coordinate systems tends to differ between HLSL/Cg and GLSL.
The world space concept is completely your creature. OpenGL doesn’t (and shouldn’t) know about it.
Generally, your modelview matrix = inverse(Camera_Model) * Object_Model,
where X_Model is a transformation of something’s coordinate system to the world.
Now, in order to capture world space coord, you can grab (Object_model * vertex_local_coord) and pass to the fragment shader.
I simply pass in a uniform with a translation and apply that to the gl_Vertex in my shader. Works fine, anyways I just wanted to know if there was a certain way its ment to be done and you answered that question just fine!
@toneburst:
No, World/Model space is the coordinate system of all your objects in the world. For instance you can draw an object with a z value bigger than 0.
Eye space (which is after you apply the ModelViewMatrix) is always looking down the negative z Axis, so that even if you are looking at you object with positive z, that would become negative in eyespace (basically if a z value becomes positive in eyespace, its behind the camera and thus cant be seen).