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

add occlussion color

parent c3e62bc2
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf ...@@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf
## [Unreleased] ## [Unreleased]
- Add occlusion color parameter
## [v3.31.4] - 2023-02-24 ## [v3.31.4] - 2023-02-24
- Allow link cylinder/line `dashCount` set to '0' - Allow link cylinder/line `dashCount` set to '0'
......
/** /**
* 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> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
...@@ -50,6 +50,7 @@ function occlusionStyle(plugin: PluginContext) { ...@@ -50,6 +50,7 @@ function occlusionStyle(plugin: PluginContext) {
radius: 5, radius: 5,
samples: 32, samples: 32,
resolutionScale: 1, resolutionScale: 1,
color: Color(0x000000),
} }, } },
outline: { name: 'on', params: { outline: { name: 'on', params: {
scale: 1.0, scale: 1.0,
......
/** /**
* 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> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
...@@ -24,7 +24,7 @@ const Canvas3DPresets = { ...@@ -24,7 +24,7 @@ const Canvas3DPresets = {
illustrative: { illustrative: {
canvas3d: <Preset>{ canvas3d: <Preset>{
postprocessing: { postprocessing: {
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15, resolutionScale: 1 } }, occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15, resolutionScale: 1, color: Color(0x000000) } },
outline: { name: 'on', params: { scale: 1, threshold: 0.33, color: Color(0x000000), includeTransparent: true, } }, outline: { name: 'on', params: { scale: 1, threshold: 0.33, color: Color(0x000000), includeTransparent: true, } },
shadow: { name: 'off', params: {} }, shadow: { name: 'off', params: {} },
}, },
......
/** /**
* 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> * @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Ludovic Autin <ludovic.autin@gmail.com> * @author Ludovic Autin <ludovic.autin@gmail.com>
...@@ -604,6 +604,7 @@ export const LoadCellPackModel = StateAction.build({ ...@@ -604,6 +604,7 @@ export const LoadCellPackModel = StateAction.build({
bias: 1, bias: 1,
blurKernelSize: 15, blurKernelSize: 15,
resolutionScale: 1, resolutionScale: 1,
color: Color(0x000000),
} }
}, },
shadow: { shadow: {
......
...@@ -280,6 +280,7 @@ const PostprocessingSchema = { ...@@ -280,6 +280,7 @@ const PostprocessingSchema = {
uFogFar: UniformSpec('f'), uFogFar: UniformSpec('f'),
uFogColor: UniformSpec('v3'), uFogColor: UniformSpec('v3'),
uOutlineColor: UniformSpec('v3'), uOutlineColor: UniformSpec('v3'),
uOcclusionColor: UniformSpec('v3'),
uTransparentBackground: UniformSpec('b'), uTransparentBackground: UniformSpec('b'),
uMaxPossibleViewZDiff: UniformSpec('f'), uMaxPossibleViewZDiff: UniformSpec('f'),
...@@ -317,6 +318,7 @@ function getPostprocessingRenderable(ctx: WebGLContext, colorTexture: Texture, d ...@@ -317,6 +318,7 @@ function getPostprocessingRenderable(ctx: WebGLContext, colorTexture: Texture, d
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)), uOutlineColor: ValueCell.create(Vec3.create(0, 0, 0)),
uOcclusionColor: 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),
...@@ -349,6 +351,7 @@ export const PostprocessingParams = { ...@@ -349,6 +351,7 @@ export const PostprocessingParams = {
bias: PD.Numeric(0.8, { min: 0, max: 3, step: 0.1 }), bias: PD.Numeric(0.8, { min: 0, max: 3, step: 0.1 }),
blurKernelSize: PD.Numeric(15, { min: 1, max: 25, step: 2 }), blurKernelSize: PD.Numeric(15, { min: 1, max: 25, step: 2 }),
resolutionScale: PD.Numeric(1, { min: 0.1, max: 1, step: 0.05 }, { description: 'Adjust resolution of occlusion calculation' }), resolutionScale: PD.Numeric(1, { min: 0.1, max: 1, step: 0.05 }, { description: 'Adjust resolution of occlusion calculation' }),
color: PD.Color(Color(0x000000)),
}), }),
off: PD.Group({}) off: PD.Group({})
}, { cycle: true, description: 'Darken occluded crevices with the ambient occlusion effect' }), }, { cycle: true, description: 'Darken occluded crevices with the ambient occlusion effect' }),
...@@ -595,6 +598,8 @@ export class PostprocessingPass { ...@@ -595,6 +598,8 @@ export class PostprocessingPass {
ValueCell.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, Vec2.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, sw, sh)); ValueCell.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, Vec2.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, sw, sh));
ValueCell.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, Vec2.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, sw, sh)); ValueCell.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, Vec2.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, sw, sh));
} }
ValueCell.update(this.renderable.values.uOcclusionColor, Color.toVec3Normalized(this.renderable.values.uOcclusionColor.ref.value, props.occlusion.params.color));
} }
if (props.shadow.name === 'on') { if (props.shadow.name === 'on') {
......
...@@ -24,6 +24,7 @@ uniform float uFogNear; ...@@ -24,6 +24,7 @@ uniform float uFogNear;
uniform float uFogFar; uniform float uFogFar;
uniform vec3 uFogColor; uniform vec3 uFogColor;
uniform vec3 uOutlineColor; uniform vec3 uOutlineColor;
uniform vec3 uOcclusionColor;
uniform bool uTransparentBackground; uniform bool uTransparentBackground;
uniform vec2 uOcclusionOffset; uniform vec2 uOcclusionOffset;
...@@ -32,8 +33,6 @@ uniform float uMaxPossibleViewZDiff; ...@@ -32,8 +33,6 @@ uniform float uMaxPossibleViewZDiff;
uniform mat4 uInvProjection; uniform mat4 uInvProjection;
const float outlineDistanceFactor = 5.0; const float outlineDistanceFactor = 5.0;
const vec3 occlusionColor = vec3(0.0);
#include common #include common
float getViewZ(const in float depth) { float getViewZ(const in float depth) {
...@@ -130,9 +129,9 @@ void main(void) { ...@@ -130,9 +129,9 @@ void main(void) {
fogFactor = smoothstep(uFogNear, uFogFar, viewDist); fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
float occlusionFactor = getSsao(coords + uOcclusionOffset); float occlusionFactor = getSsao(coords + uOcclusionOffset);
if (!uTransparentBackground) { if (!uTransparentBackground) {
color.rgb = mix(mix(occlusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor); color.rgb = mix(mix(uOcclusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor);
} else { } else {
color.rgb = mix(occlusionColor * (1.0 - fogFactor), color.rgb, occlusionFactor); color.rgb = mix(uOcclusionColor * (1.0 - fogFactor), color.rgb, occlusionFactor);
} }
} }
#endif #endif
......
/** /**
* Copyright (c) 2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2022-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
...@@ -60,7 +60,7 @@ export class QuickStyles extends PurePluginUIComponent { ...@@ -60,7 +60,7 @@ export class QuickStyles extends PurePluginUIComponent {
}, },
occlusion: { occlusion: {
name: 'on', name: 'on',
params: { bias: 0.8, blurKernelSize: 15, radius: 5, samples: 32, resolutionScale: 1 } params: { bias: 0.8, blurKernelSize: 15, radius: 5, samples: 32, resolutionScale: 1, color: Color(0x000000) }
}, },
shadow: { name: 'off', params: {} }, shadow: { name: 'off', params: {} },
} }
...@@ -85,7 +85,7 @@ export class QuickStyles extends PurePluginUIComponent { ...@@ -85,7 +85,7 @@ export class QuickStyles extends PurePluginUIComponent {
name: 'on', name: 'on',
params: pp.occlusion.name === 'on' params: pp.occlusion.name === 'on'
? pp.occlusion.params ? pp.occlusion.params
: { bias: 0.8, blurKernelSize: 15, radius: 5, samples: 32, resolutionScale: 1 } : { bias: 0.8, blurKernelSize: 15, radius: 5, samples: 32, resolutionScale: 1, color: Color(0x000000) }
}, },
shadow: { name: 'off', params: {} }, shadow: { name: 'off', params: {} },
} }
......
...@@ -210,6 +210,7 @@ export const STYLIZED_POSTPROCESSING: Partial<PostprocessingProps> = { ...@@ -210,6 +210,7 @@ export const STYLIZED_POSTPROCESSING: Partial<PostprocessingProps> = {
bias: 0.8, bias: 0.8,
blurKernelSize: 15, blurKernelSize: 15,
resolutionScale: 1, resolutionScale: 1,
color: ColorNames.black,
} }
}, outline: { }, outline: {
name: 'on' as const, params: { name: 'on' as const, params: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment