# Unproject considering parallax depth

How can I take screen coordinates (or alternatively world coordinates on the 'primary' parallax plane) and find out what world coordinates they translate into when taking parallax depth into account?

I want to be able to tell if a rectangle is under the mouse cursor. I'm using libGDX and the ParallaxCamera class from the tests module. This means depth is modelled in two dimensions, where 1 == primary plane, 0 == pinned to the screen, 0,5 == scrolls at half the rate of the primary plane.

This is trivial in the primary parallax plane, as libGDX's camera has a handy unproject method. However, I can't find any examples that use the 'parallax matrix', as this is typically passed into a SpriteBatch#setProjectionMatrix rather than being used in internal camera calculations.

I don't understand the mathematics enough to figure this out. If anyone reading this can link to any very basic explanations of the mathematics behind projecting things with parallax depth into screen space and vice versa, I'd be really grateful to read it.

• A Parallax effect can be easily achieved. Say you have 2 sprites. Sprite1 is on layer 1 (this.layer=1), Sprite2 is on layer 0.9. When we are rendering our sprites, we apply a scale transformation on the matrix of the layer value. This allows Sprite2 to move slower than Sprite1 – Jackson Feb 27 '15 at 17:53