Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
54e4c370
Commit
54e4c370
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
wip, outline
parent
0b6dfa8a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-canvas3d/canvas3d.ts
+9
-0
9 additions, 0 deletions
src/mol-canvas3d/canvas3d.ts
src/mol-canvas3d/passes/ssao-pass.ts
+9
-0
9 additions, 0 deletions
src/mol-canvas3d/passes/ssao-pass.ts
src/mol-gl/shader/passes/ssao.frag
+27
-1
27 additions, 1 deletion
src/mol-gl/shader/passes/ssao.frag
with
45 additions
and
1 deletion
src/mol-canvas3d/canvas3d.ts
+
9
−
0
View file @
54e4c370
...
@@ -428,6 +428,15 @@ namespace Canvas3D {
...
@@ -428,6 +428,15 @@ namespace Canvas3D {
p
.
ambientOcclusion
.
radius
=
props
.
ambientOcclusion
.
radius
p
.
ambientOcclusion
.
radius
=
props
.
ambientOcclusion
.
radius
ValueCell
.
update
(
ssaoPass
.
values
.
uRadius
,
props
.
ambientOcclusion
.
radius
)
ValueCell
.
update
(
ssaoPass
.
values
.
uRadius
,
props
.
ambientOcclusion
.
radius
)
}
}
if
(
props
.
ambientOcclusion
.
edgeScale
!==
undefined
)
{
p
.
ambientOcclusion
.
edgeScale
=
props
.
ambientOcclusion
.
edgeScale
ValueCell
.
update
(
ssaoPass
.
values
.
uEdgeScale
,
props
.
ambientOcclusion
.
edgeScale
*
webgl
.
pixelRatio
)
}
if
(
props
.
ambientOcclusion
.
edgeThreshold
!==
undefined
)
{
p
.
ambientOcclusion
.
edgeThreshold
=
props
.
ambientOcclusion
.
edgeThreshold
ValueCell
.
update
(
ssaoPass
.
values
.
uEdgeThreshold
,
props
.
ambientOcclusion
.
edgeThreshold
)
}
}
}
if
(
props
.
renderer
)
renderer
.
setProps
(
props
.
renderer
)
if
(
props
.
renderer
)
renderer
.
setProps
(
props
.
renderer
)
...
...
This diff is collapsed.
Click to expand it.
src/mol-canvas3d/passes/ssao-pass.ts
+
9
−
0
View file @
54e4c370
...
@@ -25,6 +25,9 @@ const SSAOPassSchema = {
...
@@ -25,6 +25,9 @@ const SSAOPassSchema = {
uKernelSize
:
UniformSpec
(
'
i
'
),
uKernelSize
:
UniformSpec
(
'
i
'
),
uBias
:
UniformSpec
(
'
f
'
),
uBias
:
UniformSpec
(
'
f
'
),
uRadius
:
UniformSpec
(
'
f
'
),
uRadius
:
UniformSpec
(
'
f
'
),
uEdgeScale
:
UniformSpec
(
'
f
'
),
uEdgeThreshold
:
UniformSpec
(
'
f
'
),
}
}
export
const
SSAOPassParams
=
{
export
const
SSAOPassParams
=
{
...
@@ -32,6 +35,9 @@ export const SSAOPassParams = {
...
@@ -32,6 +35,9 @@ export const SSAOPassParams = {
kernelSize
:
PD
.
Numeric
(
4
,
{
min
:
1
,
max
:
100
,
step
:
1
}),
kernelSize
:
PD
.
Numeric
(
4
,
{
min
:
1
,
max
:
100
,
step
:
1
}),
bias
:
PD
.
Numeric
(
0.5
,
{
min
:
0
,
max
:
1
,
step
:
0.01
}),
bias
:
PD
.
Numeric
(
0.5
,
{
min
:
0
,
max
:
1
,
step
:
0.01
}),
radius
:
PD
.
Numeric
(
128
,
{
min
:
0
,
max
:
256
,
step
:
1
}),
radius
:
PD
.
Numeric
(
128
,
{
min
:
0
,
max
:
256
,
step
:
1
}),
edgeScale
:
PD
.
Numeric
(
1
,
{
min
:
0
,
max
:
10
,
step
:
1
}),
edgeThreshold
:
PD
.
Numeric
(
0.8
,
{
min
:
0
,
max
:
1
,
step
:
0.01
}),
}
}
export
type
SSAOPassProps
=
PD
.
Values
<
typeof
SSAOPassParams
>
export
type
SSAOPassProps
=
PD
.
Values
<
typeof
SSAOPassParams
>
...
@@ -47,6 +53,9 @@ export function getSSAOPassRenderable(ctx: WebGLContext, colorTexture: Texture,
...
@@ -47,6 +53,9 @@ export function getSSAOPassRenderable(ctx: WebGLContext, colorTexture: Texture,
uKernelSize
:
ValueCell
.
create
(
p
.
kernelSize
),
uKernelSize
:
ValueCell
.
create
(
p
.
kernelSize
),
uBias
:
ValueCell
.
create
(
p
.
bias
),
uBias
:
ValueCell
.
create
(
p
.
bias
),
uRadius
:
ValueCell
.
create
(
p
.
radius
),
uRadius
:
ValueCell
.
create
(
p
.
radius
),
uEdgeScale
:
ValueCell
.
create
(
p
.
edgeScale
*
ctx
.
pixelRatio
),
uEdgeThreshold
:
ValueCell
.
create
(
p
.
edgeThreshold
),
}
}
const
schema
=
{
...
SSAOPassSchema
}
const
schema
=
{
...
SSAOPassSchema
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-gl/shader/passes/ssao.frag
+
27
−
1
View file @
54e4c370
...
@@ -11,6 +11,9 @@ uniform int uKernelSize;
...
@@ -11,6 +11,9 @@ uniform int uKernelSize;
uniform
float
uBias
;
uniform
float
uBias
;
uniform
float
uRadius
;
uniform
float
uRadius
;
uniform
float
uEdgeScale
;
uniform
float
uEdgeThreshold
;
const
float
noiseAmount
=
0
.
0002
;
const
float
noiseAmount
=
0
.
0002
;
float
noise
(
vec2
coords
)
{
float
noise
(
vec2
coords
)
{
...
@@ -31,13 +34,34 @@ float calcSSAO(in vec2 coords, in float depth) {
...
@@ -31,13 +34,34 @@ float calcSSAO(in vec2 coords, in float depth) {
vec2
coordsDelta
=
coords
+
uRadius
/
float
(
uKernelSize
)
*
vec2
(
float
(
i
)
/
uTexSize
.
x
,
float
(
j
)
/
uTexSize
.
y
);
vec2
coordsDelta
=
coords
+
uRadius
/
float
(
uKernelSize
)
*
vec2
(
float
(
i
)
/
uTexSize
.
x
,
float
(
j
)
/
uTexSize
.
y
);
coordsDelta
+=
noiseAmount
*
(
noise
(
coordsDelta
)
-
0
.
5
)
/
uTexSize
;
coordsDelta
+=
noiseAmount
*
(
noise
(
coordsDelta
)
-
0
.
5
)
/
uTexSize
;
coordsDelta
=
clamp
(
coordsDelta
,
0
.
5
/
uTexSize
,
1
.
0
-
1
.
0
/
uTexSize
);
coordsDelta
=
clamp
(
coordsDelta
,
0
.
5
/
uTexSize
,
1
.
0
-
1
.
0
/
uTexSize
);
if
(
texture
(
tDepth
,
coordsDelta
).
r
<
depth
)
occlusionFactor
+=
1
.
0
;
if
(
texture
2D
(
tDepth
,
coordsDelta
).
r
<
depth
)
occlusionFactor
+=
1
.
0
;
}
}
}
}
return
occlusionFactor
/
float
((
2
*
uKernelSize
+
1
)
*
(
2
*
uKernelSize
+
1
));
return
occlusionFactor
/
float
((
2
*
uKernelSize
+
1
)
*
(
2
*
uKernelSize
+
1
));
}
}
float
calcEdgeDepth
(
in
vec2
coords
)
{
vec2
invTexSize
=
1
.
0
/
uTexSize
;
float
halfScaleFloor
=
floor
(
uEdgeScale
*
0
.
5
);
float
halfScaleCeil
=
ceil
(
uEdgeScale
*
0
.
5
);
vec2
bottomLeftUV
=
coords
-
invTexSize
*
halfScaleFloor
;
vec2
topRightUV
=
coords
+
invTexSize
*
halfScaleCeil
;
vec2
bottomRightUV
=
coords
+
vec2
(
invTexSize
.
x
*
halfScaleCeil
,
-
invTexSize
.
y
*
halfScaleFloor
);
vec2
topLeftUV
=
coords
+
vec2
(
-
invTexSize
.
x
*
halfScaleFloor
,
invTexSize
.
y
*
halfScaleCeil
);
float
depth0
=
texture2D
(
tDepth
,
bottomLeftUV
).
r
;
float
depth1
=
texture2D
(
tDepth
,
topRightUV
).
r
;
float
depth2
=
texture2D
(
tDepth
,
bottomRightUV
).
r
;
float
depth3
=
texture2D
(
tDepth
,
topLeftUV
).
r
;
float
depthFiniteDifference0
=
depth1
-
depth0
;
float
depthFiniteDifference1
=
depth3
-
depth2
;
return
sqrt
(
pow
(
depthFiniteDifference0
,
2
.
0
)
+
pow
(
depthFiniteDifference1
,
2
.
0
))
*
100
.
0
;
}
void
main
(
void
)
{
void
main
(
void
)
{
vec2
coords
=
gl_FragCoord
.
xy
/
uTexSize
;
vec2
coords
=
gl_FragCoord
.
xy
/
uTexSize
;
vec4
color
=
texture
(
tColor
,
coords
);
vec4
color
=
texture
(
tColor
,
coords
);
...
@@ -48,6 +72,8 @@ void main(void) {
...
@@ -48,6 +72,8 @@ void main(void) {
float
occlusionFactor
=
calcSSAO
(
coords
,
depth
);
float
occlusionFactor
=
calcSSAO
(
coords
,
depth
);
color
=
mix
(
color
,
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
1
.
0
),
uBias
*
occlusionFactor
);
color
=
mix
(
color
,
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
1
.
0
),
uBias
*
occlusionFactor
);
}
}
color
.
rgb
*=
(
step
(
calcEdgeDepth
(
coords
),
uEdgeThreshold
));
gl_FragColor
=
color
;
gl_FragColor
=
color
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment