diff --git a/CHANGELOG.md b/CHANGELOG.md index 7948192c6b6035d5bcefbaeea80dd879303f8977..3fab9bea4cc42ead945e3dd7e0e1e4902fdbe422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf Fix impostor bond visuals not correctly updating on `sizeFactor` changes Fix degenerate case in PCA +Fix near clipping avoidance in impostor shaders ## [v3.31.2] - 2023-02-12 diff --git a/src/mol-gl/shader/cylinders.vert.ts b/src/mol-gl/shader/cylinders.vert.ts index 60b3f19328854456f0fdfccfbd6b985d29f0b8c6..c5f9d66a1600b7b32a17ca153e70fdbb1dc63088 100644 --- a/src/mol-gl/shader/cylinders.vert.ts +++ b/src/mol-gl/shader/cylinders.vert.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2020-2023 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -71,8 +71,10 @@ void main() { vViewPosition = mvPosition.xyz; gl_Position = uProjection * mvPosition; - mvPosition.z -= 2.0 * (length(vEnd - vStart) + vSize); // avoid clipping - gl_Position.z = (uProjection * mvPosition).z; + if (gl_Position.z < -gl_Position.w) { + mvPosition.z -= 2.0 * (length(vEnd - vStart) + vSize); // avoid clipping + gl_Position.z = (uProjection * mvPosition).z; + } #include clip_instance } diff --git a/src/mol-gl/shader/spheres.vert.ts b/src/mol-gl/shader/spheres.vert.ts index 70a3daf72268f529bb6e57245e1cbd2aceb0d983..387885098c2a3103cb47f8e84f5955e064a1370e 100644 --- a/src/mol-gl/shader/spheres.vert.ts +++ b/src/mol-gl/shader/spheres.vert.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2023 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -96,8 +96,10 @@ void main(void){ vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader - mvPosition.z -= 2.0 * vRadius; // avoid clipping - gl_Position.z = (uProjection * vec4(mvPosition.xyz, 1.0)).z; + if (gl_Position.z < -gl_Position.w) { + mvPosition.z -= 2.0 * vRadius; // avoid clipping + gl_Position.z = (uProjection * vec4(mvPosition.xyz, 1.0)).z; + } #include clip_instance }