Tag Info

Hot answers tagged


What you essentially want is the depth in camera coordinates, but relative to model, not camera. the easiest way to achieve that is to calculate the position of the origin of a model coordinate system in camera coordinates. ... vec4 cs_position = glModelViewMatrix * gl_Vertex; vec4 origin_position = glModelViewMatrix * vec4(0,0,0,1); distToOrigin = ...


calculate a bounding volume of the object (sphere, convex hull, box - depends on your speed/accuracy needs), this needs to be done only once - at initalization while rendering, for each object: transform camera (origin, direction) to object space project bounding volume on camera direction axis and subtract camera origin projection to retrieve min/max ...

Only top voted, non community-wiki answers of a minimum length are eligible