Hello,

I would like to convert mouse cursor coordinates (x, y) into 3 dimensional coordinates (x, y, z).

Note that my question is not about object picking technique but having sort of adjustable depth buffer for object drawing.

For example, I would like to create an object in x, y, z when I click the left mouse button.

So it should be x depth away from camera but object should be drawn in a position where exactly I click from the screen + depth buffer inside.

```
glm::mat4 viewMatrix = glm::lookAt(position, target, up);
glm::mat4 projectionMatrix = glm::perspective(glm::radians(cameraFrustum.fov), cameraFrustum.AR, cameraFrustum.nearPlane, cameraFrustum.farPlane);
void InputManager::mouse_cursor_callback(GLFWwindow* window, double xpos, double ypos) {
GLfloat x = xpos;
GLfloat y = glWindow.height - 1 - ypos;
GLfloat z = 0.0f;
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
glWindow.glMouse = glm::unProject(glm::vec3(x, y, z),
glWindow.camera->viewMatrix,
glWindow.camera->projectionMatrix,
glm::vec4(glWindow.x, glWindow.y, glWindow.width, glWindow.height));
}
```

I am trying to make it done with above but it returns z as 1 always.

Is there a way I can achieve my goal?

Thanks,