Skip to content

Commit

Permalink
Consider proximity before calculating occlusion.
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruesc committed Nov 14, 2018
1 parent 143c271 commit 48f91b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/effects/glsl/ssao/shader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ float getAmbientOcclusion(const in vec3 p, const in vec3 n, const in float depth
float sampleDepth = readDepth(coord);
float proximity = abs(depth - sampleDepth);

if(sampleDepth <= distanceCutoff.y) {
if(sampleDepth < distanceCutoff.y && proximity < proximityCutoff.y) {

float falloff = 1.0 - smoothstep(proximityCutoff.x, proximityCutoff.y, proximity);
vec3 sampleViewPosition = getViewPosition(coord, sampleDepth, getViewZ(sampleDepth));
Expand All @@ -79,7 +79,7 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
float ao = 1.0;

// Skip fragments of objects that are too far away.
if(depth <= distanceCutoff.y) {
if(depth < distanceCutoff.y) {

vec3 viewPosition = getViewPosition(uv, depth, getViewZ(depth));
vec3 viewNormal = unpackRGBToNormal(texture2D(normalBuffer, uv).xyz);
Expand Down

0 comments on commit 48f91b8

Please sign in to comment.