|
@@ -43,7 +43,7 @@ vec2 getNoiseVec2(const in vec2 coords) {
|
|
}
|
|
}
|
|
|
|
|
|
bool isBackground(const in float depth) {
|
|
bool isBackground(const in float depth) {
|
|
- return depth >= 0.99;
|
|
|
|
|
|
+ return depth == 1.0;
|
|
}
|
|
}
|
|
|
|
|
|
float getDepth(const in vec2 coords) {
|
|
float getDepth(const in vec2 coords) {
|
|
@@ -53,10 +53,10 @@ float getDepth(const in vec2 coords) {
|
|
vec3 normalFromDepth(const in float depth, const in float depth1, const in float depth2, vec2 offset1, vec2 offset2) {
|
|
vec3 normalFromDepth(const in float depth, const in float depth1, const in float depth2, vec2 offset1, vec2 offset2) {
|
|
vec3 p1 = vec3(offset1, depth1 - depth);
|
|
vec3 p1 = vec3(offset1, depth1 - depth);
|
|
vec3 p2 = vec3(offset2, depth2 - depth);
|
|
vec3 p2 = vec3(offset2, depth2 - depth);
|
|
-
|
|
|
|
|
|
+
|
|
vec3 normal = cross(p1, p2);
|
|
vec3 normal = cross(p1, p2);
|
|
normal.z = -normal.z;
|
|
normal.z = -normal.z;
|
|
-
|
|
|
|
|
|
+
|
|
return normalize(normal);
|
|
return normalize(normal);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -72,7 +72,7 @@ void main(void) {
|
|
gl_FragColor = vec4(packUnitIntervalToRG(0.0), selfPackedDepth);
|
|
gl_FragColor = vec4(packUnitIntervalToRG(0.0), selfPackedDepth);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
vec2 offset1 = vec2(0.0, invTexSize.y);
|
|
vec2 offset1 = vec2(0.0, invTexSize.y);
|
|
vec2 offset2 = vec2(invTexSize.x, 0.0);
|
|
vec2 offset2 = vec2(invTexSize.x, 0.0);
|
|
|
|
|
|
@@ -91,7 +91,7 @@ void main(void) {
|
|
float occlusion = 0.0;
|
|
float occlusion = 0.0;
|
|
for(int i = 0; i < dNSamples; i++){
|
|
for(int i = 0; i < dNSamples; i++){
|
|
vec3 sampleViewPos = TBN * uSamples[i];
|
|
vec3 sampleViewPos = TBN * uSamples[i];
|
|
- sampleViewPos = selfViewPos + sampleViewPos * uRadius;
|
|
|
|
|
|
+ sampleViewPos = selfViewPos + sampleViewPos * uRadius;
|
|
|
|
|
|
vec4 offset = vec4(sampleViewPos, 1.0);
|
|
vec4 offset = vec4(sampleViewPos, 1.0);
|
|
offset = uProjection * offset;
|
|
offset = uProjection * offset;
|
|
@@ -99,12 +99,12 @@ void main(void) {
|
|
|
|
|
|
float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, getDepth(offset.xy)), uInvProjection).z;
|
|
float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, getDepth(offset.xy)), uInvProjection).z;
|
|
|
|
|
|
- occlusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ));
|
|
|
|
|
|
+ occlusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ));
|
|
}
|
|
}
|
|
occlusion = 1.0 - (uBias * occlusion / float(dNSamples));
|
|
occlusion = 1.0 - (uBias * occlusion / float(dNSamples));
|
|
|
|
|
|
vec2 packedOcclusion = packUnitIntervalToRG(occlusion);
|
|
vec2 packedOcclusion = packUnitIntervalToRG(occlusion);
|
|
-
|
|
|
|
|
|
+
|
|
gl_FragColor = vec4(packedOcclusion, selfPackedDepth);
|
|
gl_FragColor = vec4(packedOcclusion, selfPackedDepth);
|
|
}
|
|
}
|
|
`;
|
|
`;
|