SHARE
TWEET
Untitled
a guest
Dec 27th, 2014
4
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- //FRAGMENT SHADER
- float linearizeDepth(float depth) {
- return (2.0 * zNear) / (zFar + zNear - depth * (zFar - zNear));
- }
- vec3 uvToEye(vec3 p) {
- //vec2 pos = p * 2.0f - 1.0f;
- //vec4 clipPos = vec4(p, z, 1.0f);
- //vec4 viewPos = inverse(projection) * clipPos;
- //return viewPos.xyz / viewPos.w;
- vec4 pos = inverse(projection) * vec4(p * 2 - 1, 1);
- pos /= pos.w;
- pos = inverse(mView) * pos;
- return pos.xyz / pos.w;
- }
- void main() {
- float depth = texture(depthMap, coord).x;
- depth = linearizeDepth(depth);
- if (depth >= .99f) {
- discard;
- return;
- }
- vec3 pos = uvToEye(vec3(coord, depth));
- //doing lots of other stuff that isn't relevant
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

