diff --git a/CHANGELOG.md b/CHANGELOG.md index 088dfff62bded1f7ea3c30e44305ba16e263ba4e..de8713178d213abce9ac268e02a9e5d282888f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Note that since we don't clearly distinguish between a public and private interf - Fix unit mapping in bondedAtomicPairs MolScript query - Improve pdb parsing: handle non unique atom and chain names (fixes #156) - Fix volume streaming for entries with multiple contour lists +- Add ``allowTransparentBackfaces`` parameter to support double-sided rendering of transparent geometries ## [v3.5.0] - 2022-03-25 diff --git a/src/mol-geo/geometry/cylinders/cylinders.ts b/src/mol-geo/geometry/cylinders/cylinders.ts index 2c4d4db856ee15a246f084703e751745b739f8dd..657698e486e21e269dbe6b19b88d47efeba2ad09 100644 --- a/src/mol-geo/geometry/cylinders/cylinders.ts +++ b/src/mol-geo/geometry/cylinders/cylinders.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -157,6 +157,7 @@ export namespace Cylinders { doubleSided: PD.Boolean(false, BaseGeometry.CustomQualityParamInfo), ignoreLight: PD.Boolean(false, BaseGeometry.ShadingCategory), xrayShaded: PD.Boolean(false, BaseGeometry.ShadingCategory), + allowTransparentBackfaces: PD.Boolean(false, BaseGeometry.ShadingCategory), bumpFrequency: PD.Numeric(0, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory), bumpAmplitude: PD.Numeric(1, { min: 0, max: 5, step: 0.1 }, BaseGeometry.ShadingCategory), }; diff --git a/src/mol-geo/geometry/mesh/mesh.ts b/src/mol-geo/geometry/mesh/mesh.ts index be1169af7613b3b6d656772c44a5d47365275a95..60db49f75b59c5d1a0fd35268efbe84c78c41128 100644 --- a/src/mol-geo/geometry/mesh/mesh.ts +++ b/src/mol-geo/geometry/mesh/mesh.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author David Sehnal <david.sehnal@gmail.com> @@ -625,6 +625,7 @@ export namespace Mesh { flatShaded: PD.Boolean(false, BaseGeometry.ShadingCategory), ignoreLight: PD.Boolean(false, BaseGeometry.ShadingCategory), xrayShaded: PD.Boolean(false, BaseGeometry.ShadingCategory), + allowTransparentBackfaces: PD.Boolean(false, BaseGeometry.ShadingCategory), bumpFrequency: PD.Numeric(0, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory), bumpAmplitude: PD.Numeric(1, { min: 0, max: 5, step: 0.1 }, BaseGeometry.ShadingCategory), }; diff --git a/src/mol-geo/geometry/spheres/spheres.ts b/src/mol-geo/geometry/spheres/spheres.ts index d5531baa6d2210503a2b9c934a1aaf878e7dffdd..a998e411484e5254eddc5f7875fbfa94770b1d5c 100644 --- a/src/mol-geo/geometry/spheres/spheres.ts +++ b/src/mol-geo/geometry/spheres/spheres.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -129,6 +129,7 @@ export namespace Spheres { doubleSided: PD.Boolean(false, BaseGeometry.CustomQualityParamInfo), ignoreLight: PD.Boolean(false, BaseGeometry.ShadingCategory), xrayShaded: PD.Boolean(false, BaseGeometry.ShadingCategory), + allowTransparentBackfaces: PD.Boolean(false, BaseGeometry.ShadingCategory), bumpFrequency: PD.Numeric(0, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory), bumpAmplitude: PD.Numeric(1, { min: 0, max: 5, step: 0.1 }, BaseGeometry.ShadingCategory), }; diff --git a/src/mol-geo/geometry/texture-mesh/texture-mesh.ts b/src/mol-geo/geometry/texture-mesh/texture-mesh.ts index 4ec8f376d25f45092759eaeefcd6b6f3d95695a1..7dbecda586fdc6ae572c365f479a88f9e4f2cb45 100644 --- a/src/mol-geo/geometry/texture-mesh/texture-mesh.ts +++ b/src/mol-geo/geometry/texture-mesh/texture-mesh.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -113,6 +113,7 @@ export namespace TextureMesh { flatShaded: PD.Boolean(false, BaseGeometry.ShadingCategory), ignoreLight: PD.Boolean(false, BaseGeometry.ShadingCategory), xrayShaded: PD.Boolean(false, BaseGeometry.ShadingCategory), + allowTransparentBackfaces: PD.Boolean(false, BaseGeometry.ShadingCategory), bumpFrequency: PD.Numeric(0, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory), bumpAmplitude: PD.Numeric(1, { min: 0, max: 5, step: 0.1 }, BaseGeometry.ShadingCategory), }; diff --git a/src/mol-gl/shader/chunks/wboit-write.glsl.ts b/src/mol-gl/shader/chunks/wboit-write.glsl.ts index 9e1143b59c6e5ab2aa79bf0741a94b3e27990019..103eac3d73e4d2866148e04912d1f18628b9f0c6 100644 --- a/src/mol-gl/shader/chunks/wboit-write.glsl.ts +++ b/src/mol-gl/shader/chunks/wboit-write.glsl.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2022 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> @@ -13,7 +13,7 @@ export const wboit_write = ` } } else if (uRenderWboit) { // the 'fragmentDepth > 0.99' check is to handle precision issues with packed depth - if (preFogAlpha != 1.0 && !interior && (fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize) || fragmentDepth > 0.99)) { + if (preFogAlpha != 1.0 && (!interior || uDoubleSided) && (fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize) || fragmentDepth > 0.99)) { 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); diff --git a/src/mol-repr/util.ts b/src/mol-repr/util.ts index da117ac515ba535abc83313e4b09bfaf0483c77b..8b988f1bd6b08dbb49a4be959e7df909f66983b7 100644 --- a/src/mol-repr/util.ts +++ b/src/mol-repr/util.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -57,6 +57,7 @@ export interface QualityProps { doubleSided: boolean xrayShaded: boolean alpha: number + allowTransparentBackfaces: boolean } export const DefaultQualityThresholds = { @@ -192,7 +193,7 @@ export function getQualityProps(props: Partial<QualityProps>, data?: any) { resolution = Math.max(resolution, volume / 500_000_000); resolution = Math.min(resolution, 20); - if ((props.alpha !== undefined && props.alpha < 1) || !!props.xrayShaded) { + if (!props.allowTransparentBackfaces && ((props.alpha !== undefined && props.alpha < 1) || !!props.xrayShaded)) { doubleSided = false; }