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

add outline color option to renderer

parent b9b0413e
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf ...@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf
- Add ``bumpiness`` (per-object and per-group), ``bumpFrequency`` & ``bumpAmplitude`` (per-object) render parameters (#299) - Add ``bumpiness`` (per-object and per-group), ``bumpFrequency`` & ``bumpAmplitude`` (per-object) render parameters (#299)
- Change ``label`` representation defaults: Use text border instead of rectangle background. - Change ``label`` representation defaults: Use text border instead of rectangle background.
- Add outline color option to renderer
## [v3.0.0-dev.3] - 2021-12-4 ## [v3.0.0-dev.3] - 2021-12-4
......
...@@ -51,7 +51,8 @@ function occlusionStyle(plugin: PluginContext) { ...@@ -51,7 +51,8 @@ function occlusionStyle(plugin: PluginContext) {
} }, } },
outline: { name: 'on', params: { outline: { name: 'on', params: {
scale: 1.0, scale: 1.0,
threshold: 0.33 threshold: 0.33,
color: Color(0x0000),
} } } }
} }
} }); } });
......
...@@ -11,6 +11,7 @@ import { PluginUIContext } from '../../mol-plugin-ui/context'; ...@@ -11,6 +11,7 @@ import { PluginUIContext } from '../../mol-plugin-ui/context';
import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec'; import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
import { PluginCommands } from '../../mol-plugin/commands'; import { PluginCommands } from '../../mol-plugin/commands';
import { Asset } from '../../mol-util/assets'; import { Asset } from '../../mol-util/assets';
import { Color } from '../../mol-util/color';
import './index.html'; import './index.html';
require('mol-plugin-ui/skin/light.scss'); require('mol-plugin-ui/skin/light.scss');
...@@ -26,7 +27,7 @@ const Canvas3DPresets = { ...@@ -26,7 +27,7 @@ const Canvas3DPresets = {
}, },
postprocessing: { postprocessing: {
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } }, occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
outline: { name: 'on', params: { scale: 1, threshold: 0.1 } } outline: { name: 'on', params: { scale: 1, threshold: 0.1, color: Color(0x000000) } }
}, },
renderer: { renderer: {
style: { name: 'flat', params: {} } style: { name: 'flat', params: {} }
......
...@@ -193,6 +193,7 @@ const PostprocessingSchema = { ...@@ -193,6 +193,7 @@ const PostprocessingSchema = {
uFogNear: UniformSpec('f'), uFogNear: UniformSpec('f'),
uFogFar: UniformSpec('f'), uFogFar: UniformSpec('f'),
uFogColor: UniformSpec('v3'), uFogColor: UniformSpec('v3'),
uOutlineColor: UniformSpec('v3'),
uTransparentBackground: UniformSpec('b'), uTransparentBackground: UniformSpec('b'),
uMaxPossibleViewZDiff: UniformSpec('f'), uMaxPossibleViewZDiff: UniformSpec('f'),
...@@ -220,6 +221,7 @@ function getPostprocessingRenderable(ctx: WebGLContext, colorTexture: Texture, d ...@@ -220,6 +221,7 @@ function getPostprocessingRenderable(ctx: WebGLContext, colorTexture: Texture, d
uFogNear: ValueCell.create(10000), uFogNear: ValueCell.create(10000),
uFogFar: ValueCell.create(10000), uFogFar: ValueCell.create(10000),
uFogColor: ValueCell.create(Vec3.create(1, 1, 1)), uFogColor: ValueCell.create(Vec3.create(1, 1, 1)),
uOutlineColor: ValueCell.create(Vec3.create(0, 0, 0)),
uTransparentBackground: ValueCell.create(false), uTransparentBackground: ValueCell.create(false),
uMaxPossibleViewZDiff: ValueCell.create(0.5), uMaxPossibleViewZDiff: ValueCell.create(0.5),
...@@ -252,6 +254,7 @@ export const PostprocessingParams = { ...@@ -252,6 +254,7 @@ export const PostprocessingParams = {
on: PD.Group({ on: PD.Group({
scale: PD.Numeric(1, { min: 1, max: 5, step: 1 }), scale: PD.Numeric(1, { min: 1, max: 5, step: 1 }),
threshold: PD.Numeric(0.33, { min: 0.01, max: 1, step: 0.01 }), threshold: PD.Numeric(0.33, { min: 0.01, max: 1, step: 0.01 }),
color: PD.Color(Color(0x000000)),
}), }),
off: PD.Group({}) off: PD.Group({})
}, { cycle: true, description: 'Draw outline around 3D objects' }), }, { cycle: true, description: 'Draw outline around 3D objects' }),
...@@ -446,6 +449,8 @@ export class PostprocessingPass { ...@@ -446,6 +449,8 @@ export class PostprocessingPass {
ValueCell.updateIfChanged(this.outlinesRenderable.values.uFar, camera.far); ValueCell.updateIfChanged(this.outlinesRenderable.values.uFar, camera.far);
ValueCell.updateIfChanged(this.outlinesRenderable.values.uMaxPossibleViewZDiff, maxPossibleViewZDiff); ValueCell.updateIfChanged(this.outlinesRenderable.values.uMaxPossibleViewZDiff, maxPossibleViewZDiff);
ValueCell.update(this.renderable.values.uOutlineColor, Color.toVec3Normalized(this.renderable.values.uOutlineColor.ref.value, props.outline.params.color));
ValueCell.updateIfChanged(this.renderable.values.uMaxPossibleViewZDiff, maxPossibleViewZDiff); ValueCell.updateIfChanged(this.renderable.values.uMaxPossibleViewZDiff, maxPossibleViewZDiff);
if (this.renderable.values.dOutlineScale.ref.value !== outlineScale) { needsUpdateMain = true; } if (this.renderable.values.dOutlineScale.ref.value !== outlineScale) { needsUpdateMain = true; }
ValueCell.updateIfChanged(this.renderable.values.dOutlineScale, outlineScale); ValueCell.updateIfChanged(this.renderable.values.dOutlineScale, outlineScale);
......
...@@ -21,6 +21,7 @@ uniform float uFar; ...@@ -21,6 +21,7 @@ uniform float uFar;
uniform float uFogNear; uniform float uFogNear;
uniform float uFogFar; uniform float uFogFar;
uniform vec3 uFogColor; uniform vec3 uFogColor;
uniform vec3 uOutlineColor;
uniform bool uTransparentBackground; uniform bool uTransparentBackground;
uniform float uOcclusionBias; uniform float uOcclusionBias;
...@@ -116,7 +117,7 @@ void main(void) { ...@@ -116,7 +117,7 @@ void main(void) {
float outline = getOutline(coords, closestTexel); float outline = getOutline(coords, closestTexel);
if (outline == 0.0) { if (outline == 0.0) {
color.rgb *= outline; color.rgb = mix(uOutlineColor, color.rgb, outline);
viewDist = abs(getViewZ(closestTexel)); viewDist = abs(getViewZ(closestTexel));
fogFactor = smoothstep(uFogNear, uFogFar, viewDist); fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
if (!uTransparentBackground) { if (!uTransparentBackground) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment