Skip to content
Snippets Groups Projects
Commit 55de0aba authored by Alexander Rose's avatar Alexander Rose
Browse files

fix point repr & shader

parent ecfa7b5a
Branches
No related tags found
No related merge requests found
......@@ -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
......
/**
* 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
......@@ -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,
......
/**
* 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>
......
......@@ -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');
}
}
......
......@@ -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
......
......@@ -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
......@@ -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),
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment