Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glm::unProject with perspective projection matrix fails #119

Closed
alzhuravlev opened this issue Sep 30, 2013 · 5 comments
Closed

glm::unProject with perspective projection matrix fails #119

alzhuravlev opened this issue Sep 30, 2013 · 5 comments
Assignees
Labels
Milestone

Comments

@alzhuravlev
Copy link

file: glm/gtc/matrix_transform.inl
method: glm::unProject

Actual:
...
tmp = tmp * T(2) - T(1);
...

Expected:
...
tmp.x = tmp.x * T(2) - T(1);
tmp.y = tmp.y * T(2) - T(1);
...

Otherwise when we unproject value in perspective projection depth value (tmp.z) will be corrupted by tmp * T(2) - T(1);

@ghost ghost assigned Groovounet Oct 5, 2013
@Groovounet
Copy link
Member

Hi,

That's an interesting report which is actually a feature request, not a bug.
My guess is that you might be a Direct3D user or a software rendering user.

It's odd but OpenGL Z axis is actually define between -1 and 1 on the contrary with Direct3D that defines it between 0 and 1. So I guess I need to add functions for [0, 1] for both "unProject" and "project", not sure what to call them....

Thanks,
Christophe

@JesseTG
Copy link

JesseTG commented Mar 5, 2016

Has this been fixed already? 0.9.6 was a while ago.

@Groovounet
Copy link
Member

This wasn't fixed, I applied the proposed fix but I probably need to double check the math...

@JesseTG
Copy link

JesseTG commented Mar 6, 2016

Ah, ok. Could've sworn I'd seen something like this in the code base somewhere before...

@Groovounet
Copy link
Member

This is fixed in GLM 0.9.8.

Thanks,
Christophe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants