diff --git a/build/Three.js b/build/Three.js index bfa719bc..05a67be2 100644 --- a/build/Three.js +++ b/build/Three.js @@ -356,6 +356,7 @@ THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:"attribute vec4 tang cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t", value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(j=25);g=(j-1)*0.5;e=Array(j);for(c=f=0;c25&&(h=25);f=(h-1)*0.5;c=Array(h);for(b=e=0;b + @@ -156,8 +157,9 @@ var renderBackground = new THREE.RenderPass( sceneBG, cameraOrtho ); var renderModel = new THREE.RenderPass( sceneModel, cameraPerspective ); - var effectBloom = new THREE.BloomPass( 1.0 ); - var effectFilm = new THREE.FilmPass( 0.25, 0.5 ); + var effectBloom = new THREE.BloomPass( 0.75 ); + var effectFilm = new THREE.FilmPass( 0.35, 0.5, 2048, false ); + var effectSepia = new THREE.SepiaPass( 1.0 ); renderModel.clear = false; effectFilm.renderToScreen = true; @@ -167,8 +169,33 @@ composer.addPass( renderBackground ); composer.addPass( renderModel ); composer.addPass( effectBloom ); + composer.addPass( effectSepia ); composer.addPass( effectFilm ); + // + + onWindowResize(); + + window.addEventListener( 'resize', onWindowResize, false ); + + } + + function onWindowResize( event ) { + + renderer.setSize( window.innerWidth, window.innerHeight ); + + cameraPerspective.aspect = window.innerWidth / window.innerHeight; + cameraPerspective.updateProjectionMatrix(); + + cameraOrtho.left = window.innerWidth / - 2; + cameraOrtho.right = window.innerWidth / 2; + cameraOrtho.top = window.innerHeight / 2; + cameraOrtho.bottom = window.innerHeight / - 2; + + cameraOrtho.updateProjectionMatrix(); + + composer.reset(); + } function getText( id ) { diff --git a/src/extras/ShaderUtils.js b/src/extras/ShaderUtils.js index a03abb93..b9f224e0 100644 --- a/src/extras/ShaderUtils.js +++ b/src/extras/ShaderUtils.js @@ -562,6 +562,58 @@ THREE.ShaderUtils = { }, + + /* ------------------------------------------------------------------------- + // Sepia tone shader + // - based on glfx.js sepia shader + // https://github.com/evanw/glfx.js + ------------------------------------------------------------------------- */ + + 'sepia': { + + uniforms: { + + tDiffuse: { type: "t", value: 0, texture: null }, + amount: { type: "f", value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = vec2( uv.x, 1.0 - uv.y );", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join("\n"), + + fragmentShader: [ + + "varying vec2 vUv;", + "uniform sampler2D tDiffuse;", + "uniform float amount;", + + "void main() {", + + "vec4 color = texture2D( tDiffuse, vUv );", + "vec3 c = color.rgb;", + + "color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );", + "color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );", + "color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );", + + "gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );", + + "}" + + ].join("\n") + + }, + /* ------------------------------------------------------------------------- // Full-screen textured quad shader ------------------------------------------------------------------------- */