I'm not sure how to use the Unproject method provided by GLM.
Specifically, in what format is the viewport passed in? And why doesn't the function require a view matrix as well as a projection and world matrix?
A bit of history is required here. GLM's unproject is actually a more or less direct replacement for the
Now for the actual use:
When applied you simply end up by converting the provided window coordinates back to the object coordinates, more or less the inverse of what your render code usually does.
A half-decent explanation on the original
The viewport is passed in as four floats: the x and y window coordinates of the viewport, followed by its width and height. That's the same order as used e.g. by
As KillianDS already pointed out, the
As you can see, the matrix passed as the second argument basically is the product of a translation and a perspective transformation.