All files / engine/Source/Shaders/Builtin/Functions writeLogDepth.js

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82                                                                                                                                                                   
//This file is automatically rebuilt by the Cesium build process.
export default "#ifdef LOG_DEPTH\n\
in float v_depthFromNearPlusOne;\n\
\n\
#ifdef POLYGON_OFFSET\n\
uniform vec2 u_polygonOffset;\n\
#endif\n\
\n\
#endif\n\
\n\
/**\n\
 * Writes the fragment depth to the logarithmic depth buffer.\n\
 * <p>\n\
 * Use this when the vertex shader does not call {@link czm_vertexLogDepth}, for example, when\n\
 * ray-casting geometry using a full screen quad.\n\
 * </p>\n\
 * @name czm_writeLogDepth\n\
 * @glslFunction\n\
 *\n\
 * @param {float} depth The depth coordinate, where 1.0 is on the near plane and\n\
 *                      depth increases in eye-space units from there\n\
 *\n\
 * @example\n\
 * czm_writeLogDepth((czm_projection * v_positionEyeCoordinates).w + 1.0);\n\
 */\n\
void czm_writeLogDepth(float depth)\n\
{\n\
#if (defined(LOG_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth)))\n\
    // Discard the vertex if it's not between the near and far planes.\n\
    // We allow a bit of epsilon on the near plane comparison because a 1.0\n\
    // from the vertex shader (indicating the vertex should be _on_ the near\n\
    // plane) will not necessarily come here as exactly 1.0.\n\
    if (depth <= 0.9999999 || depth > czm_farDepthFromNearPlusOne) {\n\
        discard;\n\
    }\n\
\n\
#ifdef POLYGON_OFFSET\n\
    // Polygon offset: m * factor + r * units\n\
    float factor = u_polygonOffset[0];\n\
    float units = u_polygonOffset[1];\n\
\n\
#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))\n\
    // This factor doesn't work in IE 10\n\
    if (factor != 0.0) {\n\
        // m = sqrt(dZdX^2 + dZdY^2);\n\
        float x = dFdx(depth);\n\
        float y = dFdy(depth);\n\
        float m = sqrt(x * x + y * y);\n\
\n\
        // Apply the factor before computing the log depth.\n\
        depth += m * factor;\n\
    }\n\
#endif\n\
\n\
#endif\n\
\n\
    gl_FragDepth = log2(depth) * czm_oneOverLog2FarDepthFromNearPlusOne;\n\
\n\
#ifdef POLYGON_OFFSET\n\
    // Apply the units after the log depth.\n\
    gl_FragDepth += czm_epsilon7 * units;\n\
#endif\n\
\n\
#endif\n\
}\n\
\n\
/**\n\
 * Writes the fragment depth to the logarithmic depth buffer.\n\
 * <p>\n\
 * Use this when the vertex shader calls {@link czm_vertexLogDepth}.\n\
 * </p>\n\
 *\n\
 * @name czm_writeLogDepth\n\
 * @glslFunction\n\
 */\n\
void czm_writeLogDepth() {\n\
#ifdef LOG_DEPTH\n\
    czm_writeLogDepth(v_depthFromNearPlusOne);\n\
#endif\n\
}\n\
";