UNPKG

molstar

Version:

A comprehensive macromolecular library.

36 lines (35 loc) 1.34 kB
"use strict"; /** * Copyright (c) 2019-2023 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Áron Samuel Kovács <aron.kovacs@mail.muni.cz> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.wboit_write = void 0; exports.wboit_write = ` #if defined(dRenderVariant_colorWboit) if (uRenderMask == MaskOpaque) { if (preFogAlpha < 1.0) { discard; } } else if (uRenderMask == MaskTransparent) { if (preFogAlpha != 1.0 && fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize)) { #ifdef dTransparentBackfaces_off if (interior) discard; #endif float alpha = gl_FragColor.a; float wboitWeight = alpha * clamp(pow(1.0 - fragmentDepth, 2.0), 0.01, 1.0); gl_FragColor = vec4(gl_FragColor.rgb * alpha * wboitWeight, alpha); // extra alpha is to handle pre-multiplied alpha #ifndef dGeometryType_directVolume gl_FragData[1] = vec4((uTransparentBackground ? alpha : 1.0) * alpha * wboitWeight); #else gl_FragData[1] = vec4(alpha * alpha * wboitWeight); #endif } else { discard; } } #endif `;