Unproject gl_FragCoord

Hi all!

I want to unproject the gl_FragCoord to get the 3D coordinats in camera space. I multiply the inverse projection matrix against gl_FragCoord but this doens’t work. Any hint?

Thank you in advance!
Greetings Mario

Well, I guess it should work the way you’re doing it, but I would recommend you compute coordinate in the vertex shader by multiplying the vertex with the modelview matrix and pass it to the fragment shader instead. Should be faster unless you are using extreme amounts of polygons.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.