molstar
Version:
A comprehensive macromolecular library.
52 lines (47 loc) • 1.89 kB
JavaScript
"use strict";
/**
* Copyright (c) 2023-2024 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.fade_lod = void 0;
exports.fade_lod = `
if (uLod.w == 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {
float d = dot(uCameraPlane.xyz, vModelPosition) + uCameraPlane.w;
float ta = min(
smoothstep(uLod.x, uLod.x + uLod.z, d),
1.0 - smoothstep(uLod.y - uLod.z, uLod.y, d)
);
float at = 0.0;
// shift by view-offset during multi-sample rendering to allow for blending
vec2 coord = gl_FragCoord.xy + uViewOffset * 0.25;
const mat4 thresholdMatrix = mat4(
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
);
int ci = int(intMod(coord.x, 4.0));
int ri = int(intMod(coord.y, 4.0));
vec4 i = vec4(float(ci * 4 + ri));
vec4 v = thresholdMatrix[0] * vec4(equal(i, vec4(0.0, 1.0, 2.0, 3.0))) +
thresholdMatrix[1] * vec4(equal(i, vec4(4.0, 5.0, 6.0, 7.0))) +
thresholdMatrix[2] * vec4(equal(i, vec4(8.0, 9.0, 10.0, 11.0))) +
thresholdMatrix[3] * vec4(equal(i, vec4(12.0, 13.0, 14.0, 15.0)));
at = v.x + v.y + v.z + v.w;
at = thresholdMatrix[ci][ri];
if (ta < 0.99 && (ta < 0.01 || ta < at)) {
discard;
}
if (ta < uPickingAlphaThreshold) {
discard;
}
}
`;