Created
May 30, 2016 00:58
-
-
Save galek/7bac754ccf2ce3a2b595b18be6e30937 to your computer and use it in GitHub Desktop.
Compute frag pos in view space
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
// Compute frag pos in view space | |
vec3 fragPos; | |
{ | |
float depth = gl_FragCoord.z; | |
fragPos.z = u_lightingUniforms.projectionParams.z | |
/ (u_lightingUniforms.projectionParams.w + depth); | |
vec2 screenSize = 1.0 / RENDERER_SIZE; | |
vec2 ndc = gl_FragCoord.xy * screenSize * 2.0 - 1.0; | |
fragPos.xy = ndc * u_lightingUniforms.projectionParams.xy * fragPos.z; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment