1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #ifdef LOG_DEPTH
- varying float v_depthFromNearPlusOne;
- #ifdef POLYGON_OFFSET
- uniform vec2 u_polygonOffset;
- #endif
- #endif
- void czm_writeLogDepth(float depth)
- {
- #if defined(GL_EXT_frag_depth) && defined(LOG_DEPTH)
-
-
-
-
- if (depth <= 0.9999999 || depth > czm_farDepthFromNearPlusOne) {
- discard;
- }
- #ifdef POLYGON_OFFSET
-
- float factor = u_polygonOffset[0];
- float units = u_polygonOffset[1];
-
- #ifdef GL_OES_standard_derivatives
-
- float x = dFdx(depth);
- float y = dFdy(depth);
- float m = sqrt(x * x + y * y);
-
- depth += m * factor;
- #endif
- #endif
- gl_FragDepthEXT = log2(depth) * czm_oneOverLog2FarDepthFromNearPlusOne;
- #ifdef POLYGON_OFFSET
-
- gl_FragDepthEXT += czm_epsilon7 * units;
- #endif
- #endif
- }
- void czm_writeLogDepth() {
- #ifdef LOG_DEPTH
- czm_writeLogDepth(v_depthFromNearPlusOne);
- #endif
- }
|