I am currently trying to get the distance from my camera plane (using an orthographic camera) to an object that I am rendering in order to derive the depth from it. Essentially I am trying to do the following:
varying float distToCamera;
vec4 cs_position = glModelViewMatrix * gl_Vertex;
distToCamera = -cs_position.z;
gl_Position = gl_ProjectionMatrix * cs_position;
as shown within this source:
However, within Cinder and GLSL, whenever I try to access either the gl_Pixel or glModeViewMatrix, my program crashes. So I am wondering if there is a replacement for these two variables or what I am trying to access in Cinder? I have had a look at the gitHub source through the link: https://github.com/cinder/Cinder/blob/master/src/cinder/gl/GlslProg.cpp But I can't find anything conclusive.
I am fine with the fragment shader, it's just this part in the vertex shader that's giving me trouble. I am new to Cinder and OpenGL (to a lesser degree) so any help would be much appreciated!