|
@@ -35,7 +35,7 @@
|
|
|
padding: 5px;
|
|
|
display: inline-block;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
#error {
|
|
|
margin: auto;
|
|
|
margin-top: 40px;
|
|
@@ -45,7 +45,7 @@
|
|
|
background: #CE0808;
|
|
|
}
|
|
|
</style>
|
|
|
-
|
|
|
+
|
|
|
<script id="post-vert" type="x-shader/x-vertex">
|
|
|
varying vec2 vUv;
|
|
|
|
|
@@ -56,24 +56,20 @@
|
|
|
</script>
|
|
|
<script id="post-frag" type="x-shader/x-fragment">
|
|
|
#include <packing>
|
|
|
-
|
|
|
+
|
|
|
varying vec2 vUv;
|
|
|
uniform sampler2D tDiffuse;
|
|
|
uniform sampler2D tDepth;
|
|
|
uniform float cameraNear;
|
|
|
uniform float cameraFar;
|
|
|
|
|
|
+
|
|
|
float readDepth (sampler2D depthSampler, vec2 coord) {
|
|
|
- float cameraFarPlusNear = cameraFar + cameraNear;
|
|
|
- float cameraFarMinusNear = cameraFar - cameraNear;
|
|
|
- float cameraCoef = 2.0 * cameraNear;
|
|
|
- return cameraCoef / (cameraFarPlusNear - texture2D(depthSampler, coord).x * cameraFarMinusNear);
|
|
|
+ float fragCoordZ = texture2D(depthSampler, coord).x;
|
|
|
+ float viewZ = invClipZToViewZ( fragCoordZ, cameraNear, cameraFar );
|
|
|
+ return viewZToLinearClipZ( viewZ, cameraNear, cameraFar );
|
|
|
}
|
|
|
|
|
|
- // float depthTexel = texture2D(tDepth, vUv).x;
|
|
|
- // float depth = invClipZToViewZ(depthTexel, cameraNear, cameraFar);
|
|
|
- // float linearClipZ = viewZToLinearClipZ(depth, cameraNear, cameraFar);
|
|
|
-
|
|
|
void main() {
|
|
|
vec3 diffuse = texture2D(tDiffuse, vUv).rgb;
|
|
|
float depth = readDepth(tDepth, vUv);
|