UNPKG

@xeokit/xeokit-sdk

Version:

3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision

12 lines (11 loc) 731 B
export const DepthProgram = function(programVariables, geometry, logarithmicDepthBufferEnabled) { const vHighPrecisionZW = programVariables.createVarying("highp vec2", "vHighPrecisionZW", () => `${geometry.attributes.position.clip}.zw`); const outColor = programVariables.createOutput("vec4", "outColor"); return { programName: "Depth", getLogDepth: logarithmicDepthBufferEnabled && (vFragDepth => vFragDepth), renderPassFlag: 0, // COLOR_OPAQUE | COLOR_TRANSPARENT // isn't it the same as vec4(vec3(1.0 - gl_FragCoord.z), 1.0) ? appendFragmentOutputs: (src) => src.push(`${outColor} = vec4(vec3((1.0 - ${vHighPrecisionZW}[0] / ${vHighPrecisionZW}[1]) / 2.0), 1.0);`) }; };