Last active
September 16, 2015 19:53
-
-
Save v3c70r/21312f645a6ab6746cc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec4 uvToEye(vec2 texCoord, float z) //screen to camera coordinate | |
{ | |
const vec4 viewport = vec4(0, 0, 1, 1); | |
vec3 ndcPos; | |
//ndcPos.xy = ((2.0 * texCoord.xy)-(2.0*viewport.xy))/(viewport.zw)-1; | |
ndcPos.xy = 2 * (texCoord.xy) - vec2(1.0, 1.0); | |
ndcPos.z = (2.0 * z - 1.0); | |
vec4 clipPos; | |
//clipPos.w = camMats.projMat[3][2]/ (ndcPos.z - (camMats.projMat[2][2]/camMats.projMat[2][3])); | |
clipPos.w = camMats.projMat[3][2] / ( ndcPos.z + camMats.projMat[2][2]); | |
clipPos.xyz = ndcPos*clipPos.w; | |
return inverse(camMats.projMat) * clipPos; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment