|
@@ -142,14 +142,6 @@ THREE.BokehShader = {
|
|
|
|
|
|
"//------------------------------------------",
|
|
|
|
|
|
- "float getDepth( const in vec2 screenPosition ) {",
|
|
|
- " #if DEPTH_PACKING == 1",
|
|
|
- " return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );",
|
|
|
- " #else",
|
|
|
- " return texture2D( tDepth, screenPosition ).x;",
|
|
|
- " #endif",
|
|
|
- "}",
|
|
|
-
|
|
|
"float penta(vec2 coords) {",
|
|
|
"//pentagonal shape",
|
|
|
"float scale = float(rings) - 1.3;",
|
|
@@ -211,7 +203,7 @@ THREE.BokehShader = {
|
|
|
|
|
|
|
|
|
"for( int i=0; i<9; i++ ) {",
|
|
|
- "float tmp = getDepth( coords + offset[ i ] );",
|
|
|
+ "float tmp = texture2D(tDepth, coords + offset[i]).r;",
|
|
|
"d += tmp * kernel[i];",
|
|
|
"}",
|
|
|
|
|
@@ -273,10 +265,10 @@ THREE.BokehShader = {
|
|
|
"void main() {",
|
|
|
"//scene depth calculation",
|
|
|
|
|
|
- "float depth = linearize( getDepth( vUv.xy ) );",
|
|
|
+ "float depth = linearize(texture2D(tDepth,vUv.xy).x);",
|
|
|
|
|
|
"// Blur depth?",
|
|
|
- "if (depthblur) {",
|
|
|
+ "if ( depthblur ) {",
|
|
|
"depth = linearize(bdepth(vUv.xy));",
|
|
|
"}",
|
|
|
|
|
@@ -286,7 +278,7 @@ THREE.BokehShader = {
|
|
|
|
|
|
"if (shaderFocus) {",
|
|
|
|
|
|
- "fDepth = linearize( getDepth( focusCoords ) );",
|
|
|
+ "fDepth = linearize(texture2D(tDepth,focusCoords).x);",
|
|
|
|
|
|
"}",
|
|
|
|
|
@@ -363,3 +355,50 @@ THREE.BokehShader = {
|
|
|
].join( "\n" )
|
|
|
|
|
|
};
|
|
|
+
|
|
|
+THREE.BokehDepthShader = {
|
|
|
+
|
|
|
+ uniforms: {
|
|
|
+
|
|
|
+ "mNear": { value: 1.0 },
|
|
|
+ "mFar": { value: 1000.0 },
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ vertexShader: [
|
|
|
+
|
|
|
+ "#include <common>",
|
|
|
+
|
|
|
+ "varying float vViewZDepth;",
|
|
|
+
|
|
|
+ "void main() {",
|
|
|
+
|
|
|
+ " #include <begin_vertex>",
|
|
|
+ " #include <project_vertex>",
|
|
|
+
|
|
|
+ " vViewZDepth = - mvPosition.z;",
|
|
|
+
|
|
|
+ "}"
|
|
|
+
|
|
|
+ ].join( "\n" ),
|
|
|
+
|
|
|
+ fragmentShader: [
|
|
|
+
|
|
|
+ "uniform float mNear;",
|
|
|
+ "uniform float mFar;",
|
|
|
+
|
|
|
+ "varying float vViewZDepth;",
|
|
|
+
|
|
|
+ "#include <common>",
|
|
|
+ "#include <packing>",
|
|
|
+
|
|
|
+ "void main() {",
|
|
|
+
|
|
|
+ " float color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );",
|
|
|
+ " gl_FragColor = vec4( vec3( color ), 1.0 );",
|
|
|
+
|
|
|
+ "} "
|
|
|
+
|
|
|
+ ].join( "\n" )
|
|
|
+
|
|
|
+};
|