diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e8246fc95bdc2726870e6f71fe2d73f963e567d..70a792d81435f522e93bc4534291601a4dba91cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ Note that since we don't clearly distinguish between a public and private interf - Add Charmm saccharide names - Treat missing occupancy column as occupany of 1 - Fix line shader not accounting for aspect ratio +- [Breaking] Fix point repr & shader + - Was unusable with ``wboit`` + - Replaced ``pointFilledCircle`` & ``pointEdgeBleach`` params by ``pointStyle`` (square, circle, fuzzy) + - Set ``pointSizeAttenuation`` to false by default + - Set ``sizeTheme`` to ``uniform`` by default ## [v2.3.0] - 2021-09-06 diff --git a/src/mol-geo/geometry/points/points.ts b/src/mol-geo/geometry/points/points.ts index a3e999d37306db3ad1e92b5e5270a913750153c3..d22e866ebb621ee60228d48e9919d9e42a8c045c 100644 --- a/src/mol-geo/geometry/points/points.ts +++ b/src/mol-geo/geometry/points/points.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -117,12 +117,19 @@ export namespace Points { // + export const StyleTypes = { + 'square': 'Square', + 'circle': 'Circle', + 'fuzzy': 'Fuzzy', + }; + export type StyleTypes = keyof typeof StyleTypes; + export const StyleTypeNames = Object.keys(StyleTypes) as StyleTypes[]; + export const Params = { ...BaseGeometry.Params, sizeFactor: PD.Numeric(1.5, { min: 0, max: 10, step: 0.1 }), pointSizeAttenuation: PD.Boolean(false), - pointFilledCircle: PD.Boolean(false), - pointEdgeBleach: PD.Numeric(0.2, { min: 0, max: 1, step: 0.05 }), + pointStyle: PD.Select('square', PD.objectToOptions(StyleTypes)), }; export type Params = typeof Params @@ -189,8 +196,7 @@ export namespace Points { ...BaseGeometry.createValues(props, counts), uSizeFactor: ValueCell.create(props.sizeFactor), dPointSizeAttenuation: ValueCell.create(props.pointSizeAttenuation), - dPointFilledCircle: ValueCell.create(props.pointFilledCircle), - uPointEdgeBleach: ValueCell.create(props.pointEdgeBleach), + dPointStyle: ValueCell.create(props.pointStyle), }; } @@ -204,8 +210,7 @@ export namespace Points { BaseGeometry.updateValues(values, props); ValueCell.updateIfChanged(values.uSizeFactor, props.sizeFactor); ValueCell.updateIfChanged(values.dPointSizeAttenuation, props.pointSizeAttenuation); - ValueCell.updateIfChanged(values.dPointFilledCircle, props.pointFilledCircle); - ValueCell.updateIfChanged(values.uPointEdgeBleach, props.pointEdgeBleach); + ValueCell.updateIfChanged(values.dPointStyle, props.pointStyle); } function updateBoundingSphere(values: PointsValues, points: Points) { @@ -229,10 +234,7 @@ export namespace Points { function updateRenderableState(state: RenderableState, props: PD.Values<Params>) { BaseGeometry.updateRenderableState(state, props); - state.opaque = state.opaque && ( - !props.pointFilledCircle || - (props.pointFilledCircle && props.pointEdgeBleach === 0) - ); + state.opaque = state.opaque && props.pointStyle !== 'fuzzy'; state.writeDepth = state.opaque; } } \ No newline at end of file diff --git a/src/mol-gl/_spec/renderer.spec.ts b/src/mol-gl/_spec/renderer.spec.ts index 0c2a9ea4fbb1190c0f49664505017011de0190b6..c07e61bc5a9d490ba34cae3e20a6f04188af0ee1 100644 --- a/src/mol-gl/_spec/renderer.spec.ts +++ b/src/mol-gl/_spec/renderer.spec.ts @@ -85,8 +85,7 @@ function createPoints() { uSizeFactor: ValueCell.create(1), dPointSizeAttenuation: ValueCell.create(true), - dPointFilledCircle: ValueCell.create(false), - uPointEdgeBleach: ValueCell.create(0.5), + dPointStyle: ValueCell.create('square'), }; const state: RenderableState = { disposed: false, diff --git a/src/mol-gl/renderable/points.ts b/src/mol-gl/renderable/points.ts index 315d6de4b0c7e8bad628b1855060e3d65d52f2b9..ec815261b18e2c668cb8049365dba004e0be70dc 100644 --- a/src/mol-gl/renderable/points.ts +++ b/src/mol-gl/renderable/points.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -7,9 +7,10 @@ import { Renderable, RenderableState, createRenderable } from '../renderable'; import { WebGLContext } from '../webgl/context'; import { createGraphicsRenderItem } from '../webgl/render-item'; -import { GlobalUniformSchema, BaseSchema, AttributeSpec, UniformSpec, DefineSpec, Values, InternalSchema, SizeSchema, InternalValues, GlobalTextureSchema } from './schema'; +import { GlobalUniformSchema, BaseSchema, AttributeSpec, DefineSpec, Values, InternalSchema, SizeSchema, InternalValues, GlobalTextureSchema } from './schema'; import { PointsShaderCode } from '../shader-code'; import { ValueCell } from '../../mol-util'; +import { Points } from '../../mol-geo/geometry/points/points'; export const PointsSchema = { ...BaseSchema, @@ -17,8 +18,7 @@ export const PointsSchema = { aGroup: AttributeSpec('float32', 1, 0), aPosition: AttributeSpec('float32', 3, 0), dPointSizeAttenuation: DefineSpec('boolean'), - dPointFilledCircle: DefineSpec('boolean'), - uPointEdgeBleach: UniformSpec('f'), + dPointStyle: DefineSpec('string', Points.StyleTypeNames), }; export type PointsSchema = typeof PointsSchema export type PointsValues = Values<PointsSchema> diff --git a/src/mol-gl/renderer.ts b/src/mol-gl/renderer.ts index f57222d2ff808d0a257b17a036c773e6c73649e2..361b1533f81b5b3e7a652c248b964f08649aa545 100644 --- a/src/mol-gl/renderer.ts +++ b/src/mol-gl/renderer.ts @@ -570,7 +570,7 @@ namespace Renderer { // TODO: simplify, handle in renderable.state??? // uAlpha is updated in "render" so we need to recompute it here const alpha = clamp(r.values.alpha.ref.value * r.state.alphaFactor, 0, 1); - if (alpha === 1 && r.values.transparencyAverage.ref.value !== 1 && r.values.dRenderMode?.ref.value !== 'volume' && !r.values.dPointFilledCircle?.ref.value && !r.values.dXrayShaded?.ref.value) { + if (alpha === 1 && r.values.transparencyAverage.ref.value !== 1 && r.values.dRenderMode?.ref.value !== 'volume' && r.values.dPointStyle?.ref.value !== 'fuzzy' && !r.values.dXrayShaded?.ref.value) { renderObject(r, 'colorWboit'); } } @@ -586,7 +586,7 @@ namespace Renderer { // TODO: simplify, handle in renderable.state??? // uAlpha is updated in "render" so we need to recompute it here const alpha = clamp(r.values.alpha.ref.value * r.state.alphaFactor, 0, 1); - if (alpha < 1 || r.values.transparencyAverage.ref.value > 0 || r.values.dRenderMode?.ref.value === 'volume' || r.values.dPointFilledCircle?.ref.value || !!r.values.uBackgroundColor || r.values.dXrayShaded?.ref.value) { + if (alpha < 1 || r.values.transparencyAverage.ref.value > 0 || r.values.dRenderMode?.ref.value === 'volume' || r.values.dPointStyle?.ref.value === 'fuzzy' || !!r.values.uBackgroundColor || r.values.dXrayShaded?.ref.value) { renderObject(r, 'colorWboit'); } } diff --git a/src/mol-gl/shader/points.frag.ts b/src/mol-gl/shader/points.frag.ts index c18506882ebd89581df63f96a0474c9fa28718f8..0d52802e2b016c3dcdec83863ab2ce6180eb0448 100644 --- a/src/mol-gl/shader/points.frag.ts +++ b/src/mol-gl/shader/points.frag.ts @@ -13,10 +13,6 @@ precision highp int; #include color_frag_params #include common_clip -#ifdef dPointFilledCircle - uniform float uPointEdgeBleach; -#endif - const vec2 center = vec2(0.5); const float radius = 0.5; @@ -27,6 +23,15 @@ void main(){ bool interior = false; #include assign_material_color + #if defined(dPointStyle_circle) + float dist = distance(gl_PointCoord, center); + if (dist > radius) discard; + #elif defined(dPointStyle_fuzzy) + float dist = distance(gl_PointCoord, center); + float fuzzyAlpha = 1.0 - smoothstep(0.0, radius, dist); + if (fuzzyAlpha < 0.0001) discard; + #endif + #if defined(dRenderVariant_pick) #include check_picking_alpha gl_FragColor = material; @@ -37,11 +42,8 @@ void main(){ #elif defined(dRenderVariant_color) gl_FragColor = material; - #ifdef dPointFilledCircle - float dist = distance(gl_PointCoord, center); - float alpha = 1.0 - smoothstep(radius - uPointEdgeBleach, radius, dist); - if (alpha < 0.0001) discard; - gl_FragColor.a *= alpha; + #if defined(dPointStyle_fuzzy) + gl_FragColor.a *= fuzzyAlpha; #endif #include apply_marker_color diff --git a/src/mol-repr/structure/representation/point.ts b/src/mol-repr/structure/representation/point.ts index 019d61ca955a7ca1934dc58bebd06cfa797621bd..0bcddfe18913d220af265f931f988ca057117d70 100644 --- a/src/mol-repr/structure/representation/point.ts +++ b/src/mol-repr/structure/representation/point.ts @@ -32,11 +32,11 @@ export function PointRepresentation(ctx: RepresentationContext, getParams: Repre export const PointRepresentationProvider = StructureRepresentationProvider({ name: 'point', label: 'Point', - description: 'Displays elements (atoms, coarse spheres) as spheres.', + description: 'Displays elements (atoms, coarse spheres) as points.', factory: PointRepresentation, getParams: getPointParams, defaultValues: PD.getDefaultValues(PointParams), defaultColorTheme: { name: 'element-symbol' }, - defaultSizeTheme: { name: 'physical' }, + defaultSizeTheme: { name: 'uniform' }, isApplicable: (structure: Structure) => structure.elementCount > 0 }); \ No newline at end of file diff --git a/src/mol-repr/structure/visual/element-point.ts b/src/mol-repr/structure/visual/element-point.ts index 5ccea9224332e198f413b13140f957f60d8e5fbc..3f41e74ff0f114c0a6efee414248c67b32e31021 100644 --- a/src/mol-repr/structure/visual/element-point.ts +++ b/src/mol-repr/structure/visual/element-point.ts @@ -18,7 +18,7 @@ import { Sphere3D } from '../../../mol-math/geometry'; export const ElementPointParams = { ...UnitsPointsParams, - pointSizeAttenuation: PD.Boolean(true), + pointSizeAttenuation: PD.Boolean(false), ignoreHydrogens: PD.Boolean(false), traceOnly: PD.Boolean(false), };