Created
August 2, 2018 13:06
-
-
Save hb3p8/f28372a4d537fa9c910f820463a84931 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
float const depthGL = read_imagef (depthImage, depthSampler, (int2) (x, y)).x; // in range [0,1] | |
float2 const pixel = (float2) ( (x + 0.5f) / (float) imageSizeX, | |
(y + 0.5f) / (float) imageSizeY); // in range [0,1] | |
float4 point_NDC = (float4) ( 2.0f * pixel.x - 1.0f, // in range [-1,1] | |
2.0f * pixel.y - 1.0f, // in range [-1,1] | |
2.0f * depthGL - 1.0f, // in range [-1,1] | |
1.0f); | |
point_NDC.z -= 1.25e-6f; // apply constant polygon offset for OpenGL depth | |
float4 const point_WORLD = matVecMult (trsf_NDC_WORLD, point_NDC); | |
float const rayTime = depthGL < 1.f ? length (point_WORLD.xyz / point_WORLD.w - ray.Origin.xyz) : BIGFLOAT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment