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
5a14fcab
Commit
5a14fcab
authored
4 years ago
by
AronKovacs
Browse files
Options
Downloads
Patches
Plain Diff
small ssao changes, e.g. better vec2 noise
parent
560e4077
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-gl/shader/ssao.frag.ts
+8
-7
8 additions, 7 deletions
src/mol-gl/shader/ssao.frag.ts
with
8 additions
and
7 deletions
src/mol-gl/shader/ssao.frag.ts
+
8
−
7
View file @
5a14fcab
...
...
@@ -27,12 +27,12 @@ float noise(const in vec2 coords) {
float b = 78.233;
float c = 43758.5453;
float dt = dot(coords, vec2(a,b));
float sn = mod(dt,
3.14159
);
float sn = mod(dt,
PI
);
return abs(fract(sin(sn) * c)); // is abs necessary?
}
vec2 getNoiseVec2(const in vec2 coords) {
return vec2(noise(coords), noise(coords
)
+ 2.71828);
return vec2(noise(coords), noise(coords +
vec2(PI,
2.71828)
))
;
}
bool isBackground(const in float depth) {
...
...
@@ -53,8 +53,10 @@ vec3 normalFromDepth(const in float depth, const in float depth1, const in float
return normalize(normal);
}
// StarCraft II Ambient Occlusion by [Filion and McNaughton 2008]
void main(void) {
vec2 selfCoords = gl_FragCoord.xy / uTexSize;
vec2 invTexSize = 1.0 / uTexSize;
vec2 selfCoords = gl_FragCoord.xy * invTexSize;
float selfDepth = getDepth(selfCoords);
vec2 selfPackedDepth = packUnitIntervalToRG(selfDepth);
...
...
@@ -64,8 +66,8 @@ void main(void) {
return;
}
vec2 offset1 = vec2(0.0,
0.001
);
vec2 offset2 = vec2(
0.001
, 0.0);
vec2 offset1 = vec2(0.0,
invTexSize.y
);
vec2 offset2 = vec2(
invTexSize.x
, 0.0);
float selfDepth1 = getDepth(selfCoords + offset1);
float selfDepth2 = getDepth(selfCoords + offset2);
...
...
@@ -89,8 +91,7 @@ void main(void) {
offset.xyz /= offset.w;
offset.xyz = offset.xyz * 0.5 + 0.5;
float sampleDepth = getDepth(offset.xy);
float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepth), uInvProjection).z;
float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, getDepth(offset.xy)), uInvProjection).z;
occlusion += (sampleViewZ >= sampleViewPos.z + uBias ? 1.0 : 0.0) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ));
}
...
...
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