├── README.md ├── ThreeJSshader1 ├── .idea │ ├── modules.xml │ └── ThreeJSshader1.iml └── js │ ├── nodes │ ├── inputs │ │ ├── Matrix4Node.js │ │ ├── ColorNode.js │ │ ├── Vector2Node.js │ │ ├── Vector4Node.js │ │ ├── Vector3Node.js │ │ ├── FloatNode.js │ │ ├── IntNode.js │ │ ├── ScreenNode.js │ │ ├── MirrorNode.js │ │ └── CubeTextureNode.js │ ├── utils │ │ ├── TimerNode.js │ │ ├── NoiseNode.js │ │ ├── ResolutionNode.js │ │ ├── LuminanceNode.js │ │ ├── NormalMapNode.js │ │ ├── VelocityNode.js │ │ ├── JoinNode.js │ │ ├── BumpNode.js │ │ ├── SwitchNode.js │ │ └── ColorAdjustmentNode.js │ ├── VarNode.js │ ├── materials │ │ ├── PhongNodeMaterial.js │ │ └── StandardNodeMaterial.js │ ├── accessors │ │ ├── LightNode.js │ │ ├── UVNode.js │ │ ├── ScreenUVNode.js │ │ ├── ColorsNode.js │ │ └── NormalNode.js │ ├── RawNode.js │ ├── postprocessing │ │ └── NodePass.js │ ├── AttributeNode.js │ ├── InputNode.js │ ├── math │ │ └── OperatorNode.js │ └── FunctionCallNode.js │ ├── loaders │ ├── ctm │ │ ├── CTMWorker.js │ │ └── license │ │ │ ├── OpenCTM.txt │ │ │ ├── js-lzma.txt │ │ │ └── js-openctm.txt │ └── SVGLoader.js │ ├── PRNG.js │ ├── shaders │ ├── BasicShader.js │ ├── CopyShader.js │ ├── GammaCorrectionShader.js │ ├── LuminosityShader.js │ ├── ColorifyShader.js │ ├── UnpackDepthRGBAShader.js │ ├── BlendShader.js │ ├── ColorCorrectionShader.js │ ├── TechnicolorShader.js │ ├── SepiaShader.js │ ├── DOFMipMapShader.js │ ├── MirrorShader.js │ ├── NormalMapShader.js │ ├── RGBShiftShader.js │ ├── KaleidoShader.js │ ├── BrightnessContrastShader.js │ ├── LuminosityHighPassShader.js │ ├── VignetteShader.js │ ├── BleachBypassShader.js │ ├── DotScreenShader.js │ ├── TriangleBlurShader.js │ ├── HueSaturationShader.js │ ├── VerticalBlurShader.js │ └── HorizontalBlurShader.js │ ├── modifiers │ └── ExplodeModifier.js │ ├── crossfade │ └── gui.js │ ├── postprocessing │ ├── ClearPass.js │ ├── RenderPass.js │ ├── ShaderPass.js │ ├── TexturePass.js │ ├── DotScreenPass.js │ ├── CubeTexturePass.js │ ├── SavePass.js │ └── FilmPass.js │ ├── exporters │ ├── TypedGeometryExporter.js │ └── STLExporter.js │ ├── effects │ └── StereoEffect.js │ ├── libs │ ├── system.min.js │ └── stats.min.js │ ├── math │ └── ColorConverter.js │ ├── curves │ └── NURBSSurface.js │ ├── MorphAnimation.js │ ├── Gyroscope.js │ ├── MorphAnimMesh.js │ └── controls │ └── PointerLockControls.js └── ThreeJSshader2 ├── .idea ├── modules.xml └── ThreeJSshader1.iml └── js ├── nodes ├── inputs │ ├── Matrix4Node.js │ ├── ColorNode.js │ ├── Vector2Node.js │ ├── Vector4Node.js │ ├── Vector3Node.js │ ├── FloatNode.js │ ├── IntNode.js │ ├── ScreenNode.js │ ├── MirrorNode.js │ └── CubeTextureNode.js ├── utils │ ├── TimerNode.js │ ├── NoiseNode.js │ ├── ResolutionNode.js │ ├── LuminanceNode.js │ ├── NormalMapNode.js │ ├── VelocityNode.js │ ├── JoinNode.js │ ├── BumpNode.js │ ├── SwitchNode.js │ └── ColorAdjustmentNode.js ├── VarNode.js ├── materials │ ├── PhongNodeMaterial.js │ └── StandardNodeMaterial.js ├── accessors │ ├── LightNode.js │ ├── UVNode.js │ ├── ScreenUVNode.js │ ├── ColorsNode.js │ └── NormalNode.js ├── RawNode.js ├── postprocessing │ └── NodePass.js ├── AttributeNode.js ├── InputNode.js ├── math │ └── OperatorNode.js └── FunctionCallNode.js ├── loaders ├── ctm │ ├── CTMWorker.js │ └── license │ │ ├── OpenCTM.txt │ │ ├── js-lzma.txt │ │ └── js-openctm.txt └── SVGLoader.js ├── PRNG.js ├── shaders ├── BasicShader.js ├── CopyShader.js ├── GammaCorrectionShader.js ├── LuminosityShader.js ├── ColorifyShader.js ├── UnpackDepthRGBAShader.js ├── BlendShader.js ├── ColorCorrectionShader.js ├── TechnicolorShader.js ├── SepiaShader.js ├── DOFMipMapShader.js ├── MirrorShader.js ├── NormalMapShader.js ├── RGBShiftShader.js ├── KaleidoShader.js ├── BrightnessContrastShader.js ├── LuminosityHighPassShader.js ├── VignetteShader.js ├── BleachBypassShader.js ├── DotScreenShader.js ├── TriangleBlurShader.js ├── HueSaturationShader.js ├── VerticalBlurShader.js └── HorizontalBlurShader.js ├── modifiers └── ExplodeModifier.js ├── crossfade └── gui.js ├── postprocessing ├── ClearPass.js ├── RenderPass.js ├── ShaderPass.js ├── TexturePass.js ├── DotScreenPass.js ├── CubeTexturePass.js ├── SavePass.js └── FilmPass.js ├── exporters ├── TypedGeometryExporter.js └── STLExporter.js ├── effects └── StereoEffect.js ├── libs ├── system.min.js └── stats.min.js ├── math └── ColorConverter.js ├── curves └── NURBSSurface.js ├── MorphAnimation.js ├── Gyroscope.js ├── MorphAnimMesh.js └── controls └── PointerLockControls.js /README.md: -------------------------------------------------------------------------------- 1 | # ThreeJSToonShader 2 | used threejs r83 to Implementation ToonShader effect 3 | -------------------------------------------------------------------------------- /ThreeJSshader1/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ThreeJSshader2/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/Matrix4Node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.Matrix4Node = function( matrix ) { 6 | 7 | THREE.InputNode.call( this, 'm4' ); 8 | 9 | this.value = matrix || new THREE.Matrix4(); 10 | 11 | }; 12 | 13 | THREE.Matrix4Node.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.Matrix4Node.prototype.constructor = THREE.Matrix4Node; 15 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/Matrix4Node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.Matrix4Node = function( matrix ) { 6 | 7 | THREE.InputNode.call( this, 'm4' ); 8 | 9 | this.value = matrix || new THREE.Matrix4(); 10 | 11 | }; 12 | 13 | THREE.Matrix4Node.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.Matrix4Node.prototype.constructor = THREE.Matrix4Node; 15 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/loaders/ctm/CTMWorker.js: -------------------------------------------------------------------------------- 1 | importScripts( "lzma.js", "ctm.js" ); 2 | 3 | self.onmessage = function( event ) { 4 | 5 | var files = []; 6 | 7 | for ( var i = 0; i < event.data.offsets.length; i ++ ) { 8 | 9 | var stream = new CTM.Stream( event.data.data ); 10 | stream.offset = event.data.offsets[ i ]; 11 | 12 | files[ i ] = new CTM.File( stream ); 13 | 14 | } 15 | 16 | self.postMessage( files ); 17 | self.close(); 18 | 19 | }; 20 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/loaders/ctm/CTMWorker.js: -------------------------------------------------------------------------------- 1 | importScripts( "lzma.js", "ctm.js" ); 2 | 3 | self.onmessage = function( event ) { 4 | 5 | var files = []; 6 | 7 | for ( var i = 0; i < event.data.offsets.length; i ++ ) { 8 | 9 | var stream = new CTM.Stream( event.data.data ); 10 | stream.offset = event.data.offsets[ i ]; 11 | 12 | files[ i ] = new CTM.File( stream ); 13 | 14 | } 15 | 16 | self.postMessage( files ); 17 | self.close(); 18 | 19 | }; 20 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/ColorNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ColorNode = function( color ) { 6 | 7 | THREE.InputNode.call( this, 'c' ); 8 | 9 | this.value = new THREE.Color( color || 0 ); 10 | 11 | }; 12 | 13 | THREE.ColorNode.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.ColorNode.prototype.constructor = THREE.ColorNode; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.ColorNode.prototype, 'value', [ 'r', 'g', 'b' ] ); 17 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/ColorNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ColorNode = function( color ) { 6 | 7 | THREE.InputNode.call( this, 'c' ); 8 | 9 | this.value = new THREE.Color( color || 0 ); 10 | 11 | }; 12 | 13 | THREE.ColorNode.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.ColorNode.prototype.constructor = THREE.ColorNode; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.ColorNode.prototype, 'value', [ 'r', 'g', 'b' ] ); 17 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/Vector2Node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.Vector2Node = function( x, y ) { 6 | 7 | THREE.InputNode.call( this, 'v2' ); 8 | 9 | this.value = new THREE.Vector2( x, y ); 10 | 11 | }; 12 | 13 | THREE.Vector2Node.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.Vector2Node.prototype.constructor = THREE.Vector2Node; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.Vector2Node.prototype, 'value', [ 'x', 'y' ] ); 17 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/Vector2Node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.Vector2Node = function( x, y ) { 6 | 7 | THREE.InputNode.call( this, 'v2' ); 8 | 9 | this.value = new THREE.Vector2( x, y ); 10 | 11 | }; 12 | 13 | THREE.Vector2Node.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.Vector2Node.prototype.constructor = THREE.Vector2Node; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.Vector2Node.prototype, 'value', [ 'x', 'y' ] ); 17 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/Vector4Node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.Vector4Node = function( x, y, z, w ) { 6 | 7 | THREE.InputNode.call( this, 'v4' ); 8 | 9 | this.value = new THREE.Vector4( x, y, z, w ); 10 | 11 | }; 12 | 13 | THREE.Vector4Node.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.Vector4Node.prototype.constructor = THREE.Vector4Node; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.Vector4Node.prototype, 'value', [ 'x', 'y', 'z', 'w' ] ); 17 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/Vector4Node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.Vector4Node = function( x, y, z, w ) { 6 | 7 | THREE.InputNode.call( this, 'v4' ); 8 | 9 | this.value = new THREE.Vector4( x, y, z, w ); 10 | 11 | }; 12 | 13 | THREE.Vector4Node.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.Vector4Node.prototype.constructor = THREE.Vector4Node; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.Vector4Node.prototype, 'value', [ 'x', 'y', 'z', 'w' ] ); 17 | -------------------------------------------------------------------------------- /ThreeJSshader1/.idea/ThreeJSshader1.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ThreeJSshader2/.idea/ThreeJSshader1.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/Vector3Node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.Vector3Node = function( x, y, z ) { 6 | 7 | THREE.InputNode.call( this, 'v3' ); 8 | 9 | this.type = 'v3'; 10 | this.value = new THREE.Vector3( x, y, z ); 11 | 12 | }; 13 | 14 | THREE.Vector3Node.prototype = Object.create( THREE.InputNode.prototype ); 15 | THREE.Vector3Node.prototype.constructor = THREE.Vector3Node; 16 | 17 | THREE.NodeMaterial.addShortcuts( THREE.Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] ); 18 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/Vector3Node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.Vector3Node = function( x, y, z ) { 6 | 7 | THREE.InputNode.call( this, 'v3' ); 8 | 9 | this.type = 'v3'; 10 | this.value = new THREE.Vector3( x, y, z ); 11 | 12 | }; 13 | 14 | THREE.Vector3Node.prototype = Object.create( THREE.InputNode.prototype ); 15 | THREE.Vector3Node.prototype.constructor = THREE.Vector3Node; 16 | 17 | THREE.NodeMaterial.addShortcuts( THREE.Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] ); 18 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/PRNG.js: -------------------------------------------------------------------------------- 1 | // Park-Miller-Carta Pseudo-Random Number Generator 2 | // https://github.com/pnitsch/BitmapData.js/blob/master/js/BitmapData.js 3 | 4 | var PRNG = function () { 5 | 6 | this.seed = 1; 7 | this.next = function() { 8 | 9 | return ( this.gen() / 2147483647 ); 10 | 11 | }; 12 | this.nextRange = function( min, max ) { 13 | 14 | return min + ( ( max - min ) * this.next() ) 15 | 16 | }; 17 | this.gen = function() { 18 | 19 | return this.seed = ( this.seed * 16807 ) % 2147483647; 20 | 21 | }; 22 | 23 | }; 24 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/PRNG.js: -------------------------------------------------------------------------------- 1 | // Park-Miller-Carta Pseudo-Random Number Generator 2 | // https://github.com/pnitsch/BitmapData.js/blob/master/js/BitmapData.js 3 | 4 | var PRNG = function () { 5 | 6 | this.seed = 1; 7 | this.next = function() { 8 | 9 | return ( this.gen() / 2147483647 ); 10 | 11 | }; 12 | this.nextRange = function( min, max ) { 13 | 14 | return min + ( ( max - min ) * this.next() ) 15 | 16 | }; 17 | this.gen = function() { 18 | 19 | return this.seed = ( this.seed * 16807 ) % 2147483647; 20 | 21 | }; 22 | 23 | }; 24 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/BasicShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://www.mrdoob.com 3 | * 4 | * Simple test shader 5 | */ 6 | 7 | THREE.BasicShader = { 8 | 9 | uniforms: {}, 10 | 11 | vertexShader: [ 12 | 13 | "void main() {", 14 | 15 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 16 | 17 | "}" 18 | 19 | ].join( "\n" ), 20 | 21 | fragmentShader: [ 22 | 23 | "void main() {", 24 | 25 | "gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ) 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/BasicShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://www.mrdoob.com 3 | * 4 | * Simple test shader 5 | */ 6 | 7 | THREE.BasicShader = { 8 | 9 | uniforms: {}, 10 | 11 | vertexShader: [ 12 | 13 | "void main() {", 14 | 15 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 16 | 17 | "}" 18 | 19 | ].join( "\n" ), 20 | 21 | fragmentShader: [ 22 | 23 | "void main() {", 24 | 25 | "gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ) 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/TimerNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.TimerNode = function( value, scale ) { 6 | 7 | THREE.FloatNode.call( this, value ); 8 | 9 | this.requestUpdate = true; 10 | 11 | this.scale = scale !== undefined ? scale : 1; 12 | 13 | }; 14 | 15 | THREE.TimerNode.prototype = Object.create( THREE.FloatNode.prototype ); 16 | THREE.TimerNode.prototype.constructor = THREE.TimerNode; 17 | 18 | THREE.TimerNode.prototype.updateFrame = function( delta ) { 19 | 20 | this.number += delta * this.scale; 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/TimerNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.TimerNode = function( value, scale ) { 6 | 7 | THREE.FloatNode.call( this, value ); 8 | 9 | this.requestUpdate = true; 10 | 11 | this.scale = scale !== undefined ? scale : 1; 12 | 13 | }; 14 | 15 | THREE.TimerNode.prototype = Object.create( THREE.FloatNode.prototype ); 16 | THREE.TimerNode.prototype.constructor = THREE.TimerNode; 17 | 18 | THREE.TimerNode.prototype.updateFrame = function( delta ) { 19 | 20 | this.number += delta * this.scale; 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/NoiseNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.NoiseNode = function( coord ) { 6 | 7 | THREE.TempNode.call( this, 'fv1' ); 8 | 9 | this.coord = coord; 10 | 11 | }; 12 | 13 | THREE.NoiseNode.prototype = Object.create( THREE.TempNode.prototype ); 14 | THREE.NoiseNode.prototype.constructor = THREE.NoiseNode; 15 | 16 | THREE.NoiseNode.prototype.generate = function( builder, output ) { 17 | 18 | builder.include( 'snoise' ); 19 | 20 | return builder.format( 'snoise(' + this.coord.build( builder, 'v2' ) + ')', this.getType( builder ), output ); 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/NoiseNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.NoiseNode = function( coord ) { 6 | 7 | THREE.TempNode.call( this, 'fv1' ); 8 | 9 | this.coord = coord; 10 | 11 | }; 12 | 13 | THREE.NoiseNode.prototype = Object.create( THREE.TempNode.prototype ); 14 | THREE.NoiseNode.prototype.constructor = THREE.NoiseNode; 15 | 16 | THREE.NoiseNode.prototype.generate = function( builder, output ) { 17 | 18 | builder.include( 'snoise' ); 19 | 20 | return builder.format( 'snoise(' + this.coord.build( builder, 'v2' ) + ')', this.getType( builder ), output ); 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/ResolutionNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ResolutionNode = function( renderer ) { 6 | 7 | THREE.Vector2Node.call( this ); 8 | 9 | this.requestUpdate = true; 10 | 11 | this.renderer = renderer; 12 | 13 | }; 14 | 15 | THREE.ResolutionNode.prototype = Object.create( THREE.Vector2Node.prototype ); 16 | THREE.ResolutionNode.prototype.constructor = THREE.ResolutionNode; 17 | 18 | THREE.ResolutionNode.prototype.updateFrame = function( delta ) { 19 | 20 | var size = this.renderer.getSize(); 21 | 22 | this.x = size.width; 23 | this.y = size.height; 24 | 25 | }; 26 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/ResolutionNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ResolutionNode = function( renderer ) { 6 | 7 | THREE.Vector2Node.call( this ); 8 | 9 | this.requestUpdate = true; 10 | 11 | this.renderer = renderer; 12 | 13 | }; 14 | 15 | THREE.ResolutionNode.prototype = Object.create( THREE.Vector2Node.prototype ); 16 | THREE.ResolutionNode.prototype.constructor = THREE.ResolutionNode; 17 | 18 | THREE.ResolutionNode.prototype.updateFrame = function( delta ) { 19 | 20 | var size = this.renderer.getSize(); 21 | 22 | this.x = size.width; 23 | this.y = size.height; 24 | 25 | }; 26 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/FloatNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.FloatNode = function( value ) { 6 | 7 | THREE.InputNode.call( this, 'fv1' ); 8 | 9 | this.value = [ value || 0 ]; 10 | 11 | }; 12 | 13 | THREE.FloatNode.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.FloatNode.prototype.constructor = THREE.FloatNode; 15 | 16 | Object.defineProperties( THREE.FloatNode.prototype, { 17 | number: { 18 | get: function() { 19 | 20 | return this.value[ 0 ]; 21 | 22 | }, 23 | set: function( val ) { 24 | 25 | this.value[ 0 ] = val; 26 | 27 | } 28 | } 29 | } ); 30 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/FloatNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.FloatNode = function( value ) { 6 | 7 | THREE.InputNode.call( this, 'fv1' ); 8 | 9 | this.value = [ value || 0 ]; 10 | 11 | }; 12 | 13 | THREE.FloatNode.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.FloatNode.prototype.constructor = THREE.FloatNode; 15 | 16 | Object.defineProperties( THREE.FloatNode.prototype, { 17 | number: { 18 | get: function() { 19 | 20 | return this.value[ 0 ]; 21 | 22 | }, 23 | set: function( val ) { 24 | 25 | this.value[ 0 ] = val; 26 | 27 | } 28 | } 29 | } ); 30 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/LuminanceNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.LuminanceNode = function( rgb ) { 6 | 7 | THREE.TempNode.call( this, 'fv1' ); 8 | 9 | this.rgb = rgb; 10 | 11 | }; 12 | 13 | THREE.LuminanceNode.prototype = Object.create( THREE.TempNode.prototype ); 14 | THREE.LuminanceNode.prototype.constructor = THREE.LuminanceNode; 15 | 16 | THREE.LuminanceNode.prototype.generate = function( builder, output ) { 17 | 18 | builder.include( 'luminance_rgb' ); 19 | 20 | return builder.format( 'luminance_rgb(' + this.rgb.build( builder, 'v3' ) + ')', this.getType( builder ), output ); 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/LuminanceNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.LuminanceNode = function( rgb ) { 6 | 7 | THREE.TempNode.call( this, 'fv1' ); 8 | 9 | this.rgb = rgb; 10 | 11 | }; 12 | 13 | THREE.LuminanceNode.prototype = Object.create( THREE.TempNode.prototype ); 14 | THREE.LuminanceNode.prototype.constructor = THREE.LuminanceNode; 15 | 16 | THREE.LuminanceNode.prototype.generate = function( builder, output ) { 17 | 18 | builder.include( 'luminance_rgb' ); 19 | 20 | return builder.format( 'luminance_rgb(' + this.rgb.build( builder, 'v3' ) + ')', this.getType( builder ), output ); 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/IntNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.IntNode = function( value ) { 6 | 7 | THREE.InputNode.call( this, 'iv1' ); 8 | 9 | this.value = [ Math.floor( value || 0 ) ]; 10 | 11 | }; 12 | 13 | THREE.IntNode.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.IntNode.prototype.constructor = THREE.IntNode; 15 | 16 | Object.defineProperties( THREE.IntNode.prototype, { 17 | number: { 18 | get: function() { 19 | 20 | return this.value[ 0 ]; 21 | 22 | }, 23 | set: function( val ) { 24 | 25 | this.value[ 0 ] = Math.floor( val ); 26 | 27 | } 28 | } 29 | } ); 30 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/IntNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.IntNode = function( value ) { 6 | 7 | THREE.InputNode.call( this, 'iv1' ); 8 | 9 | this.value = [ Math.floor( value || 0 ) ]; 10 | 11 | }; 12 | 13 | THREE.IntNode.prototype = Object.create( THREE.InputNode.prototype ); 14 | THREE.IntNode.prototype.constructor = THREE.IntNode; 15 | 16 | Object.defineProperties( THREE.IntNode.prototype, { 17 | number: { 18 | get: function() { 19 | 20 | return this.value[ 0 ]; 21 | 22 | }, 23 | set: function( val ) { 24 | 25 | this.value[ 0 ] = Math.floor( val ); 26 | 27 | } 28 | } 29 | } ); 30 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/ScreenNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ScreenNode = function( coord ) { 6 | 7 | THREE.TextureNode.call( this, undefined, coord ); 8 | 9 | }; 10 | 11 | THREE.ScreenNode.prototype = Object.create( THREE.TextureNode.prototype ); 12 | THREE.ScreenNode.prototype.constructor = THREE.ScreenNode; 13 | 14 | THREE.ScreenNode.prototype.isUnique = function() { 15 | 16 | return true; 17 | 18 | }; 19 | 20 | THREE.ScreenNode.prototype.getTexture = function( builder, output ) { 21 | 22 | return THREE.InputNode.prototype.generate.call( this, builder, output, this.getUuid(), 't', 'renderTexture' ); 23 | 24 | }; 25 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/ScreenNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ScreenNode = function( coord ) { 6 | 7 | THREE.TextureNode.call( this, undefined, coord ); 8 | 9 | }; 10 | 11 | THREE.ScreenNode.prototype = Object.create( THREE.TextureNode.prototype ); 12 | THREE.ScreenNode.prototype.constructor = THREE.ScreenNode; 13 | 14 | THREE.ScreenNode.prototype.isUnique = function() { 15 | 16 | return true; 17 | 18 | }; 19 | 20 | THREE.ScreenNode.prototype.getTexture = function( builder, output ) { 21 | 22 | return THREE.InputNode.prototype.generate.call( this, builder, output, this.getUuid(), 't', 'renderTexture' ); 23 | 24 | }; 25 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/VarNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.VarNode = function( type ) { 6 | 7 | THREE.GLNode.call( this, type ); 8 | 9 | }; 10 | 11 | THREE.VarNode.prototype = Object.create( THREE.GLNode.prototype ); 12 | THREE.VarNode.prototype.constructor = THREE.VarNode; 13 | 14 | THREE.VarNode.prototype.getType = function( builder ) { 15 | 16 | return builder.getTypeByFormat( this.type ); 17 | 18 | }; 19 | 20 | THREE.VarNode.prototype.generate = function( builder, output ) { 21 | 22 | var varying = builder.material.getVar( this.uuid, this.type ); 23 | 24 | return builder.format( varying.name, this.getType( builder ), output ); 25 | 26 | }; 27 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/VarNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.VarNode = function( type ) { 6 | 7 | THREE.GLNode.call( this, type ); 8 | 9 | }; 10 | 11 | THREE.VarNode.prototype = Object.create( THREE.GLNode.prototype ); 12 | THREE.VarNode.prototype.constructor = THREE.VarNode; 13 | 14 | THREE.VarNode.prototype.getType = function( builder ) { 15 | 16 | return builder.getTypeByFormat( this.type ); 17 | 18 | }; 19 | 20 | THREE.VarNode.prototype.generate = function( builder, output ) { 21 | 22 | var varying = builder.material.getVar( this.uuid, this.type ); 23 | 24 | return builder.format( varying.name, this.getType( builder ), output ); 25 | 26 | }; 27 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/materials/PhongNodeMaterial.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.PhongNodeMaterial = function() { 6 | 7 | this.node = new THREE.PhongNode(); 8 | 9 | THREE.NodeMaterial.call( this, this.node, this.node ); 10 | 11 | }; 12 | 13 | THREE.PhongNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype ); 14 | THREE.PhongNodeMaterial.prototype.constructor = THREE.PhongNodeMaterial; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.PhongNodeMaterial.prototype, 'node', 17 | [ 'color', 'alpha', 'specular', 'shininess', 'normal', 'normalScale', 'emissive', 'ambient', 'light', 'shadow', 'ao', 'environment', 'environmentAlpha', 'transform' ] ); 18 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/materials/PhongNodeMaterial.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.PhongNodeMaterial = function() { 6 | 7 | this.node = new THREE.PhongNode(); 8 | 9 | THREE.NodeMaterial.call( this, this.node, this.node ); 10 | 11 | }; 12 | 13 | THREE.PhongNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype ); 14 | THREE.PhongNodeMaterial.prototype.constructor = THREE.PhongNodeMaterial; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.PhongNodeMaterial.prototype, 'node', 17 | [ 'color', 'alpha', 'specular', 'shininess', 'normal', 'normalScale', 'emissive', 'ambient', 'light', 'shadow', 'ao', 'environment', 'environmentAlpha', 'transform' ] ); 18 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/materials/StandardNodeMaterial.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.StandardNodeMaterial = function() { 6 | 7 | this.node = new THREE.StandardNode(); 8 | 9 | THREE.NodeMaterial.call( this, this.node, this.node ); 10 | 11 | }; 12 | 13 | THREE.StandardNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype ); 14 | THREE.StandardNodeMaterial.prototype.constructor = THREE.StandardNodeMaterial; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.StandardNodeMaterial.prototype, 'node', 17 | [ 'color', 'alpha', 'roughness', 'metalness', 'reflectivity', 'clearCoat', 'clearCoatRoughness', 'normal', 'normalScale', 'emissive', 'ambient', 'light', 'shadow', 'ao', 'environment', 'transform' ] ); 18 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/materials/StandardNodeMaterial.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.StandardNodeMaterial = function() { 6 | 7 | this.node = new THREE.StandardNode(); 8 | 9 | THREE.NodeMaterial.call( this, this.node, this.node ); 10 | 11 | }; 12 | 13 | THREE.StandardNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype ); 14 | THREE.StandardNodeMaterial.prototype.constructor = THREE.StandardNodeMaterial; 15 | 16 | THREE.NodeMaterial.addShortcuts( THREE.StandardNodeMaterial.prototype, 'node', 17 | [ 'color', 'alpha', 'roughness', 'metalness', 'reflectivity', 'clearCoat', 'clearCoatRoughness', 'normal', 'normalScale', 'emissive', 'ambient', 'light', 'shadow', 'ao', 'environment', 'transform' ] ); 18 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/accessors/LightNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.LightNode = function() { 6 | 7 | THREE.TempNode.call( this, 'v3', { shared: false } ); 8 | 9 | }; 10 | 11 | THREE.LightNode.prototype = Object.create( THREE.TempNode.prototype ); 12 | THREE.LightNode.prototype.constructor = THREE.LightNode; 13 | 14 | THREE.LightNode.prototype.generate = function( builder, output ) { 15 | 16 | if ( builder.isCache( 'light' ) ) { 17 | 18 | return builder.format( 'reflectedLight.directDiffuse', this.getType( builder ), output ) 19 | 20 | } else { 21 | 22 | console.warn( "THREE.LightNode is only compatible in \"light\" channel." ); 23 | 24 | return builder.format( 'vec3( 0.0 )', this.getType( builder ), output ); 25 | 26 | } 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/accessors/LightNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.LightNode = function() { 6 | 7 | THREE.TempNode.call( this, 'v3', { shared: false } ); 8 | 9 | }; 10 | 11 | THREE.LightNode.prototype = Object.create( THREE.TempNode.prototype ); 12 | THREE.LightNode.prototype.constructor = THREE.LightNode; 13 | 14 | THREE.LightNode.prototype.generate = function( builder, output ) { 15 | 16 | if ( builder.isCache( 'light' ) ) { 17 | 18 | return builder.format( 'reflectedLight.directDiffuse', this.getType( builder ), output ) 19 | 20 | } else { 21 | 22 | console.warn( "THREE.LightNode is only compatible in \"light\" channel." ); 23 | 24 | return builder.format( 'vec3( 0.0 )', this.getType( builder ), output ); 25 | 26 | } 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/RawNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.RawNode = function( value ) { 6 | 7 | THREE.GLNode.call( this, 'v4' ); 8 | 9 | this.value = value; 10 | 11 | }; 12 | 13 | THREE.RawNode.prototype = Object.create( THREE.GLNode.prototype ); 14 | THREE.RawNode.prototype.constructor = THREE.RawNode; 15 | 16 | THREE.GLNode.prototype.generate = function( builder ) { 17 | 18 | var material = builder.material; 19 | 20 | var data = this.value.parseAndBuildCode( builder, this.type ); 21 | 22 | var code = data.code + '\n'; 23 | 24 | if ( builder.shader == 'vertex' ) { 25 | 26 | code += 'gl_Position = ' + data.result + ';'; 27 | 28 | } else { 29 | 30 | code += 'gl_FragColor = ' + data.result + ';'; 31 | 32 | } 33 | 34 | return code; 35 | 36 | }; 37 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/RawNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.RawNode = function( value ) { 6 | 7 | THREE.GLNode.call( this, 'v4' ); 8 | 9 | this.value = value; 10 | 11 | }; 12 | 13 | THREE.RawNode.prototype = Object.create( THREE.GLNode.prototype ); 14 | THREE.RawNode.prototype.constructor = THREE.RawNode; 15 | 16 | THREE.GLNode.prototype.generate = function( builder ) { 17 | 18 | var material = builder.material; 19 | 20 | var data = this.value.parseAndBuildCode( builder, this.type ); 21 | 22 | var code = data.code + '\n'; 23 | 24 | if ( builder.shader == 'vertex' ) { 25 | 26 | code += 'gl_Position = ' + data.result + ';'; 27 | 28 | } else { 29 | 30 | code += 'gl_FragColor = ' + data.result + ';'; 31 | 32 | } 33 | 34 | return code; 35 | 36 | }; 37 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/loaders/SVGLoader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | * @author zz85 / http://joshuakoo.com/ 4 | */ 5 | 6 | THREE.SVGLoader = function ( manager ) { 7 | 8 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; 9 | 10 | }; 11 | 12 | THREE.SVGLoader.prototype = { 13 | 14 | constructor: THREE.SVGLoader, 15 | 16 | load: function ( url, onLoad, onProgress, onError ) { 17 | 18 | var scope = this; 19 | 20 | var parser = new DOMParser(); 21 | 22 | var loader = new THREE.FileLoader( scope.manager ); 23 | loader.load( url, function ( svgString ) { 24 | 25 | var doc = parser.parseFromString( svgString, 'image/svg+xml' ); // application/xml 26 | 27 | onLoad( doc.documentElement ); 28 | 29 | }, onProgress, onError ); 30 | 31 | } 32 | 33 | }; 34 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/loaders/SVGLoader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | * @author zz85 / http://joshuakoo.com/ 4 | */ 5 | 6 | THREE.SVGLoader = function ( manager ) { 7 | 8 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; 9 | 10 | }; 11 | 12 | THREE.SVGLoader.prototype = { 13 | 14 | constructor: THREE.SVGLoader, 15 | 16 | load: function ( url, onLoad, onProgress, onError ) { 17 | 18 | var scope = this; 19 | 20 | var parser = new DOMParser(); 21 | 22 | var loader = new THREE.FileLoader( scope.manager ); 23 | loader.load( url, function ( svgString ) { 24 | 25 | var doc = parser.parseFromString( svgString, 'image/svg+xml' ); // application/xml 26 | 27 | onLoad( doc.documentElement ); 28 | 29 | }, onProgress, onError ); 30 | 31 | } 32 | 33 | }; 34 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/postprocessing/NodePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.NodePass = function() { 6 | 7 | THREE.ShaderPass.call( this ); 8 | 9 | this.textureID = 'renderTexture'; 10 | 11 | this.fragment = new THREE.RawNode( new THREE.ScreenNode() ); 12 | 13 | this.node = new THREE.NodeMaterial(); 14 | this.node.fragment = this.fragment; 15 | 16 | this.build(); 17 | 18 | }; 19 | 20 | THREE.NodePass.prototype = Object.create( THREE.ShaderPass.prototype ); 21 | THREE.NodePass.prototype.constructor = THREE.NodePass; 22 | 23 | THREE.NodeMaterial.addShortcuts( THREE.NodePass.prototype, 'fragment', [ 'value' ] ); 24 | 25 | THREE.NodePass.prototype.build = function() { 26 | 27 | this.node.build(); 28 | 29 | this.uniforms = this.node.uniforms; 30 | this.material = this.node; 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/postprocessing/NodePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.NodePass = function() { 6 | 7 | THREE.ShaderPass.call( this ); 8 | 9 | this.textureID = 'renderTexture'; 10 | 11 | this.fragment = new THREE.RawNode( new THREE.ScreenNode() ); 12 | 13 | this.node = new THREE.NodeMaterial(); 14 | this.node.fragment = this.fragment; 15 | 16 | this.build(); 17 | 18 | }; 19 | 20 | THREE.NodePass.prototype = Object.create( THREE.ShaderPass.prototype ); 21 | THREE.NodePass.prototype.constructor = THREE.NodePass; 22 | 23 | THREE.NodeMaterial.addShortcuts( THREE.NodePass.prototype, 'fragment', [ 'value' ] ); 24 | 25 | THREE.NodePass.prototype.build = function() { 26 | 27 | this.node.build(); 28 | 29 | this.uniforms = this.node.uniforms; 30 | this.material = this.node; 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/CopyShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Full-screen textured quad shader 5 | */ 6 | 7 | THREE.CopyShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { value: null }, 12 | "opacity": { value: 1.0 } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 24 | 25 | "}" 26 | 27 | ].join( "\n" ), 28 | 29 | fragmentShader: [ 30 | 31 | "uniform float opacity;", 32 | 33 | "uniform sampler2D tDiffuse;", 34 | 35 | "varying vec2 vUv;", 36 | 37 | "void main() {", 38 | 39 | "vec4 texel = texture2D( tDiffuse, vUv );", 40 | "gl_FragColor = opacity * texel;", 41 | 42 | "}" 43 | 44 | ].join( "\n" ) 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/CopyShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Full-screen textured quad shader 5 | */ 6 | 7 | THREE.CopyShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { value: null }, 12 | "opacity": { value: 1.0 } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 24 | 25 | "}" 26 | 27 | ].join( "\n" ), 28 | 29 | fragmentShader: [ 30 | 31 | "uniform float opacity;", 32 | 33 | "uniform sampler2D tDiffuse;", 34 | 35 | "varying vec2 vUv;", 36 | 37 | "void main() {", 38 | 39 | "vec4 texel = texture2D( tDiffuse, vUv );", 40 | "gl_FragColor = opacity * texel;", 41 | 42 | "}" 43 | 44 | ].join( "\n" ) 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/GammaCorrectionShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author WestLangley / http://github.com/WestLangley 3 | * 4 | * Gamma Correction Shader 5 | * http://en.wikipedia.org/wiki/gamma_correction 6 | */ 7 | 8 | THREE.GammaCorrectionShader = { 9 | 10 | uniforms: { 11 | 12 | "tDiffuse": { value: null } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 24 | 25 | "}" 26 | 27 | ].join( "\n" ), 28 | 29 | fragmentShader: [ 30 | 31 | "uniform sampler2D tDiffuse;", 32 | 33 | "varying vec2 vUv;", 34 | 35 | "void main() {", 36 | 37 | "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );", 38 | 39 | "gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );", 40 | 41 | "}" 42 | 43 | ].join( "\n" ) 44 | 45 | }; 46 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/GammaCorrectionShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author WestLangley / http://github.com/WestLangley 3 | * 4 | * Gamma Correction Shader 5 | * http://en.wikipedia.org/wiki/gamma_correction 6 | */ 7 | 8 | THREE.GammaCorrectionShader = { 9 | 10 | uniforms: { 11 | 12 | "tDiffuse": { value: null } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 24 | 25 | "}" 26 | 27 | ].join( "\n" ), 28 | 29 | fragmentShader: [ 30 | 31 | "uniform sampler2D tDiffuse;", 32 | 33 | "varying vec2 vUv;", 34 | 35 | "void main() {", 36 | 37 | "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );", 38 | 39 | "gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );", 40 | 41 | "}" 42 | 43 | ].join( "\n" ) 44 | 45 | }; 46 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/accessors/UVNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.UVNode = function( index ) { 6 | 7 | THREE.TempNode.call( this, 'v2', { shared: false } ); 8 | 9 | this.index = index || 0; 10 | 11 | }; 12 | 13 | THREE.UVNode.vertexDict = [ 'uv', 'uv2' ]; 14 | THREE.UVNode.fragmentDict = [ 'vUv', 'vUv2' ]; 15 | 16 | THREE.UVNode.prototype = Object.create( THREE.TempNode.prototype ); 17 | THREE.UVNode.prototype.constructor = THREE.UVNode; 18 | 19 | THREE.UVNode.prototype.generate = function( builder, output ) { 20 | 21 | var material = builder.material; 22 | var result; 23 | 24 | material.requestAttribs.uv[ this.index ] = true; 25 | 26 | if ( builder.isShader( 'vertex' ) ) result = THREE.UVNode.vertexDict[ this.index ]; 27 | else result = THREE.UVNode.fragmentDict[ this.index ]; 28 | 29 | return builder.format( result, this.getType( builder ), output ); 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/accessors/UVNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.UVNode = function( index ) { 6 | 7 | THREE.TempNode.call( this, 'v2', { shared: false } ); 8 | 9 | this.index = index || 0; 10 | 11 | }; 12 | 13 | THREE.UVNode.vertexDict = [ 'uv', 'uv2' ]; 14 | THREE.UVNode.fragmentDict = [ 'vUv', 'vUv2' ]; 15 | 16 | THREE.UVNode.prototype = Object.create( THREE.TempNode.prototype ); 17 | THREE.UVNode.prototype.constructor = THREE.UVNode; 18 | 19 | THREE.UVNode.prototype.generate = function( builder, output ) { 20 | 21 | var material = builder.material; 22 | var result; 23 | 24 | material.requestAttribs.uv[ this.index ] = true; 25 | 26 | if ( builder.isShader( 'vertex' ) ) result = THREE.UVNode.vertexDict[ this.index ]; 27 | else result = THREE.UVNode.fragmentDict[ this.index ]; 28 | 29 | return builder.format( result, this.getType( builder ), output ); 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/accessors/ScreenUVNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ScreenUVNode = function( resolution ) { 6 | 7 | THREE.TempNode.call( this, 'v2' ); 8 | 9 | this.resolution = resolution; 10 | 11 | }; 12 | 13 | THREE.ScreenUVNode.prototype = Object.create( THREE.TempNode.prototype ); 14 | THREE.ScreenUVNode.prototype.constructor = THREE.ScreenUVNode; 15 | 16 | THREE.ScreenUVNode.prototype.generate = function( builder, output ) { 17 | 18 | var material = builder.material; 19 | var result; 20 | 21 | if ( builder.isShader( 'fragment' ) ) { 22 | 23 | result = '(gl_FragCoord.xy/' + this.resolution.build( builder, 'v2' ) + ')'; 24 | 25 | } else { 26 | 27 | console.warn( "THREE.ScreenUVNode is not compatible with " + builder.shader + " shader." ); 28 | 29 | result = 'vec2( 0.0 )'; 30 | 31 | } 32 | 33 | return builder.format( result, this.getType( builder ), output ); 34 | 35 | }; 36 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/LuminosityShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Luminosity 5 | * http://en.wikipedia.org/wiki/Luminosity 6 | */ 7 | 8 | THREE.LuminosityShader = { 9 | 10 | uniforms: { 11 | 12 | "tDiffuse": { value: null } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | 24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 25 | 26 | "}" 27 | 28 | ].join( "\n" ), 29 | 30 | fragmentShader: [ 31 | 32 | "uniform sampler2D tDiffuse;", 33 | 34 | "varying vec2 vUv;", 35 | 36 | "void main() {", 37 | 38 | "vec4 texel = texture2D( tDiffuse, vUv );", 39 | 40 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );", 41 | 42 | "float v = dot( texel.xyz, luma );", 43 | 44 | "gl_FragColor = vec4( v, v, v, texel.w );", 45 | 46 | "}" 47 | 48 | ].join( "\n" ) 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/accessors/ScreenUVNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ScreenUVNode = function( resolution ) { 6 | 7 | THREE.TempNode.call( this, 'v2' ); 8 | 9 | this.resolution = resolution; 10 | 11 | }; 12 | 13 | THREE.ScreenUVNode.prototype = Object.create( THREE.TempNode.prototype ); 14 | THREE.ScreenUVNode.prototype.constructor = THREE.ScreenUVNode; 15 | 16 | THREE.ScreenUVNode.prototype.generate = function( builder, output ) { 17 | 18 | var material = builder.material; 19 | var result; 20 | 21 | if ( builder.isShader( 'fragment' ) ) { 22 | 23 | result = '(gl_FragCoord.xy/' + this.resolution.build( builder, 'v2' ) + ')'; 24 | 25 | } else { 26 | 27 | console.warn( "THREE.ScreenUVNode is not compatible with " + builder.shader + " shader." ); 28 | 29 | result = 'vec2( 0.0 )'; 30 | 31 | } 32 | 33 | return builder.format( result, this.getType( builder ), output ); 34 | 35 | }; 36 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/LuminosityShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Luminosity 5 | * http://en.wikipedia.org/wiki/Luminosity 6 | */ 7 | 8 | THREE.LuminosityShader = { 9 | 10 | uniforms: { 11 | 12 | "tDiffuse": { value: null } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | 24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 25 | 26 | "}" 27 | 28 | ].join( "\n" ), 29 | 30 | fragmentShader: [ 31 | 32 | "uniform sampler2D tDiffuse;", 33 | 34 | "varying vec2 vUv;", 35 | 36 | "void main() {", 37 | 38 | "vec4 texel = texture2D( tDiffuse, vUv );", 39 | 40 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );", 41 | 42 | "float v = dot( texel.xyz, luma );", 43 | 44 | "gl_FragColor = vec4( v, v, v, texel.w );", 45 | 46 | "}" 47 | 48 | ].join( "\n" ) 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/modifiers/ExplodeModifier.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Make all faces use unique vertices 3 | * so that each face can be separated from others 4 | * 5 | * @author alteredq / http://alteredqualia.com/ 6 | */ 7 | 8 | THREE.ExplodeModifier = function () { 9 | 10 | }; 11 | 12 | THREE.ExplodeModifier.prototype.modify = function ( geometry ) { 13 | 14 | var vertices = []; 15 | 16 | for ( var i = 0, il = geometry.faces.length; i < il; i ++ ) { 17 | 18 | var n = vertices.length; 19 | 20 | var face = geometry.faces[ i ]; 21 | 22 | var a = face.a; 23 | var b = face.b; 24 | var c = face.c; 25 | 26 | var va = geometry.vertices[ a ]; 27 | var vb = geometry.vertices[ b ]; 28 | var vc = geometry.vertices[ c ]; 29 | 30 | vertices.push( va.clone() ); 31 | vertices.push( vb.clone() ); 32 | vertices.push( vc.clone() ); 33 | 34 | face.a = n; 35 | face.b = n + 1; 36 | face.c = n + 2; 37 | 38 | } 39 | 40 | geometry.vertices = vertices; 41 | 42 | }; 43 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/modifiers/ExplodeModifier.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Make all faces use unique vertices 3 | * so that each face can be separated from others 4 | * 5 | * @author alteredq / http://alteredqualia.com/ 6 | */ 7 | 8 | THREE.ExplodeModifier = function () { 9 | 10 | }; 11 | 12 | THREE.ExplodeModifier.prototype.modify = function ( geometry ) { 13 | 14 | var vertices = []; 15 | 16 | for ( var i = 0, il = geometry.faces.length; i < il; i ++ ) { 17 | 18 | var n = vertices.length; 19 | 20 | var face = geometry.faces[ i ]; 21 | 22 | var a = face.a; 23 | var b = face.b; 24 | var c = face.c; 25 | 26 | var va = geometry.vertices[ a ]; 27 | var vb = geometry.vertices[ b ]; 28 | var vc = geometry.vertices[ c ]; 29 | 30 | vertices.push( va.clone() ); 31 | vertices.push( vb.clone() ); 32 | vertices.push( vc.clone() ); 33 | 34 | face.a = n; 35 | face.b = n + 1; 36 | face.c = n + 2; 37 | 38 | } 39 | 40 | geometry.vertices = vertices; 41 | 42 | }; 43 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/accessors/ColorsNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ColorsNode = function( index ) { 6 | 7 | THREE.TempNode.call( this, 'v4', { shared: false } ); 8 | 9 | this.index = index || 0; 10 | 11 | }; 12 | 13 | THREE.ColorsNode.vertexDict = [ 'color', 'color2' ]; 14 | THREE.ColorsNode.fragmentDict = [ 'vColor', 'vColor2' ]; 15 | 16 | THREE.ColorsNode.prototype = Object.create( THREE.TempNode.prototype ); 17 | THREE.ColorsNode.prototype.constructor = THREE.ColorsNode; 18 | 19 | THREE.ColorsNode.prototype.generate = function( builder, output ) { 20 | 21 | var material = builder.material; 22 | var result; 23 | 24 | material.requestAttribs.color[ this.index ] = true; 25 | 26 | if ( builder.isShader( 'vertex' ) ) result = THREE.ColorsNode.vertexDict[ this.index ]; 27 | else result = THREE.ColorsNode.fragmentDict[ this.index ]; 28 | 29 | return builder.format( result, this.getType( builder ), output ); 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/ColorifyShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Colorify shader 5 | */ 6 | 7 | THREE.ColorifyShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { value: null }, 12 | "color": { value: new THREE.Color( 0xffffff ) } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 24 | 25 | "}" 26 | 27 | ].join( "\n" ), 28 | 29 | fragmentShader: [ 30 | 31 | "uniform vec3 color;", 32 | "uniform sampler2D tDiffuse;", 33 | 34 | "varying vec2 vUv;", 35 | 36 | "void main() {", 37 | 38 | "vec4 texel = texture2D( tDiffuse, vUv );", 39 | 40 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );", 41 | "float v = dot( texel.xyz, luma );", 42 | 43 | "gl_FragColor = vec4( v * color, texel.w );", 44 | 45 | "}" 46 | 47 | ].join( "\n" ) 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/accessors/ColorsNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ColorsNode = function( index ) { 6 | 7 | THREE.TempNode.call( this, 'v4', { shared: false } ); 8 | 9 | this.index = index || 0; 10 | 11 | }; 12 | 13 | THREE.ColorsNode.vertexDict = [ 'color', 'color2' ]; 14 | THREE.ColorsNode.fragmentDict = [ 'vColor', 'vColor2' ]; 15 | 16 | THREE.ColorsNode.prototype = Object.create( THREE.TempNode.prototype ); 17 | THREE.ColorsNode.prototype.constructor = THREE.ColorsNode; 18 | 19 | THREE.ColorsNode.prototype.generate = function( builder, output ) { 20 | 21 | var material = builder.material; 22 | var result; 23 | 24 | material.requestAttribs.color[ this.index ] = true; 25 | 26 | if ( builder.isShader( 'vertex' ) ) result = THREE.ColorsNode.vertexDict[ this.index ]; 27 | else result = THREE.ColorsNode.fragmentDict[ this.index ]; 28 | 29 | return builder.format( result, this.getType( builder ), output ); 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/ColorifyShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Colorify shader 5 | */ 6 | 7 | THREE.ColorifyShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { value: null }, 12 | "color": { value: new THREE.Color( 0xffffff ) } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 24 | 25 | "}" 26 | 27 | ].join( "\n" ), 28 | 29 | fragmentShader: [ 30 | 31 | "uniform vec3 color;", 32 | "uniform sampler2D tDiffuse;", 33 | 34 | "varying vec2 vUv;", 35 | 36 | "void main() {", 37 | 38 | "vec4 texel = texture2D( tDiffuse, vUv );", 39 | 40 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );", 41 | "float v = dot( texel.xyz, luma );", 42 | 43 | "gl_FragColor = vec4( v * color, texel.w );", 44 | 45 | "}" 46 | 47 | ].join( "\n" ) 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/loaders/ctm/license/OpenCTM.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2010 Marcus Geelnard 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not 17 | be misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source 20 | distribution. 21 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/loaders/ctm/license/OpenCTM.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2010 Marcus Geelnard 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not 17 | be misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source 20 | distribution. 21 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/UnpackDepthRGBAShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Unpack RGBA depth shader 5 | * - show RGBA encoded depth as monochrome color 6 | */ 7 | 8 | THREE.UnpackDepthRGBAShader = { 9 | 10 | uniforms: { 11 | 12 | "tDiffuse": { value: null }, 13 | "opacity": { value: 1.0 } 14 | 15 | }, 16 | 17 | vertexShader: [ 18 | 19 | "varying vec2 vUv;", 20 | 21 | "void main() {", 22 | 23 | "vUv = uv;", 24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 25 | 26 | "}" 27 | 28 | ].join( "\n" ), 29 | 30 | fragmentShader: [ 31 | 32 | "uniform float opacity;", 33 | 34 | "uniform sampler2D tDiffuse;", 35 | 36 | "varying vec2 vUv;", 37 | 38 | "#include ", 39 | 40 | "void main() {", 41 | 42 | "float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );", 43 | "gl_FragColor = opacity * vec4( vec3( depth ), 1.0 );", 44 | 45 | "}" 46 | 47 | ].join( "\n" ) 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/UnpackDepthRGBAShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Unpack RGBA depth shader 5 | * - show RGBA encoded depth as monochrome color 6 | */ 7 | 8 | THREE.UnpackDepthRGBAShader = { 9 | 10 | uniforms: { 11 | 12 | "tDiffuse": { value: null }, 13 | "opacity": { value: 1.0 } 14 | 15 | }, 16 | 17 | vertexShader: [ 18 | 19 | "varying vec2 vUv;", 20 | 21 | "void main() {", 22 | 23 | "vUv = uv;", 24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 25 | 26 | "}" 27 | 28 | ].join( "\n" ), 29 | 30 | fragmentShader: [ 31 | 32 | "uniform float opacity;", 33 | 34 | "uniform sampler2D tDiffuse;", 35 | 36 | "varying vec2 vUv;", 37 | 38 | "#include ", 39 | 40 | "void main() {", 41 | 42 | "float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );", 43 | "gl_FragColor = opacity * vec4( vec3( depth ), 1.0 );", 44 | 45 | "}" 46 | 47 | ].join( "\n" ) 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/BlendShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Blend two textures 5 | */ 6 | 7 | THREE.BlendShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse1": { value: null }, 12 | "tDiffuse2": { value: null }, 13 | "mixRatio": { value: 0.5 }, 14 | "opacity": { value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform float opacity;", 34 | "uniform float mixRatio;", 35 | 36 | "uniform sampler2D tDiffuse1;", 37 | "uniform sampler2D tDiffuse2;", 38 | 39 | "varying vec2 vUv;", 40 | 41 | "void main() {", 42 | 43 | "vec4 texel1 = texture2D( tDiffuse1, vUv );", 44 | "vec4 texel2 = texture2D( tDiffuse2, vUv );", 45 | "gl_FragColor = opacity * mix( texel1, texel2, mixRatio );", 46 | 47 | "}" 48 | 49 | ].join( "\n" ) 50 | 51 | }; 52 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/BlendShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Blend two textures 5 | */ 6 | 7 | THREE.BlendShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse1": { value: null }, 12 | "tDiffuse2": { value: null }, 13 | "mixRatio": { value: 0.5 }, 14 | "opacity": { value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform float opacity;", 34 | "uniform float mixRatio;", 35 | 36 | "uniform sampler2D tDiffuse1;", 37 | "uniform sampler2D tDiffuse2;", 38 | 39 | "varying vec2 vUv;", 40 | 41 | "void main() {", 42 | 43 | "vec4 texel1 = texture2D( tDiffuse1, vUv );", 44 | "vec4 texel2 = texture2D( tDiffuse2, vUv );", 45 | "gl_FragColor = opacity * mix( texel1, texel2, mixRatio );", 46 | 47 | "}" 48 | 49 | ].join( "\n" ) 50 | 51 | }; 52 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/ColorCorrectionShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Color correction 5 | */ 6 | 7 | THREE.ColorCorrectionShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { value: null }, 12 | "powRGB": { value: new THREE.Vector3( 2, 2, 2 ) }, 13 | "mulRGB": { value: new THREE.Vector3( 1, 1, 1 ) }, 14 | "addRGB": { value: new THREE.Vector3( 0, 0, 0 ) } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join( "\n" ), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform sampler2D tDiffuse;", 35 | "uniform vec3 powRGB;", 36 | "uniform vec3 mulRGB;", 37 | "uniform vec3 addRGB;", 38 | 39 | "varying vec2 vUv;", 40 | 41 | "void main() {", 42 | 43 | "gl_FragColor = texture2D( tDiffuse, vUv );", 44 | "gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );", 45 | 46 | "}" 47 | 48 | ].join( "\n" ) 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/ColorCorrectionShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Color correction 5 | */ 6 | 7 | THREE.ColorCorrectionShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { value: null }, 12 | "powRGB": { value: new THREE.Vector3( 2, 2, 2 ) }, 13 | "mulRGB": { value: new THREE.Vector3( 1, 1, 1 ) }, 14 | "addRGB": { value: new THREE.Vector3( 0, 0, 0 ) } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join( "\n" ), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform sampler2D tDiffuse;", 35 | "uniform vec3 powRGB;", 36 | "uniform vec3 mulRGB;", 37 | "uniform vec3 addRGB;", 38 | 39 | "varying vec2 vUv;", 40 | 41 | "void main() {", 42 | 43 | "gl_FragColor = texture2D( tDiffuse, vUv );", 44 | "gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );", 45 | 46 | "}" 47 | 48 | ].join( "\n" ) 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/crossfade/gui.js: -------------------------------------------------------------------------------- 1 | var transitionParams = { 2 | "useTexture": true, 3 | "transition": 0.5, 4 | "transitionSpeed": 2.0, 5 | "texture": 5, 6 | "loopTexture": true, 7 | "animateTransition": true, 8 | "textureThreshold": 0.3 9 | }; 10 | 11 | function initGUI() { 12 | 13 | var gui = new dat.GUI(); 14 | 15 | gui.add( transitionParams, "useTexture" ).onChange( function( value ) { 16 | 17 | transition.useTexture( value ); 18 | 19 | } ); 20 | 21 | gui.add( transitionParams, 'loopTexture' ); 22 | 23 | gui.add( transitionParams, 'texture', { Perlin: 0, Squares: 1, Cells: 2, Distort: 3, Gradient: 4, Radial: 5 } ).onChange( function( value ) { 24 | 25 | transition.setTexture( value ); 26 | 27 | } ).listen(); 28 | 29 | gui.add( transitionParams, "textureThreshold", 0, 1, 0.01 ).onChange( function( value ) { 30 | 31 | transition.setTextureThreshold( value ); 32 | 33 | } ); 34 | 35 | gui.add( transitionParams, "animateTransition" ); 36 | gui.add( transitionParams, "transition", 0, 1, 0.01 ).listen(); 37 | gui.add( transitionParams, "transitionSpeed", 0.5, 5, 0.01 ); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/crossfade/gui.js: -------------------------------------------------------------------------------- 1 | var transitionParams = { 2 | "useTexture": true, 3 | "transition": 0.5, 4 | "transitionSpeed": 2.0, 5 | "texture": 5, 6 | "loopTexture": true, 7 | "animateTransition": true, 8 | "textureThreshold": 0.3 9 | }; 10 | 11 | function initGUI() { 12 | 13 | var gui = new dat.GUI(); 14 | 15 | gui.add( transitionParams, "useTexture" ).onChange( function( value ) { 16 | 17 | transition.useTexture( value ); 18 | 19 | } ); 20 | 21 | gui.add( transitionParams, 'loopTexture' ); 22 | 23 | gui.add( transitionParams, 'texture', { Perlin: 0, Squares: 1, Cells: 2, Distort: 3, Gradient: 4, Radial: 5 } ).onChange( function( value ) { 24 | 25 | transition.setTexture( value ); 26 | 27 | } ).listen(); 28 | 29 | gui.add( transitionParams, "textureThreshold", 0, 1, 0.01 ).onChange( function( value ) { 30 | 31 | transition.setTextureThreshold( value ); 32 | 33 | } ); 34 | 35 | gui.add( transitionParams, "animateTransition" ); 36 | gui.add( transitionParams, "transition", 0, 1, 0.01 ).listen(); 37 | gui.add( transitionParams, "transitionSpeed", 0.5, 5, 0.01 ); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/AttributeNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.AttributeNode = function( name, type ) { 6 | 7 | THREE.GLNode.call( this, type ); 8 | 9 | this.name = name; 10 | 11 | }; 12 | 13 | THREE.AttributeNode.prototype = Object.create( THREE.GLNode.prototype ); 14 | THREE.AttributeNode.prototype.constructor = THREE.AttributeNode; 15 | 16 | THREE.AttributeNode.prototype.getAttributeType = function( builder ) { 17 | 18 | return typeof this.type === 'number' ? builder.getConstructorFromLength( this.type ) : this.type; 19 | 20 | }; 21 | 22 | THREE.AttributeNode.prototype.getType = function( builder ) { 23 | 24 | var type = this.getAttributeType( builder ); 25 | 26 | return builder.getTypeByFormat( type ); 27 | 28 | }; 29 | 30 | THREE.AttributeNode.prototype.generate = function( builder, output ) { 31 | 32 | var type = this.getAttributeType( builder ); 33 | 34 | var attribute = builder.material.getAttribute( this.name, type ); 35 | 36 | return builder.format( builder.isShader( 'vertex' ) ? this.name : attribute.varying.name, this.getType( builder ), output ); 37 | 38 | }; 39 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/TechnicolorShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author flimshaw / http://charliehoey.com 3 | * 4 | * Technicolor Shader 5 | * Simulates the look of the two-strip technicolor process popular in early 20th century films. 6 | * More historical info here: http://www.widescreenmuseum.com/oldcolor/technicolor1.htm 7 | * Demo here: http://charliehoey.com/technicolor_shader/shader_test.html 8 | */ 9 | 10 | THREE.TechnicolorShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { value: null } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform sampler2D tDiffuse;", 34 | "varying vec2 vUv;", 35 | 36 | "void main() {", 37 | 38 | "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );", 39 | "vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);", 40 | 41 | "gl_FragColor = newTex;", 42 | 43 | "}" 44 | 45 | ].join( "\n" ) 46 | 47 | }; 48 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/AttributeNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.AttributeNode = function( name, type ) { 6 | 7 | THREE.GLNode.call( this, type ); 8 | 9 | this.name = name; 10 | 11 | }; 12 | 13 | THREE.AttributeNode.prototype = Object.create( THREE.GLNode.prototype ); 14 | THREE.AttributeNode.prototype.constructor = THREE.AttributeNode; 15 | 16 | THREE.AttributeNode.prototype.getAttributeType = function( builder ) { 17 | 18 | return typeof this.type === 'number' ? builder.getConstructorFromLength( this.type ) : this.type; 19 | 20 | }; 21 | 22 | THREE.AttributeNode.prototype.getType = function( builder ) { 23 | 24 | var type = this.getAttributeType( builder ); 25 | 26 | return builder.getTypeByFormat( type ); 27 | 28 | }; 29 | 30 | THREE.AttributeNode.prototype.generate = function( builder, output ) { 31 | 32 | var type = this.getAttributeType( builder ); 33 | 34 | var attribute = builder.material.getAttribute( this.name, type ); 35 | 36 | return builder.format( builder.isShader( 'vertex' ) ? this.name : attribute.varying.name, this.getType( builder ), output ); 37 | 38 | }; 39 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/TechnicolorShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author flimshaw / http://charliehoey.com 3 | * 4 | * Technicolor Shader 5 | * Simulates the look of the two-strip technicolor process popular in early 20th century films. 6 | * More historical info here: http://www.widescreenmuseum.com/oldcolor/technicolor1.htm 7 | * Demo here: http://charliehoey.com/technicolor_shader/shader_test.html 8 | */ 9 | 10 | THREE.TechnicolorShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { value: null } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform sampler2D tDiffuse;", 34 | "varying vec2 vUv;", 35 | 36 | "void main() {", 37 | 38 | "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );", 39 | "vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);", 40 | 41 | "gl_FragColor = newTex;", 42 | 43 | "}" 44 | 45 | ].join( "\n" ) 46 | 47 | }; 48 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/postprocessing/ClearPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | THREE.ClearPass = function ( clearColor, clearAlpha ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.needsSwap = false; 10 | 11 | this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000; 12 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; 13 | 14 | }; 15 | 16 | THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 17 | 18 | constructor: THREE.ClearPass, 19 | 20 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 21 | 22 | var oldClearColor, oldClearAlpha; 23 | 24 | if ( this.clearColor ) { 25 | 26 | oldClearColor = renderer.getClearColor().getHex(); 27 | oldClearAlpha = renderer.getClearAlpha(); 28 | 29 | renderer.setClearColor( this.clearColor, this.clearAlpha ); 30 | 31 | } 32 | 33 | renderer.setRenderTarget( this.renderToScreen ? null : readBuffer ); 34 | renderer.clear(); 35 | 36 | if ( this.clearColor ) { 37 | 38 | renderer.setClearColor( oldClearColor, oldClearAlpha ); 39 | 40 | } 41 | 42 | } 43 | 44 | } ); 45 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/postprocessing/ClearPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | THREE.ClearPass = function ( clearColor, clearAlpha ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.needsSwap = false; 10 | 11 | this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000; 12 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; 13 | 14 | }; 15 | 16 | THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 17 | 18 | constructor: THREE.ClearPass, 19 | 20 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 21 | 22 | var oldClearColor, oldClearAlpha; 23 | 24 | if ( this.clearColor ) { 25 | 26 | oldClearColor = renderer.getClearColor().getHex(); 27 | oldClearAlpha = renderer.getClearAlpha(); 28 | 29 | renderer.setClearColor( this.clearColor, this.clearAlpha ); 30 | 31 | } 32 | 33 | renderer.setRenderTarget( this.renderToScreen ? null : readBuffer ); 34 | renderer.clear(); 35 | 36 | if ( this.clearColor ) { 37 | 38 | renderer.setClearColor( oldClearColor, oldClearAlpha ); 39 | 40 | } 41 | 42 | } 43 | 44 | } ); 45 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/loaders/ctm/license/js-lzma.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Juan Mellado 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/loaders/ctm/license/js-lzma.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Juan Mellado 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/loaders/ctm/license/js-openctm.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Juan Mellado 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/loaders/ctm/license/js-openctm.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Juan Mellado 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/exporters/TypedGeometryExporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | THREE.TypedGeometryExporter = function () {}; 6 | 7 | THREE.TypedGeometryExporter.prototype = { 8 | 9 | constructor: THREE.TypedGeometryExporter, 10 | 11 | parse: function ( geometry ) { 12 | 13 | var output = { 14 | metadata: { 15 | version: 4.0, 16 | type: 'TypedGeometry', 17 | generator: 'TypedGeometryExporter' 18 | } 19 | }; 20 | 21 | var attributes = [ 'vertices', 'normals', 'uvs' ]; 22 | 23 | for ( var key in attributes ) { 24 | 25 | var attribute = attributes[ key ]; 26 | 27 | var typedArray = geometry[ attribute ]; 28 | var array = []; 29 | 30 | for ( var i = 0, l = typedArray.length; i < l; i ++ ) { 31 | 32 | array[ i ] = typedArray[ i ]; 33 | 34 | } 35 | 36 | output[ attribute ] = array; 37 | 38 | } 39 | 40 | var boundingSphere = geometry.boundingSphere; 41 | 42 | if ( boundingSphere !== null ) { 43 | 44 | output.boundingSphere = { 45 | center: boundingSphere.center.toArray(), 46 | radius: boundingSphere.radius 47 | } 48 | 49 | } 50 | 51 | return output; 52 | 53 | } 54 | 55 | }; 56 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/exporters/TypedGeometryExporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | THREE.TypedGeometryExporter = function () {}; 6 | 7 | THREE.TypedGeometryExporter.prototype = { 8 | 9 | constructor: THREE.TypedGeometryExporter, 10 | 11 | parse: function ( geometry ) { 12 | 13 | var output = { 14 | metadata: { 15 | version: 4.0, 16 | type: 'TypedGeometry', 17 | generator: 'TypedGeometryExporter' 18 | } 19 | }; 20 | 21 | var attributes = [ 'vertices', 'normals', 'uvs' ]; 22 | 23 | for ( var key in attributes ) { 24 | 25 | var attribute = attributes[ key ]; 26 | 27 | var typedArray = geometry[ attribute ]; 28 | var array = []; 29 | 30 | for ( var i = 0, l = typedArray.length; i < l; i ++ ) { 31 | 32 | array[ i ] = typedArray[ i ]; 33 | 34 | } 35 | 36 | output[ attribute ] = array; 37 | 38 | } 39 | 40 | var boundingSphere = geometry.boundingSphere; 41 | 42 | if ( boundingSphere !== null ) { 43 | 44 | output.boundingSphere = { 45 | center: boundingSphere.center.toArray(), 46 | radius: boundingSphere.radius 47 | } 48 | 49 | } 50 | 51 | return output; 52 | 53 | } 54 | 55 | }; 56 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/SepiaShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Sepia tone shader 5 | * based on glfx.js sepia shader 6 | * https://github.com/evanw/glfx.js 7 | */ 8 | 9 | THREE.SepiaShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { value: null }, 14 | "amount": { value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform float amount;", 34 | 35 | "uniform sampler2D tDiffuse;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "vec4 color = texture2D( tDiffuse, vUv );", 42 | "vec3 c = color.rgb;", 43 | 44 | "color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );", 45 | "color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );", 46 | "color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );", 47 | 48 | "gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );", 49 | 50 | "}" 51 | 52 | ].join( "\n" ) 53 | 54 | }; 55 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/SepiaShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Sepia tone shader 5 | * based on glfx.js sepia shader 6 | * https://github.com/evanw/glfx.js 7 | */ 8 | 9 | THREE.SepiaShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { value: null }, 14 | "amount": { value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform float amount;", 34 | 35 | "uniform sampler2D tDiffuse;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "vec4 color = texture2D( tDiffuse, vUv );", 42 | "vec3 c = color.rgb;", 43 | 44 | "color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );", 45 | "color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );", 46 | "color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );", 47 | 48 | "gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );", 49 | 50 | "}" 51 | 52 | ].join( "\n" ) 53 | 54 | }; 55 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/DOFMipMapShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Depth-of-field shader using mipmaps 5 | * - from Matt Handley @applmak 6 | * - requires power-of-2 sized render target with enabled mipmaps 7 | */ 8 | 9 | THREE.DOFMipMapShader = { 10 | 11 | uniforms: { 12 | 13 | "tColor": { value: null }, 14 | "tDepth": { value: null }, 15 | "focus": { value: 1.0 }, 16 | "maxblur": { value: 1.0 } 17 | 18 | }, 19 | 20 | vertexShader: [ 21 | 22 | "varying vec2 vUv;", 23 | 24 | "void main() {", 25 | 26 | "vUv = uv;", 27 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 28 | 29 | "}" 30 | 31 | ].join( "\n" ), 32 | 33 | fragmentShader: [ 34 | 35 | "uniform float focus;", 36 | "uniform float maxblur;", 37 | 38 | "uniform sampler2D tColor;", 39 | "uniform sampler2D tDepth;", 40 | 41 | "varying vec2 vUv;", 42 | 43 | "void main() {", 44 | 45 | "vec4 depth = texture2D( tDepth, vUv );", 46 | 47 | "float factor = depth.x - focus;", 48 | 49 | "vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );", 50 | 51 | "gl_FragColor = col;", 52 | "gl_FragColor.a = 1.0;", 53 | 54 | "}" 55 | 56 | ].join( "\n" ) 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/DOFMipMapShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Depth-of-field shader using mipmaps 5 | * - from Matt Handley @applmak 6 | * - requires power-of-2 sized render target with enabled mipmaps 7 | */ 8 | 9 | THREE.DOFMipMapShader = { 10 | 11 | uniforms: { 12 | 13 | "tColor": { value: null }, 14 | "tDepth": { value: null }, 15 | "focus": { value: 1.0 }, 16 | "maxblur": { value: 1.0 } 17 | 18 | }, 19 | 20 | vertexShader: [ 21 | 22 | "varying vec2 vUv;", 23 | 24 | "void main() {", 25 | 26 | "vUv = uv;", 27 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 28 | 29 | "}" 30 | 31 | ].join( "\n" ), 32 | 33 | fragmentShader: [ 34 | 35 | "uniform float focus;", 36 | "uniform float maxblur;", 37 | 38 | "uniform sampler2D tColor;", 39 | "uniform sampler2D tDepth;", 40 | 41 | "varying vec2 vUv;", 42 | 43 | "void main() {", 44 | 45 | "vec4 depth = texture2D( tDepth, vUv );", 46 | 47 | "float factor = depth.x - focus;", 48 | 49 | "vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );", 50 | 51 | "gl_FragColor = col;", 52 | "gl_FragColor.a = 1.0;", 53 | 54 | "}" 55 | 56 | ].join( "\n" ) 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/MirrorShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author felixturner / http://airtight.cc/ 3 | * 4 | * Mirror Shader 5 | * Copies half the input to the other half 6 | * 7 | * side: side of input to mirror (0 = left, 1 = right, 2 = top, 3 = bottom) 8 | */ 9 | 10 | THREE.MirrorShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { value: null }, 15 | "side": { value: 1 } 16 | 17 | }, 18 | 19 | vertexShader: [ 20 | 21 | "varying vec2 vUv;", 22 | 23 | "void main() {", 24 | 25 | "vUv = uv;", 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join( "\n" ), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform sampler2D tDiffuse;", 35 | "uniform int side;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "vec2 p = vUv;", 42 | "if (side == 0){", 43 | "if (p.x > 0.5) p.x = 1.0 - p.x;", 44 | "}else if (side == 1){", 45 | "if (p.x < 0.5) p.x = 1.0 - p.x;", 46 | "}else if (side == 2){", 47 | "if (p.y < 0.5) p.y = 1.0 - p.y;", 48 | "}else if (side == 3){", 49 | "if (p.y > 0.5) p.y = 1.0 - p.y;", 50 | "} ", 51 | "vec4 color = texture2D(tDiffuse, p);", 52 | "gl_FragColor = color;", 53 | 54 | "}" 55 | 56 | ].join( "\n" ) 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/MirrorShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author felixturner / http://airtight.cc/ 3 | * 4 | * Mirror Shader 5 | * Copies half the input to the other half 6 | * 7 | * side: side of input to mirror (0 = left, 1 = right, 2 = top, 3 = bottom) 8 | */ 9 | 10 | THREE.MirrorShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { value: null }, 15 | "side": { value: 1 } 16 | 17 | }, 18 | 19 | vertexShader: [ 20 | 21 | "varying vec2 vUv;", 22 | 23 | "void main() {", 24 | 25 | "vUv = uv;", 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join( "\n" ), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform sampler2D tDiffuse;", 35 | "uniform int side;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "vec2 p = vUv;", 42 | "if (side == 0){", 43 | "if (p.x > 0.5) p.x = 1.0 - p.x;", 44 | "}else if (side == 1){", 45 | "if (p.x < 0.5) p.x = 1.0 - p.x;", 46 | "}else if (side == 2){", 47 | "if (p.y < 0.5) p.y = 1.0 - p.y;", 48 | "}else if (side == 3){", 49 | "if (p.y > 0.5) p.y = 1.0 - p.y;", 50 | "} ", 51 | "vec4 color = texture2D(tDiffuse, p);", 52 | "gl_FragColor = color;", 53 | 54 | "}" 55 | 56 | ].join( "\n" ) 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/InputNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.InputNode = function( type, params ) { 6 | 7 | params = params || {}; 8 | params.shared = params.shared !== undefined ? params.shared : false; 9 | 10 | THREE.TempNode.call( this, type, params ); 11 | 12 | }; 13 | 14 | THREE.InputNode.prototype = Object.create( THREE.TempNode.prototype ); 15 | THREE.InputNode.prototype.constructor = THREE.InputNode; 16 | 17 | THREE.InputNode.prototype.generate = function( builder, output, uuid, type, ns, needsUpdate ) { 18 | 19 | var material = builder.material; 20 | 21 | uuid = builder.getUuid( uuid || this.getUuid() ); 22 | type = type || this.getType( builder ); 23 | 24 | var data = material.getDataNode( uuid ); 25 | 26 | if ( builder.isShader( 'vertex' ) ) { 27 | 28 | if ( ! data.vertex ) { 29 | 30 | data.vertex = material.createVertexUniform( type, this.value, ns, needsUpdate ); 31 | 32 | } 33 | 34 | return builder.format( data.vertex.name, type, output ); 35 | 36 | } else { 37 | 38 | if ( ! data.fragment ) { 39 | 40 | data.fragment = material.createFragmentUniform( type, this.value, ns, needsUpdate ); 41 | 42 | } 43 | 44 | return builder.format( data.fragment.name, type, output ); 45 | 46 | } 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/InputNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.InputNode = function( type, params ) { 6 | 7 | params = params || {}; 8 | params.shared = params.shared !== undefined ? params.shared : false; 9 | 10 | THREE.TempNode.call( this, type, params ); 11 | 12 | }; 13 | 14 | THREE.InputNode.prototype = Object.create( THREE.TempNode.prototype ); 15 | THREE.InputNode.prototype.constructor = THREE.InputNode; 16 | 17 | THREE.InputNode.prototype.generate = function( builder, output, uuid, type, ns, needsUpdate ) { 18 | 19 | var material = builder.material; 20 | 21 | uuid = builder.getUuid( uuid || this.getUuid() ); 22 | type = type || this.getType( builder ); 23 | 24 | var data = material.getDataNode( uuid ); 25 | 26 | if ( builder.isShader( 'vertex' ) ) { 27 | 28 | if ( ! data.vertex ) { 29 | 30 | data.vertex = material.createVertexUniform( type, this.value, ns, needsUpdate ); 31 | 32 | } 33 | 34 | return builder.format( data.vertex.name, type, output ); 35 | 36 | } else { 37 | 38 | if ( ! data.fragment ) { 39 | 40 | data.fragment = material.createFragmentUniform( type, this.value, ns, needsUpdate ); 41 | 42 | } 43 | 44 | return builder.format( data.fragment.name, type, output ); 45 | 46 | } 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/NormalMapShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Normal map shader 5 | * - compute normals from heightmap 6 | */ 7 | 8 | THREE.NormalMapShader = { 9 | 10 | uniforms: { 11 | 12 | "heightMap": { value: null }, 13 | "resolution": { value: new THREE.Vector2( 512, 512 ) }, 14 | "scale": { value: new THREE.Vector2( 1, 1 ) }, 15 | "height": { value: 0.05 } 16 | 17 | }, 18 | 19 | vertexShader: [ 20 | 21 | "varying vec2 vUv;", 22 | 23 | "void main() {", 24 | 25 | "vUv = uv;", 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join( "\n" ), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform float height;", 35 | "uniform vec2 resolution;", 36 | "uniform sampler2D heightMap;", 37 | 38 | "varying vec2 vUv;", 39 | 40 | "void main() {", 41 | 42 | "float val = texture2D( heightMap, vUv ).x;", 43 | 44 | "float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;", 45 | "float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;", 46 | 47 | "gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );", 48 | 49 | "}" 50 | 51 | ].join( "\n" ) 52 | 53 | }; 54 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/NormalMapShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Normal map shader 5 | * - compute normals from heightmap 6 | */ 7 | 8 | THREE.NormalMapShader = { 9 | 10 | uniforms: { 11 | 12 | "heightMap": { value: null }, 13 | "resolution": { value: new THREE.Vector2( 512, 512 ) }, 14 | "scale": { value: new THREE.Vector2( 1, 1 ) }, 15 | "height": { value: 0.05 } 16 | 17 | }, 18 | 19 | vertexShader: [ 20 | 21 | "varying vec2 vUv;", 22 | 23 | "void main() {", 24 | 25 | "vUv = uv;", 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join( "\n" ), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform float height;", 35 | "uniform vec2 resolution;", 36 | "uniform sampler2D heightMap;", 37 | 38 | "varying vec2 vUv;", 39 | 40 | "void main() {", 41 | 42 | "float val = texture2D( heightMap, vUv ).x;", 43 | 44 | "float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;", 45 | "float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;", 46 | 47 | "gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );", 48 | 49 | "}" 50 | 51 | ].join( "\n" ) 52 | 53 | }; 54 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/RGBShiftShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author felixturner / http://airtight.cc/ 3 | * 4 | * RGB Shift Shader 5 | * Shifts red and blue channels from center in opposite directions 6 | * Ported from http://kriss.cx/tom/2009/05/rgb-shift/ 7 | * by Tom Butterworth / http://kriss.cx/tom/ 8 | * 9 | * amount: shift distance (1 is width of input) 10 | * angle: shift angle in radians 11 | */ 12 | 13 | THREE.RGBShiftShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { value: null }, 18 | "amount": { value: 0.005 }, 19 | "angle": { value: 0.0 } 20 | 21 | }, 22 | 23 | vertexShader: [ 24 | 25 | "varying vec2 vUv;", 26 | 27 | "void main() {", 28 | 29 | "vUv = uv;", 30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 31 | 32 | "}" 33 | 34 | ].join( "\n" ), 35 | 36 | fragmentShader: [ 37 | 38 | "uniform sampler2D tDiffuse;", 39 | "uniform float amount;", 40 | "uniform float angle;", 41 | 42 | "varying vec2 vUv;", 43 | 44 | "void main() {", 45 | 46 | "vec2 offset = amount * vec2( cos(angle), sin(angle));", 47 | "vec4 cr = texture2D(tDiffuse, vUv + offset);", 48 | "vec4 cga = texture2D(tDiffuse, vUv);", 49 | "vec4 cb = texture2D(tDiffuse, vUv - offset);", 50 | "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);", 51 | 52 | "}" 53 | 54 | ].join( "\n" ) 55 | 56 | }; 57 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/RGBShiftShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author felixturner / http://airtight.cc/ 3 | * 4 | * RGB Shift Shader 5 | * Shifts red and blue channels from center in opposite directions 6 | * Ported from http://kriss.cx/tom/2009/05/rgb-shift/ 7 | * by Tom Butterworth / http://kriss.cx/tom/ 8 | * 9 | * amount: shift distance (1 is width of input) 10 | * angle: shift angle in radians 11 | */ 12 | 13 | THREE.RGBShiftShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { value: null }, 18 | "amount": { value: 0.005 }, 19 | "angle": { value: 0.0 } 20 | 21 | }, 22 | 23 | vertexShader: [ 24 | 25 | "varying vec2 vUv;", 26 | 27 | "void main() {", 28 | 29 | "vUv = uv;", 30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 31 | 32 | "}" 33 | 34 | ].join( "\n" ), 35 | 36 | fragmentShader: [ 37 | 38 | "uniform sampler2D tDiffuse;", 39 | "uniform float amount;", 40 | "uniform float angle;", 41 | 42 | "varying vec2 vUv;", 43 | 44 | "void main() {", 45 | 46 | "vec2 offset = amount * vec2( cos(angle), sin(angle));", 47 | "vec4 cr = texture2D(tDiffuse, vUv + offset);", 48 | "vec4 cga = texture2D(tDiffuse, vUv);", 49 | "vec4 cb = texture2D(tDiffuse, vUv - offset);", 50 | "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);", 51 | 52 | "}" 53 | 54 | ].join( "\n" ) 55 | 56 | }; 57 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/KaleidoShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author felixturner / http://airtight.cc/ 3 | * 4 | * Kaleidoscope Shader 5 | * Radial reflection around center point 6 | * Ported from: http://pixelshaders.com/editor/ 7 | * by Toby Schachman / http://tobyschachman.com/ 8 | * 9 | * sides: number of reflections 10 | * angle: initial angle in radians 11 | */ 12 | 13 | THREE.KaleidoShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { value: null }, 18 | "sides": { value: 6.0 }, 19 | "angle": { value: 0.0 } 20 | 21 | }, 22 | 23 | vertexShader: [ 24 | 25 | "varying vec2 vUv;", 26 | 27 | "void main() {", 28 | 29 | "vUv = uv;", 30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 31 | 32 | "}" 33 | 34 | ].join( "\n" ), 35 | 36 | fragmentShader: [ 37 | 38 | "uniform sampler2D tDiffuse;", 39 | "uniform float sides;", 40 | "uniform float angle;", 41 | 42 | "varying vec2 vUv;", 43 | 44 | "void main() {", 45 | 46 | "vec2 p = vUv - 0.5;", 47 | "float r = length(p);", 48 | "float a = atan(p.y, p.x) + angle;", 49 | "float tau = 2. * 3.1416 ;", 50 | "a = mod(a, tau/sides);", 51 | "a = abs(a - tau/sides/2.) ;", 52 | "p = r * vec2(cos(a), sin(a));", 53 | "vec4 color = texture2D(tDiffuse, p + 0.5);", 54 | "gl_FragColor = color;", 55 | 56 | "}" 57 | 58 | ].join( "\n" ) 59 | 60 | }; 61 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/KaleidoShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author felixturner / http://airtight.cc/ 3 | * 4 | * Kaleidoscope Shader 5 | * Radial reflection around center point 6 | * Ported from: http://pixelshaders.com/editor/ 7 | * by Toby Schachman / http://tobyschachman.com/ 8 | * 9 | * sides: number of reflections 10 | * angle: initial angle in radians 11 | */ 12 | 13 | THREE.KaleidoShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { value: null }, 18 | "sides": { value: 6.0 }, 19 | "angle": { value: 0.0 } 20 | 21 | }, 22 | 23 | vertexShader: [ 24 | 25 | "varying vec2 vUv;", 26 | 27 | "void main() {", 28 | 29 | "vUv = uv;", 30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 31 | 32 | "}" 33 | 34 | ].join( "\n" ), 35 | 36 | fragmentShader: [ 37 | 38 | "uniform sampler2D tDiffuse;", 39 | "uniform float sides;", 40 | "uniform float angle;", 41 | 42 | "varying vec2 vUv;", 43 | 44 | "void main() {", 45 | 46 | "vec2 p = vUv - 0.5;", 47 | "float r = length(p);", 48 | "float a = atan(p.y, p.x) + angle;", 49 | "float tau = 2. * 3.1416 ;", 50 | "a = mod(a, tau/sides);", 51 | "a = abs(a - tau/sides/2.) ;", 52 | "p = r * vec2(cos(a), sin(a));", 53 | "vec4 color = texture2D(tDiffuse, p + 0.5);", 54 | "gl_FragColor = color;", 55 | 56 | "}" 57 | 58 | ].join( "\n" ) 59 | 60 | }; 61 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/effects/StereoEffect.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * @authod mrdoob / http://mrdoob.com/ 4 | * @authod arodic / http://aleksandarrodic.com/ 5 | * @authod fonserbc / http://fonserbc.github.io/ 6 | */ 7 | 8 | THREE.StereoEffect = function ( renderer ) { 9 | 10 | var _stereo = new THREE.StereoCamera(); 11 | _stereo.aspect = 0.5; 12 | 13 | this.setEyeSeparation = function ( eyeSep ) { 14 | 15 | _stereo.eyeSep = eyeSep; 16 | 17 | }; 18 | 19 | this.setSize = function ( width, height ) { 20 | 21 | renderer.setSize( width, height ); 22 | 23 | }; 24 | 25 | this.render = function ( scene, camera ) { 26 | 27 | scene.updateMatrixWorld(); 28 | 29 | if ( camera.parent === null ) camera.updateMatrixWorld(); 30 | 31 | _stereo.update( camera ); 32 | 33 | var size = renderer.getSize(); 34 | 35 | if ( renderer.autoClear ) renderer.clear(); 36 | renderer.setScissorTest( true ); 37 | 38 | renderer.setScissor( 0, 0, size.width / 2, size.height ); 39 | renderer.setViewport( 0, 0, size.width / 2, size.height ); 40 | renderer.render( scene, _stereo.cameraL ); 41 | 42 | renderer.setScissor( size.width / 2, 0, size.width / 2, size.height ); 43 | renderer.setViewport( size.width / 2, 0, size.width / 2, size.height ); 44 | renderer.render( scene, _stereo.cameraR ); 45 | 46 | renderer.setScissorTest( false ); 47 | 48 | }; 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/BrightnessContrastShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author tapio / http://tapio.github.com/ 3 | * 4 | * Brightness and contrast adjustment 5 | * https://github.com/evanw/glfx.js 6 | * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white) 7 | * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) 8 | */ 9 | 10 | THREE.BrightnessContrastShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { value: null }, 15 | "brightness": { value: 0 }, 16 | "contrast": { value: 0 } 17 | 18 | }, 19 | 20 | vertexShader: [ 21 | 22 | "varying vec2 vUv;", 23 | 24 | "void main() {", 25 | 26 | "vUv = uv;", 27 | 28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 29 | 30 | "}" 31 | 32 | ].join( "\n" ), 33 | 34 | fragmentShader: [ 35 | 36 | "uniform sampler2D tDiffuse;", 37 | "uniform float brightness;", 38 | "uniform float contrast;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "gl_FragColor = texture2D( tDiffuse, vUv );", 45 | 46 | "gl_FragColor.rgb += brightness;", 47 | 48 | "if (contrast > 0.0) {", 49 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;", 50 | "} else {", 51 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;", 52 | "}", 53 | 54 | "}" 55 | 56 | ].join( "\n" ) 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/effects/StereoEffect.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * @authod mrdoob / http://mrdoob.com/ 4 | * @authod arodic / http://aleksandarrodic.com/ 5 | * @authod fonserbc / http://fonserbc.github.io/ 6 | */ 7 | 8 | THREE.StereoEffect = function ( renderer ) { 9 | 10 | var _stereo = new THREE.StereoCamera(); 11 | _stereo.aspect = 0.5; 12 | 13 | this.setEyeSeparation = function ( eyeSep ) { 14 | 15 | _stereo.eyeSep = eyeSep; 16 | 17 | }; 18 | 19 | this.setSize = function ( width, height ) { 20 | 21 | renderer.setSize( width, height ); 22 | 23 | }; 24 | 25 | this.render = function ( scene, camera ) { 26 | 27 | scene.updateMatrixWorld(); 28 | 29 | if ( camera.parent === null ) camera.updateMatrixWorld(); 30 | 31 | _stereo.update( camera ); 32 | 33 | var size = renderer.getSize(); 34 | 35 | if ( renderer.autoClear ) renderer.clear(); 36 | renderer.setScissorTest( true ); 37 | 38 | renderer.setScissor( 0, 0, size.width / 2, size.height ); 39 | renderer.setViewport( 0, 0, size.width / 2, size.height ); 40 | renderer.render( scene, _stereo.cameraL ); 41 | 42 | renderer.setScissor( size.width / 2, 0, size.width / 2, size.height ); 43 | renderer.setViewport( size.width / 2, 0, size.width / 2, size.height ); 44 | renderer.render( scene, _stereo.cameraR ); 45 | 46 | renderer.setScissorTest( false ); 47 | 48 | }; 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/BrightnessContrastShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author tapio / http://tapio.github.com/ 3 | * 4 | * Brightness and contrast adjustment 5 | * https://github.com/evanw/glfx.js 6 | * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white) 7 | * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) 8 | */ 9 | 10 | THREE.BrightnessContrastShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { value: null }, 15 | "brightness": { value: 0 }, 16 | "contrast": { value: 0 } 17 | 18 | }, 19 | 20 | vertexShader: [ 21 | 22 | "varying vec2 vUv;", 23 | 24 | "void main() {", 25 | 26 | "vUv = uv;", 27 | 28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 29 | 30 | "}" 31 | 32 | ].join( "\n" ), 33 | 34 | fragmentShader: [ 35 | 36 | "uniform sampler2D tDiffuse;", 37 | "uniform float brightness;", 38 | "uniform float contrast;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "gl_FragColor = texture2D( tDiffuse, vUv );", 45 | 46 | "gl_FragColor.rgb += brightness;", 47 | 48 | "if (contrast > 0.0) {", 49 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;", 50 | "} else {", 51 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;", 52 | "}", 53 | 54 | "}" 55 | 56 | ].join( "\n" ) 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/math/OperatorNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.OperatorNode = function( a, b, op ) { 6 | 7 | THREE.TempNode.call( this ); 8 | 9 | this.a = a; 10 | this.b = b; 11 | this.op = op || THREE.OperatorNode.ADD; 12 | 13 | }; 14 | 15 | THREE.OperatorNode.ADD = '+'; 16 | THREE.OperatorNode.SUB = '-'; 17 | THREE.OperatorNode.MUL = '*'; 18 | THREE.OperatorNode.DIV = '/'; 19 | 20 | THREE.OperatorNode.prototype = Object.create( THREE.TempNode.prototype ); 21 | THREE.OperatorNode.prototype.constructor = THREE.OperatorNode; 22 | 23 | THREE.OperatorNode.prototype.getType = function( builder ) { 24 | 25 | var a = this.a.getType( builder ); 26 | var b = this.b.getType( builder ); 27 | 28 | if ( builder.isFormatMatrix( a ) ) { 29 | 30 | return 'v4'; 31 | 32 | } else if ( builder.getFormatLength( b ) > builder.getFormatLength( a ) ) { 33 | 34 | // use the greater length vector 35 | 36 | return b; 37 | 38 | } 39 | 40 | return a; 41 | 42 | }; 43 | 44 | THREE.OperatorNode.prototype.generate = function( builder, output ) { 45 | 46 | var material = builder.material, 47 | data = material.getDataNode( this.uuid ); 48 | 49 | var type = this.getType( builder ); 50 | 51 | var a = this.a.build( builder, type ); 52 | var b = this.b.build( builder, type ); 53 | 54 | return builder.format( '(' + a + this.op + b + ')', type, output ); 55 | 56 | }; 57 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/math/OperatorNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.OperatorNode = function( a, b, op ) { 6 | 7 | THREE.TempNode.call( this ); 8 | 9 | this.a = a; 10 | this.b = b; 11 | this.op = op || THREE.OperatorNode.ADD; 12 | 13 | }; 14 | 15 | THREE.OperatorNode.ADD = '+'; 16 | THREE.OperatorNode.SUB = '-'; 17 | THREE.OperatorNode.MUL = '*'; 18 | THREE.OperatorNode.DIV = '/'; 19 | 20 | THREE.OperatorNode.prototype = Object.create( THREE.TempNode.prototype ); 21 | THREE.OperatorNode.prototype.constructor = THREE.OperatorNode; 22 | 23 | THREE.OperatorNode.prototype.getType = function( builder ) { 24 | 25 | var a = this.a.getType( builder ); 26 | var b = this.b.getType( builder ); 27 | 28 | if ( builder.isFormatMatrix( a ) ) { 29 | 30 | return 'v4'; 31 | 32 | } else if ( builder.getFormatLength( b ) > builder.getFormatLength( a ) ) { 33 | 34 | // use the greater length vector 35 | 36 | return b; 37 | 38 | } 39 | 40 | return a; 41 | 42 | }; 43 | 44 | THREE.OperatorNode.prototype.generate = function( builder, output ) { 45 | 46 | var material = builder.material, 47 | data = material.getDataNode( this.uuid ); 48 | 49 | var type = this.getType( builder ); 50 | 51 | var a = this.a.build( builder, type ); 52 | var b = this.b.build( builder, type ); 53 | 54 | return builder.format( '(' + a + this.op + b + ')', type, output ); 55 | 56 | }; 57 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/NormalMapNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.NormalMapNode = function( value, uv, scale, normal, position ) { 6 | 7 | THREE.TempNode.call( this, 'v3' ); 8 | 9 | this.value = value; 10 | this.scale = scale || new THREE.FloatNode( 1 ); 11 | 12 | this.normal = normal || new THREE.NormalNode( THREE.NormalNode.LOCAL ); 13 | this.position = position || new THREE.PositionNode( THREE.NormalNode.VIEW ); 14 | 15 | }; 16 | 17 | THREE.NormalMapNode.prototype = Object.create( THREE.TempNode.prototype ); 18 | THREE.NormalMapNode.prototype.constructor = THREE.NormalMapNode; 19 | 20 | THREE.NormalMapNode.prototype.generate = function( builder, output ) { 21 | 22 | var material = builder.material; 23 | 24 | builder.include( 'perturbNormal2Arb' ); 25 | 26 | if ( builder.isShader( 'fragment' ) ) { 27 | 28 | return builder.format( 'perturbNormal2Arb(-' + this.position.build( builder, 'v3' ) + ',' + 29 | this.normal.build( builder, 'v3' ) + ',' + 30 | this.value.build( builder, 'v3' ) + ',' + 31 | this.value.coord.build( builder, 'v2' ) + ',' + 32 | this.scale.build( builder, 'v2' ) + ')', this.getType( builder ), output ); 33 | 34 | } else { 35 | 36 | console.warn( "THREE.NormalMapNode is not compatible with " + builder.shader + " shader." ); 37 | 38 | return builder.format( 'vec3( 0.0 )', this.getType( builder ), output ); 39 | 40 | } 41 | 42 | }; 43 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/NormalMapNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.NormalMapNode = function( value, uv, scale, normal, position ) { 6 | 7 | THREE.TempNode.call( this, 'v3' ); 8 | 9 | this.value = value; 10 | this.scale = scale || new THREE.FloatNode( 1 ); 11 | 12 | this.normal = normal || new THREE.NormalNode( THREE.NormalNode.LOCAL ); 13 | this.position = position || new THREE.PositionNode( THREE.NormalNode.VIEW ); 14 | 15 | }; 16 | 17 | THREE.NormalMapNode.prototype = Object.create( THREE.TempNode.prototype ); 18 | THREE.NormalMapNode.prototype.constructor = THREE.NormalMapNode; 19 | 20 | THREE.NormalMapNode.prototype.generate = function( builder, output ) { 21 | 22 | var material = builder.material; 23 | 24 | builder.include( 'perturbNormal2Arb' ); 25 | 26 | if ( builder.isShader( 'fragment' ) ) { 27 | 28 | return builder.format( 'perturbNormal2Arb(-' + this.position.build( builder, 'v3' ) + ',' + 29 | this.normal.build( builder, 'v3' ) + ',' + 30 | this.value.build( builder, 'v3' ) + ',' + 31 | this.value.coord.build( builder, 'v2' ) + ',' + 32 | this.scale.build( builder, 'v2' ) + ')', this.getType( builder ), output ); 33 | 34 | } else { 35 | 36 | console.warn( "THREE.NormalMapNode is not compatible with " + builder.shader + " shader." ); 37 | 38 | return builder.format( 'vec3( 0.0 )', this.getType( builder ), output ); 39 | 40 | } 41 | 42 | }; 43 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/FunctionCallNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.FunctionCallNode = function( func, inputs ) { 6 | 7 | THREE.TempNode.call( this ); 8 | 9 | this.setFunction( func, inputs ); 10 | 11 | }; 12 | 13 | THREE.FunctionCallNode.prototype = Object.create( THREE.TempNode.prototype ); 14 | THREE.FunctionCallNode.prototype.constructor = THREE.FunctionCallNode; 15 | 16 | THREE.FunctionCallNode.prototype.setFunction = function( func, inputs ) { 17 | 18 | this.value = func; 19 | this.inputs = inputs || []; 20 | 21 | }; 22 | 23 | THREE.FunctionCallNode.prototype.getFunction = function() { 24 | 25 | return this.value; 26 | 27 | }; 28 | 29 | THREE.FunctionCallNode.prototype.getType = function( builder ) { 30 | 31 | return this.value.getType( builder ); 32 | 33 | }; 34 | 35 | THREE.FunctionCallNode.prototype.generate = function( builder, output ) { 36 | 37 | var material = builder.material; 38 | 39 | var type = this.getType( builder ); 40 | var func = this.value; 41 | 42 | var code = func.build( builder, output ) + '('; 43 | var params = []; 44 | 45 | for ( var i = 0; i < func.inputs.length; i ++ ) { 46 | 47 | var inpt = func.inputs[ i ]; 48 | var param = this.inputs[ i ] || this.inputs[ inpt.name ]; 49 | 50 | params.push( param.build( builder, builder.getTypeByFormat( inpt.type ) ) ); 51 | 52 | } 53 | 54 | code += params.join( ',' ) + ')'; 55 | 56 | return builder.format( code, type, output ); 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/FunctionCallNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.FunctionCallNode = function( func, inputs ) { 6 | 7 | THREE.TempNode.call( this ); 8 | 9 | this.setFunction( func, inputs ); 10 | 11 | }; 12 | 13 | THREE.FunctionCallNode.prototype = Object.create( THREE.TempNode.prototype ); 14 | THREE.FunctionCallNode.prototype.constructor = THREE.FunctionCallNode; 15 | 16 | THREE.FunctionCallNode.prototype.setFunction = function( func, inputs ) { 17 | 18 | this.value = func; 19 | this.inputs = inputs || []; 20 | 21 | }; 22 | 23 | THREE.FunctionCallNode.prototype.getFunction = function() { 24 | 25 | return this.value; 26 | 27 | }; 28 | 29 | THREE.FunctionCallNode.prototype.getType = function( builder ) { 30 | 31 | return this.value.getType( builder ); 32 | 33 | }; 34 | 35 | THREE.FunctionCallNode.prototype.generate = function( builder, output ) { 36 | 37 | var material = builder.material; 38 | 39 | var type = this.getType( builder ); 40 | var func = this.value; 41 | 42 | var code = func.build( builder, output ) + '('; 43 | var params = []; 44 | 45 | for ( var i = 0; i < func.inputs.length; i ++ ) { 46 | 47 | var inpt = func.inputs[ i ]; 48 | var param = this.inputs[ i ] || this.inputs[ inpt.name ]; 49 | 50 | params.push( param.build( builder, builder.getTypeByFormat( inpt.type ) ) ); 51 | 52 | } 53 | 54 | code += params.join( ',' ) + ')'; 55 | 56 | return builder.format( code, type, output ); 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/libs/system.min.js: -------------------------------------------------------------------------------- 1 | // system.js - http://github.com/mrdoob/system.js 2 | 'use strict';var System={browser:function(){var a=navigator.userAgent;return/Arora/i.test(a)?"Arora":/Chrome/i.test(a)?"Chrome":/Epiphany/i.test(a)?"Epiphany":/Firefox/i.test(a)?"Firefox":/Mobile(\/.*)? Safari/i.test(a)?"Mobile Safari":/MSIE/i.test(a)?"Internet Explorer":/Midori/i.test(a)?"Midori":/Opera/.test(a)?"Opera":/Safari/i.test(a)?"Safari":!1}(),os:function(){var a=navigator.userAgent;return/Android/i.test(a)?"Android":/CrOS/i.test(a)?"Chrome OS":/iP[ao]d|iPhone/i.test(a)?"iOS":/Linux/i.test(a)? 3 | "Linux":/Mac OS/i.test(a)?"Mac OS":/windows/i.test(a)?"Windows":!1}(),support:{canvas:!!window.CanvasRenderingContext2D,localStorage:function(){try{return!!window.localStorage.getItem}catch(a){return!1}}(),file:!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob,fileSystem:!!window.requestFileSystem||!!window.webkitRequestFileSystem,getUserMedia:!!window.navigator.getUserMedia||!!window.navigator.webkitGetUserMedia||!!window.navigator.mozGetUserMedia||!!window.navigator.msGetUserMedia, 4 | requestAnimationFrame:!!window.mozRequestAnimationFrame||!!window.webkitRequestAnimationFrame||!!window.oRequestAnimationFrame||!!window.msRequestAnimationFrame,sessionStorage:function(){try{return!!window.sessionStorage.getItem}catch(a){return!1}}(),webgl:function(){try{return!!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(a){return!1}}(),worker:!!window.Worker}}; 5 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/libs/system.min.js: -------------------------------------------------------------------------------- 1 | // system.js - http://github.com/mrdoob/system.js 2 | 'use strict';var System={browser:function(){var a=navigator.userAgent;return/Arora/i.test(a)?"Arora":/Chrome/i.test(a)?"Chrome":/Epiphany/i.test(a)?"Epiphany":/Firefox/i.test(a)?"Firefox":/Mobile(\/.*)? Safari/i.test(a)?"Mobile Safari":/MSIE/i.test(a)?"Internet Explorer":/Midori/i.test(a)?"Midori":/Opera/.test(a)?"Opera":/Safari/i.test(a)?"Safari":!1}(),os:function(){var a=navigator.userAgent;return/Android/i.test(a)?"Android":/CrOS/i.test(a)?"Chrome OS":/iP[ao]d|iPhone/i.test(a)?"iOS":/Linux/i.test(a)? 3 | "Linux":/Mac OS/i.test(a)?"Mac OS":/windows/i.test(a)?"Windows":!1}(),support:{canvas:!!window.CanvasRenderingContext2D,localStorage:function(){try{return!!window.localStorage.getItem}catch(a){return!1}}(),file:!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob,fileSystem:!!window.requestFileSystem||!!window.webkitRequestFileSystem,getUserMedia:!!window.navigator.getUserMedia||!!window.navigator.webkitGetUserMedia||!!window.navigator.mozGetUserMedia||!!window.navigator.msGetUserMedia, 4 | requestAnimationFrame:!!window.mozRequestAnimationFrame||!!window.webkitRequestAnimationFrame||!!window.oRequestAnimationFrame||!!window.msRequestAnimationFrame,sessionStorage:function(){try{return!!window.sessionStorage.getItem}catch(a){return!1}}(),webgl:function(){try{return!!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(a){return!1}}(),worker:!!window.Worker}}; 5 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/math/ColorConverter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author bhouston / http://exocortex.com/ 3 | * @author zz85 / http://github.com/zz85 4 | */ 5 | 6 | THREE.ColorConverter = { 7 | 8 | setHSV: function ( color, h, s, v ) { 9 | 10 | // https://gist.github.com/xpansive/1337890#file-index-js 11 | 12 | h = THREE.Math.euclideanModulo( h, 1 ); 13 | s = THREE.Math.clamp( s, 0, 1 ); 14 | v = THREE.Math.clamp( v, 0, 1 ); 15 | 16 | return color.setHSL( h, ( s * v ) / ( ( h = ( 2 - s ) * v ) < 1 ? h : ( 2 - h ) ), h * 0.5 ); 17 | 18 | }, 19 | 20 | getHSV: function( color ) { 21 | 22 | var hsl = color.getHSL(); 23 | 24 | // based on https://gist.github.com/xpansive/1337890#file-index-js 25 | hsl.s *= ( hsl.l < 0.5 ) ? hsl.l : ( 1 - hsl.l ); 26 | 27 | return { 28 | h: hsl.h, 29 | s: 2 * hsl.s / ( hsl.l + hsl.s ), 30 | v: hsl.l + hsl.s 31 | }; 32 | 33 | }, 34 | 35 | // where c, m, y, k is between 0 and 1 36 | 37 | setCMYK: function ( color, c, m, y, k ) { 38 | 39 | var r = ( 1 - c ) * ( 1 - k ); 40 | var g = ( 1 - m ) * ( 1 - k ); 41 | var b = ( 1 - y ) * ( 1 - k ); 42 | 43 | return color.setRGB( r, g, b ); 44 | 45 | }, 46 | 47 | getCMYK: function ( color ) { 48 | 49 | var r = color.r; 50 | var g = color.g; 51 | var b = color.b; 52 | var k = 1 - Math.max( r, g, b ); 53 | var c = ( 1 - r - k ) / ( 1 - k ); 54 | var m = ( 1 - g - k ) / ( 1 - k ); 55 | var y = ( 1 - b - k ) / ( 1 - k ); 56 | 57 | return { 58 | c: c, m: m, y: y, k: k 59 | }; 60 | 61 | } 62 | 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/VelocityNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.VelocityNode = function( target, params ) { 6 | 7 | THREE.Vector3Node.call( this ); 8 | 9 | this.requestUpdate = true; 10 | 11 | this.target = target; 12 | 13 | this.position = this.target.position.clone(); 14 | this.velocity = new THREE.Vector3(); 15 | this.moment = new THREE.Vector3(); 16 | 17 | this.params = params || {}; 18 | 19 | }; 20 | 21 | THREE.VelocityNode.prototype = Object.create( THREE.Vector3Node.prototype ); 22 | THREE.VelocityNode.prototype.constructor = THREE.VelocityNode; 23 | 24 | THREE.VelocityNode.prototype.updateFrame = function( delta ) { 25 | 26 | this.velocity.subVectors( this.target.position, this.position ); 27 | this.position.copy( this.target.position ); 28 | 29 | switch ( this.params.type ) { 30 | 31 | case "elastic": 32 | 33 | delta *= this.params.fps || 60; 34 | 35 | var spring = Math.pow( this.params.spring, delta ); 36 | var friction = Math.pow( this.params.friction, delta ); 37 | 38 | // spring 39 | this.moment.x += this.velocity.x * spring; 40 | this.moment.y += this.velocity.y * spring; 41 | this.moment.z += this.velocity.z * spring; 42 | 43 | // friction 44 | this.moment.x *= friction; 45 | this.moment.y *= friction; 46 | this.moment.z *= friction; 47 | 48 | this.value.copy( this.moment ); 49 | 50 | break; 51 | 52 | default: 53 | 54 | this.value.copy( this.velocity ); 55 | 56 | break; 57 | } 58 | 59 | }; 60 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/math/ColorConverter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author bhouston / http://exocortex.com/ 3 | * @author zz85 / http://github.com/zz85 4 | */ 5 | 6 | THREE.ColorConverter = { 7 | 8 | setHSV: function ( color, h, s, v ) { 9 | 10 | // https://gist.github.com/xpansive/1337890#file-index-js 11 | 12 | h = THREE.Math.euclideanModulo( h, 1 ); 13 | s = THREE.Math.clamp( s, 0, 1 ); 14 | v = THREE.Math.clamp( v, 0, 1 ); 15 | 16 | return color.setHSL( h, ( s * v ) / ( ( h = ( 2 - s ) * v ) < 1 ? h : ( 2 - h ) ), h * 0.5 ); 17 | 18 | }, 19 | 20 | getHSV: function( color ) { 21 | 22 | var hsl = color.getHSL(); 23 | 24 | // based on https://gist.github.com/xpansive/1337890#file-index-js 25 | hsl.s *= ( hsl.l < 0.5 ) ? hsl.l : ( 1 - hsl.l ); 26 | 27 | return { 28 | h: hsl.h, 29 | s: 2 * hsl.s / ( hsl.l + hsl.s ), 30 | v: hsl.l + hsl.s 31 | }; 32 | 33 | }, 34 | 35 | // where c, m, y, k is between 0 and 1 36 | 37 | setCMYK: function ( color, c, m, y, k ) { 38 | 39 | var r = ( 1 - c ) * ( 1 - k ); 40 | var g = ( 1 - m ) * ( 1 - k ); 41 | var b = ( 1 - y ) * ( 1 - k ); 42 | 43 | return color.setRGB( r, g, b ); 44 | 45 | }, 46 | 47 | getCMYK: function ( color ) { 48 | 49 | var r = color.r; 50 | var g = color.g; 51 | var b = color.b; 52 | var k = 1 - Math.max( r, g, b ); 53 | var c = ( 1 - r - k ) / ( 1 - k ); 54 | var m = ( 1 - g - k ) / ( 1 - k ); 55 | var y = ( 1 - b - k ) / ( 1 - k ); 56 | 57 | return { 58 | c: c, m: m, y: y, k: k 59 | }; 60 | 61 | } 62 | 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/VelocityNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.VelocityNode = function( target, params ) { 6 | 7 | THREE.Vector3Node.call( this ); 8 | 9 | this.requestUpdate = true; 10 | 11 | this.target = target; 12 | 13 | this.position = this.target.position.clone(); 14 | this.velocity = new THREE.Vector3(); 15 | this.moment = new THREE.Vector3(); 16 | 17 | this.params = params || {}; 18 | 19 | }; 20 | 21 | THREE.VelocityNode.prototype = Object.create( THREE.Vector3Node.prototype ); 22 | THREE.VelocityNode.prototype.constructor = THREE.VelocityNode; 23 | 24 | THREE.VelocityNode.prototype.updateFrame = function( delta ) { 25 | 26 | this.velocity.subVectors( this.target.position, this.position ); 27 | this.position.copy( this.target.position ); 28 | 29 | switch ( this.params.type ) { 30 | 31 | case "elastic": 32 | 33 | delta *= this.params.fps || 60; 34 | 35 | var spring = Math.pow( this.params.spring, delta ); 36 | var friction = Math.pow( this.params.friction, delta ); 37 | 38 | // spring 39 | this.moment.x += this.velocity.x * spring; 40 | this.moment.y += this.velocity.y * spring; 41 | this.moment.z += this.velocity.z * spring; 42 | 43 | // friction 44 | this.moment.x *= friction; 45 | this.moment.y *= friction; 46 | this.moment.z *= friction; 47 | 48 | this.value.copy( this.moment ); 49 | 50 | break; 51 | 52 | default: 53 | 54 | this.value.copy( this.velocity ); 55 | 56 | break; 57 | } 58 | 59 | }; 60 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/LuminosityHighPassShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author bhouston / http://clara.io/ 3 | * 4 | * Luminosity 5 | * http://en.wikipedia.org/wiki/Luminosity 6 | */ 7 | 8 | THREE.LuminosityHighPassShader = { 9 | 10 | shaderID: "luminosityHighPass", 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { type: "t", value: null }, 15 | "luminosityThreshold": { type: "f", value: 1.0 }, 16 | "smoothWidth": { type: "f", value: 1.0 }, 17 | "defaultColor": { type: "c", value: new THREE.Color( 0x000000 ) }, 18 | "defaultOpacity": { type: "f", value: 0.0 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | 30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 31 | 32 | "}" 33 | 34 | ].join("\n"), 35 | 36 | fragmentShader: [ 37 | 38 | "uniform sampler2D tDiffuse;", 39 | "uniform vec3 defaultColor;", 40 | "uniform float defaultOpacity;", 41 | "uniform float luminosityThreshold;", 42 | "uniform float smoothWidth;", 43 | 44 | "varying vec2 vUv;", 45 | 46 | "void main() {", 47 | 48 | "vec4 texel = texture2D( tDiffuse, vUv );", 49 | 50 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );", 51 | 52 | "float v = dot( texel.xyz, luma );", 53 | 54 | "vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );", 55 | 56 | "float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );", 57 | 58 | "gl_FragColor = mix( outputColor, texel, alpha );", 59 | 60 | "}" 61 | 62 | ].join("\n") 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/VignetteShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Vignette shader 5 | * based on PaintEffect postprocess from ro.me 6 | * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js 7 | */ 8 | 9 | THREE.VignetteShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { value: null }, 14 | "offset": { value: 1.0 }, 15 | "darkness": { value: 1.0 } 16 | 17 | }, 18 | 19 | vertexShader: [ 20 | 21 | "varying vec2 vUv;", 22 | 23 | "void main() {", 24 | 25 | "vUv = uv;", 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join( "\n" ), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform float offset;", 35 | "uniform float darkness;", 36 | 37 | "uniform sampler2D tDiffuse;", 38 | 39 | "varying vec2 vUv;", 40 | 41 | "void main() {", 42 | 43 | // Eskil's vignette 44 | 45 | "vec4 texel = texture2D( tDiffuse, vUv );", 46 | "vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );", 47 | "gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );", 48 | 49 | /* 50 | // alternative version from glfx.js 51 | // this one makes more "dusty" look (as opposed to "burned") 52 | 53 | "vec4 color = texture2D( tDiffuse, vUv );", 54 | "float dist = distance( vUv, vec2( 0.5 ) );", 55 | "color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );", 56 | "gl_FragColor = color;", 57 | */ 58 | 59 | "}" 60 | 61 | ].join( "\n" ) 62 | 63 | }; 64 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/LuminosityHighPassShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author bhouston / http://clara.io/ 3 | * 4 | * Luminosity 5 | * http://en.wikipedia.org/wiki/Luminosity 6 | */ 7 | 8 | THREE.LuminosityHighPassShader = { 9 | 10 | shaderID: "luminosityHighPass", 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { type: "t", value: null }, 15 | "luminosityThreshold": { type: "f", value: 1.0 }, 16 | "smoothWidth": { type: "f", value: 1.0 }, 17 | "defaultColor": { type: "c", value: new THREE.Color( 0x000000 ) }, 18 | "defaultOpacity": { type: "f", value: 0.0 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | 30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 31 | 32 | "}" 33 | 34 | ].join("\n"), 35 | 36 | fragmentShader: [ 37 | 38 | "uniform sampler2D tDiffuse;", 39 | "uniform vec3 defaultColor;", 40 | "uniform float defaultOpacity;", 41 | "uniform float luminosityThreshold;", 42 | "uniform float smoothWidth;", 43 | 44 | "varying vec2 vUv;", 45 | 46 | "void main() {", 47 | 48 | "vec4 texel = texture2D( tDiffuse, vUv );", 49 | 50 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );", 51 | 52 | "float v = dot( texel.xyz, luma );", 53 | 54 | "vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );", 55 | 56 | "float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );", 57 | 58 | "gl_FragColor = mix( outputColor, texel, alpha );", 59 | 60 | "}" 61 | 62 | ].join("\n") 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/VignetteShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Vignette shader 5 | * based on PaintEffect postprocess from ro.me 6 | * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js 7 | */ 8 | 9 | THREE.VignetteShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { value: null }, 14 | "offset": { value: 1.0 }, 15 | "darkness": { value: 1.0 } 16 | 17 | }, 18 | 19 | vertexShader: [ 20 | 21 | "varying vec2 vUv;", 22 | 23 | "void main() {", 24 | 25 | "vUv = uv;", 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join( "\n" ), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform float offset;", 35 | "uniform float darkness;", 36 | 37 | "uniform sampler2D tDiffuse;", 38 | 39 | "varying vec2 vUv;", 40 | 41 | "void main() {", 42 | 43 | // Eskil's vignette 44 | 45 | "vec4 texel = texture2D( tDiffuse, vUv );", 46 | "vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );", 47 | "gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );", 48 | 49 | /* 50 | // alternative version from glfx.js 51 | // this one makes more "dusty" look (as opposed to "burned") 52 | 53 | "vec4 color = texture2D( tDiffuse, vUv );", 54 | "float dist = distance( vUv, vec2( 0.5 ) );", 55 | "color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );", 56 | "gl_FragColor = color;", 57 | */ 58 | 59 | "}" 60 | 61 | ].join( "\n" ) 62 | 63 | }; 64 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/accessors/NormalNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.NormalNode = function( scope ) { 6 | 7 | THREE.TempNode.call( this, 'v3' ); 8 | 9 | this.scope = scope || THREE.NormalNode.LOCAL; 10 | 11 | }; 12 | 13 | THREE.NormalNode.LOCAL = 'local'; 14 | THREE.NormalNode.WORLD = 'world'; 15 | THREE.NormalNode.VIEW = 'view'; 16 | 17 | THREE.NormalNode.prototype = Object.create( THREE.TempNode.prototype ); 18 | THREE.NormalNode.prototype.constructor = THREE.NormalNode; 19 | 20 | THREE.NormalNode.prototype.isShared = function( builder ) { 21 | 22 | switch ( this.scope ) { 23 | case THREE.NormalNode.WORLD: 24 | return true; 25 | } 26 | 27 | return false; 28 | 29 | }; 30 | 31 | THREE.NormalNode.prototype.generate = function( builder, output ) { 32 | 33 | var material = builder.material; 34 | var result; 35 | 36 | switch ( this.scope ) { 37 | 38 | case THREE.NormalNode.LOCAL: 39 | 40 | material.requestAttribs.normal = true; 41 | 42 | if ( builder.isShader( 'vertex' ) ) result = 'normal'; 43 | else result = 'vObjectNormal'; 44 | 45 | break; 46 | 47 | case THREE.NormalNode.WORLD: 48 | 49 | material.requestAttribs.worldNormal = true; 50 | 51 | if ( builder.isShader( 'vertex' ) ) result = '( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz'; 52 | else result = 'vWNormal'; 53 | 54 | break; 55 | 56 | case THREE.NormalNode.VIEW: 57 | 58 | result = 'vNormal'; 59 | 60 | break; 61 | 62 | } 63 | 64 | return builder.format( result, this.getType( builder ), output ); 65 | 66 | }; 67 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/accessors/NormalNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.NormalNode = function( scope ) { 6 | 7 | THREE.TempNode.call( this, 'v3' ); 8 | 9 | this.scope = scope || THREE.NormalNode.LOCAL; 10 | 11 | }; 12 | 13 | THREE.NormalNode.LOCAL = 'local'; 14 | THREE.NormalNode.WORLD = 'world'; 15 | THREE.NormalNode.VIEW = 'view'; 16 | 17 | THREE.NormalNode.prototype = Object.create( THREE.TempNode.prototype ); 18 | THREE.NormalNode.prototype.constructor = THREE.NormalNode; 19 | 20 | THREE.NormalNode.prototype.isShared = function( builder ) { 21 | 22 | switch ( this.scope ) { 23 | case THREE.NormalNode.WORLD: 24 | return true; 25 | } 26 | 27 | return false; 28 | 29 | }; 30 | 31 | THREE.NormalNode.prototype.generate = function( builder, output ) { 32 | 33 | var material = builder.material; 34 | var result; 35 | 36 | switch ( this.scope ) { 37 | 38 | case THREE.NormalNode.LOCAL: 39 | 40 | material.requestAttribs.normal = true; 41 | 42 | if ( builder.isShader( 'vertex' ) ) result = 'normal'; 43 | else result = 'vObjectNormal'; 44 | 45 | break; 46 | 47 | case THREE.NormalNode.WORLD: 48 | 49 | material.requestAttribs.worldNormal = true; 50 | 51 | if ( builder.isShader( 'vertex' ) ) result = '( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz'; 52 | else result = 'vWNormal'; 53 | 54 | break; 55 | 56 | case THREE.NormalNode.VIEW: 57 | 58 | result = 'vNormal'; 59 | 60 | break; 61 | 62 | } 63 | 64 | return builder.format( result, this.getType( builder ), output ); 65 | 66 | }; 67 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/BleachBypassShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass] 5 | * - based on Nvidia example 6 | * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass 7 | */ 8 | 9 | THREE.BleachBypassShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { value: null }, 14 | "opacity": { value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform float opacity;", 34 | 35 | "uniform sampler2D tDiffuse;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "vec4 base = texture2D( tDiffuse, vUv );", 42 | 43 | "vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );", 44 | "float lum = dot( lumCoeff, base.rgb );", 45 | "vec3 blend = vec3( lum );", 46 | 47 | "float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );", 48 | 49 | "vec3 result1 = 2.0 * base.rgb * blend;", 50 | "vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );", 51 | 52 | "vec3 newColor = mix( result1, result2, L );", 53 | 54 | "float A2 = opacity * base.a;", 55 | "vec3 mixRGB = A2 * newColor.rgb;", 56 | "mixRGB += ( ( 1.0 - A2 ) * base.rgb );", 57 | 58 | "gl_FragColor = vec4( mixRGB, base.a );", 59 | 60 | "}" 61 | 62 | ].join( "\n" ) 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/DotScreenShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Dot screen shader 5 | * based on glfx.js sepia shader 6 | * https://github.com/evanw/glfx.js 7 | */ 8 | 9 | THREE.DotScreenShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { value: null }, 14 | "tSize": { value: new THREE.Vector2( 256, 256 ) }, 15 | "center": { value: new THREE.Vector2( 0.5, 0.5 ) }, 16 | "angle": { value: 1.57 }, 17 | "scale": { value: 1.0 } 18 | 19 | }, 20 | 21 | vertexShader: [ 22 | 23 | "varying vec2 vUv;", 24 | 25 | "void main() {", 26 | 27 | "vUv = uv;", 28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 29 | 30 | "}" 31 | 32 | ].join( "\n" ), 33 | 34 | fragmentShader: [ 35 | 36 | "uniform vec2 center;", 37 | "uniform float angle;", 38 | "uniform float scale;", 39 | "uniform vec2 tSize;", 40 | 41 | "uniform sampler2D tDiffuse;", 42 | 43 | "varying vec2 vUv;", 44 | 45 | "float pattern() {", 46 | 47 | "float s = sin( angle ), c = cos( angle );", 48 | 49 | "vec2 tex = vUv * tSize - center;", 50 | "vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;", 51 | 52 | "return ( sin( point.x ) * sin( point.y ) ) * 4.0;", 53 | 54 | "}", 55 | 56 | "void main() {", 57 | 58 | "vec4 color = texture2D( tDiffuse, vUv );", 59 | 60 | "float average = ( color.r + color.g + color.b ) / 3.0;", 61 | 62 | "gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );", 63 | 64 | "}" 65 | 66 | ].join( "\n" ) 67 | 68 | }; 69 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/BleachBypassShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass] 5 | * - based on Nvidia example 6 | * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass 7 | */ 8 | 9 | THREE.BleachBypassShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { value: null }, 14 | "opacity": { value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join( "\n" ), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform float opacity;", 34 | 35 | "uniform sampler2D tDiffuse;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "vec4 base = texture2D( tDiffuse, vUv );", 42 | 43 | "vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );", 44 | "float lum = dot( lumCoeff, base.rgb );", 45 | "vec3 blend = vec3( lum );", 46 | 47 | "float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );", 48 | 49 | "vec3 result1 = 2.0 * base.rgb * blend;", 50 | "vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );", 51 | 52 | "vec3 newColor = mix( result1, result2, L );", 53 | 54 | "float A2 = opacity * base.a;", 55 | "vec3 mixRGB = A2 * newColor.rgb;", 56 | "mixRGB += ( ( 1.0 - A2 ) * base.rgb );", 57 | 58 | "gl_FragColor = vec4( mixRGB, base.a );", 59 | 60 | "}" 61 | 62 | ].join( "\n" ) 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/DotScreenShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Dot screen shader 5 | * based on glfx.js sepia shader 6 | * https://github.com/evanw/glfx.js 7 | */ 8 | 9 | THREE.DotScreenShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { value: null }, 14 | "tSize": { value: new THREE.Vector2( 256, 256 ) }, 15 | "center": { value: new THREE.Vector2( 0.5, 0.5 ) }, 16 | "angle": { value: 1.57 }, 17 | "scale": { value: 1.0 } 18 | 19 | }, 20 | 21 | vertexShader: [ 22 | 23 | "varying vec2 vUv;", 24 | 25 | "void main() {", 26 | 27 | "vUv = uv;", 28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 29 | 30 | "}" 31 | 32 | ].join( "\n" ), 33 | 34 | fragmentShader: [ 35 | 36 | "uniform vec2 center;", 37 | "uniform float angle;", 38 | "uniform float scale;", 39 | "uniform vec2 tSize;", 40 | 41 | "uniform sampler2D tDiffuse;", 42 | 43 | "varying vec2 vUv;", 44 | 45 | "float pattern() {", 46 | 47 | "float s = sin( angle ), c = cos( angle );", 48 | 49 | "vec2 tex = vUv * tSize - center;", 50 | "vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;", 51 | 52 | "return ( sin( point.x ) * sin( point.y ) ) * 4.0;", 53 | 54 | "}", 55 | 56 | "void main() {", 57 | 58 | "vec4 color = texture2D( tDiffuse, vUv );", 59 | 60 | "float average = ( color.r + color.g + color.b ) / 3.0;", 61 | 62 | "gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );", 63 | 64 | "}" 65 | 66 | ].join( "\n" ) 67 | 68 | }; 69 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/JoinNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.JoinNode = function( x, y, z, w ) { 6 | 7 | THREE.TempNode.call( this, 'fv1' ); 8 | 9 | this.x = x; 10 | this.y = y; 11 | this.z = z; 12 | this.w = w; 13 | 14 | }; 15 | 16 | THREE.JoinNode.inputs = [ 'x', 'y', 'z', 'w' ]; 17 | 18 | THREE.JoinNode.prototype = Object.create( THREE.TempNode.prototype ); 19 | THREE.JoinNode.prototype.constructor = THREE.JoinNode; 20 | 21 | THREE.JoinNode.prototype.getNumElements = function() { 22 | 23 | var inputs = THREE.JoinNode.inputs; 24 | var i = inputs.length; 25 | 26 | while ( i -- ) { 27 | 28 | if ( this[ inputs[ i ] ] !== undefined ) { 29 | 30 | ++ i; 31 | break; 32 | 33 | } 34 | 35 | } 36 | 37 | return Math.max( i, 2 ); 38 | 39 | }; 40 | 41 | THREE.JoinNode.prototype.getType = function( builder ) { 42 | 43 | return builder.getFormatFromLength( this.getNumElements() ); 44 | 45 | }; 46 | 47 | THREE.JoinNode.prototype.generate = function( builder, output ) { 48 | 49 | var material = builder.material; 50 | 51 | var type = this.getType( builder ); 52 | var length = this.getNumElements(); 53 | 54 | var inputs = THREE.JoinNode.inputs; 55 | var outputs = []; 56 | 57 | for ( var i = 0; i < length; i ++ ) { 58 | 59 | var elm = this[ inputs[ i ] ]; 60 | 61 | outputs.push( elm ? elm.build( builder, 'fv1' ) : '0.' ); 62 | 63 | } 64 | 65 | var code = ( length > 1 ? builder.getConstructorFromLength( length ) : '' ) + '(' + outputs.join( ',' ) + ')'; 66 | 67 | return builder.format( code, type, output ); 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/JoinNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.JoinNode = function( x, y, z, w ) { 6 | 7 | THREE.TempNode.call( this, 'fv1' ); 8 | 9 | this.x = x; 10 | this.y = y; 11 | this.z = z; 12 | this.w = w; 13 | 14 | }; 15 | 16 | THREE.JoinNode.inputs = [ 'x', 'y', 'z', 'w' ]; 17 | 18 | THREE.JoinNode.prototype = Object.create( THREE.TempNode.prototype ); 19 | THREE.JoinNode.prototype.constructor = THREE.JoinNode; 20 | 21 | THREE.JoinNode.prototype.getNumElements = function() { 22 | 23 | var inputs = THREE.JoinNode.inputs; 24 | var i = inputs.length; 25 | 26 | while ( i -- ) { 27 | 28 | if ( this[ inputs[ i ] ] !== undefined ) { 29 | 30 | ++ i; 31 | break; 32 | 33 | } 34 | 35 | } 36 | 37 | return Math.max( i, 2 ); 38 | 39 | }; 40 | 41 | THREE.JoinNode.prototype.getType = function( builder ) { 42 | 43 | return builder.getFormatFromLength( this.getNumElements() ); 44 | 45 | }; 46 | 47 | THREE.JoinNode.prototype.generate = function( builder, output ) { 48 | 49 | var material = builder.material; 50 | 51 | var type = this.getType( builder ); 52 | var length = this.getNumElements(); 53 | 54 | var inputs = THREE.JoinNode.inputs; 55 | var outputs = []; 56 | 57 | for ( var i = 0; i < length; i ++ ) { 58 | 59 | var elm = this[ inputs[ i ] ]; 60 | 61 | outputs.push( elm ? elm.build( builder, 'fv1' ) : '0.' ); 62 | 63 | } 64 | 65 | var code = ( length > 1 ? builder.getConstructorFromLength( length ) : '' ) + '(' + outputs.join( ',' ) + ')'; 66 | 67 | return builder.format( code, type, output ); 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/MirrorNode.js: -------------------------------------------------------------------------------- 1 | THREE.MirrorNode = function( renderer, camera, options ) { 2 | 3 | THREE.TempNode.call( this, 'v4' ); 4 | 5 | this.mirror = renderer instanceof THREE.Mirror ? renderer : new THREE.Mirror( renderer, camera, options ); 6 | 7 | this.textureMatrix = new THREE.Matrix4Node( this.mirror.textureMatrix ); 8 | 9 | this.worldPosition = new THREE.PositionNode( THREE.PositionNode.WORLD ); 10 | 11 | this.coord = new THREE.OperatorNode( this.textureMatrix, this.worldPosition, THREE.OperatorNode.MUL ); 12 | this.coordResult = new THREE.OperatorNode( null, this.coord, THREE.OperatorNode.ADD ); 13 | 14 | this.texture = new THREE.TextureNode( this.mirror.renderTarget.texture, this.coord, null, true ); 15 | 16 | }; 17 | 18 | THREE.MirrorNode.prototype = Object.create( THREE.TempNode.prototype ); 19 | THREE.MirrorNode.prototype.constructor = THREE.MirrorNode; 20 | 21 | THREE.MirrorNode.prototype.generate = function( builder, output ) { 22 | 23 | var material = builder.material; 24 | 25 | if ( builder.isShader( 'fragment' ) ) { 26 | 27 | this.coordResult.a = this.offset; 28 | this.texture.coord = this.offset ? this.coordResult : this.coord; 29 | 30 | if ( output === 'sampler2D' ) { 31 | 32 | return this.texture.build( builder, output ); 33 | 34 | } 35 | 36 | return builder.format( this.texture.build( builder, this.type ), this.type, output ); 37 | 38 | } else { 39 | 40 | console.warn( "THREE.MirrorNode is not compatible with " + builder.shader + " shader." ); 41 | 42 | return builder.format( 'vec4(0.0)', this.type, output ); 43 | 44 | } 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/MirrorNode.js: -------------------------------------------------------------------------------- 1 | THREE.MirrorNode = function( renderer, camera, options ) { 2 | 3 | THREE.TempNode.call( this, 'v4' ); 4 | 5 | this.mirror = renderer instanceof THREE.Mirror ? renderer : new THREE.Mirror( renderer, camera, options ); 6 | 7 | this.textureMatrix = new THREE.Matrix4Node( this.mirror.textureMatrix ); 8 | 9 | this.worldPosition = new THREE.PositionNode( THREE.PositionNode.WORLD ); 10 | 11 | this.coord = new THREE.OperatorNode( this.textureMatrix, this.worldPosition, THREE.OperatorNode.MUL ); 12 | this.coordResult = new THREE.OperatorNode( null, this.coord, THREE.OperatorNode.ADD ); 13 | 14 | this.texture = new THREE.TextureNode( this.mirror.renderTarget.texture, this.coord, null, true ); 15 | 16 | }; 17 | 18 | THREE.MirrorNode.prototype = Object.create( THREE.TempNode.prototype ); 19 | THREE.MirrorNode.prototype.constructor = THREE.MirrorNode; 20 | 21 | THREE.MirrorNode.prototype.generate = function( builder, output ) { 22 | 23 | var material = builder.material; 24 | 25 | if ( builder.isShader( 'fragment' ) ) { 26 | 27 | this.coordResult.a = this.offset; 28 | this.texture.coord = this.offset ? this.coordResult : this.coord; 29 | 30 | if ( output === 'sampler2D' ) { 31 | 32 | return this.texture.build( builder, output ); 33 | 34 | } 35 | 36 | return builder.format( this.texture.build( builder, this.type ), this.type, output ); 37 | 38 | } else { 39 | 40 | console.warn( "THREE.MirrorNode is not compatible with " + builder.shader + " shader." ); 41 | 42 | return builder.format( 'vec4(0.0)', this.type, output ); 43 | 44 | } 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/postprocessing/RenderPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.scene = scene; 10 | this.camera = camera; 11 | 12 | this.overrideMaterial = overrideMaterial; 13 | 14 | this.clearColor = clearColor; 15 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; 16 | 17 | this.clear = true; 18 | this.clearDepth = false; 19 | this.needsSwap = false; 20 | 21 | }; 22 | 23 | THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 24 | 25 | constructor: THREE.RenderPass, 26 | 27 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 28 | 29 | var oldAutoClear = renderer.autoClear; 30 | renderer.autoClear = false; 31 | 32 | this.scene.overrideMaterial = this.overrideMaterial; 33 | 34 | var oldClearColor, oldClearAlpha; 35 | 36 | if ( this.clearColor ) { 37 | 38 | oldClearColor = renderer.getClearColor().getHex(); 39 | oldClearAlpha = renderer.getClearAlpha(); 40 | 41 | renderer.setClearColor( this.clearColor, this.clearAlpha ); 42 | 43 | } 44 | 45 | if ( this.clearDepth ) { 46 | 47 | renderer.clearDepth(); 48 | 49 | } 50 | 51 | renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear ); 52 | 53 | if ( this.clearColor ) { 54 | 55 | renderer.setClearColor( oldClearColor, oldClearAlpha ); 56 | 57 | } 58 | 59 | this.scene.overrideMaterial = null; 60 | renderer.autoClear = oldAutoClear; 61 | } 62 | 63 | } ); 64 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/postprocessing/RenderPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.scene = scene; 10 | this.camera = camera; 11 | 12 | this.overrideMaterial = overrideMaterial; 13 | 14 | this.clearColor = clearColor; 15 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; 16 | 17 | this.clear = true; 18 | this.clearDepth = false; 19 | this.needsSwap = false; 20 | 21 | }; 22 | 23 | THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 24 | 25 | constructor: THREE.RenderPass, 26 | 27 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 28 | 29 | var oldAutoClear = renderer.autoClear; 30 | renderer.autoClear = false; 31 | 32 | this.scene.overrideMaterial = this.overrideMaterial; 33 | 34 | var oldClearColor, oldClearAlpha; 35 | 36 | if ( this.clearColor ) { 37 | 38 | oldClearColor = renderer.getClearColor().getHex(); 39 | oldClearAlpha = renderer.getClearAlpha(); 40 | 41 | renderer.setClearColor( this.clearColor, this.clearAlpha ); 42 | 43 | } 44 | 45 | if ( this.clearDepth ) { 46 | 47 | renderer.clearDepth(); 48 | 49 | } 50 | 51 | renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear ); 52 | 53 | if ( this.clearColor ) { 54 | 55 | renderer.setClearColor( oldClearColor, oldClearAlpha ); 56 | 57 | } 58 | 59 | this.scene.overrideMaterial = null; 60 | renderer.autoClear = oldAutoClear; 61 | } 62 | 63 | } ); 64 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/curves/NURBSSurface.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author renej 3 | * NURBS surface object 4 | * 5 | * Implementation is based on (x, y [, z=0 [, w=1]]) control points with w=weight. 6 | * 7 | **/ 8 | 9 | 10 | /************************************************************** 11 | * NURBS surface 12 | **************************************************************/ 13 | 14 | THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of reals */, controlPoints /* array^2 of Vector(2|3|4) */ ) { 15 | 16 | this.degree1 = degree1; 17 | this.degree2 = degree2; 18 | this.knots1 = knots1; 19 | this.knots2 = knots2; 20 | this.controlPoints = []; 21 | 22 | var len1 = knots1.length - degree1 - 1; 23 | var len2 = knots2.length - degree2 - 1; 24 | 25 | // ensure Vector4 for control points 26 | for ( var i = 0; i < len1; ++ i ) { 27 | 28 | this.controlPoints[ i ] = []; 29 | for ( var j = 0; j < len2; ++ j ) { 30 | 31 | var point = controlPoints[ i ][ j ]; 32 | this.controlPoints[ i ][ j ] = new THREE.Vector4( point.x, point.y, point.z, point.w ); 33 | 34 | } 35 | 36 | } 37 | 38 | }; 39 | 40 | 41 | THREE.NURBSSurface.prototype = { 42 | 43 | constructor: THREE.NURBSSurface, 44 | 45 | getPoint: function ( t1, t2 ) { 46 | 47 | var u = this.knots1[ 0 ] + t1 * ( this.knots1[ this.knots1.length - 1 ] - this.knots1[ 0 ] ); // linear mapping t1->u 48 | var v = this.knots2[ 0 ] + t2 * ( this.knots2[ this.knots2.length - 1 ] - this.knots2[ 0 ] ); // linear mapping t2->u 49 | 50 | return THREE.NURBSUtils.calcSurfacePoint( this.degree1, this.degree2, this.knots1, this.knots2, this.controlPoints, u, v ); 51 | 52 | } 53 | }; 54 | 55 | 56 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/curves/NURBSSurface.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author renej 3 | * NURBS surface object 4 | * 5 | * Implementation is based on (x, y [, z=0 [, w=1]]) control points with w=weight. 6 | * 7 | **/ 8 | 9 | 10 | /************************************************************** 11 | * NURBS surface 12 | **************************************************************/ 13 | 14 | THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of reals */, controlPoints /* array^2 of Vector(2|3|4) */ ) { 15 | 16 | this.degree1 = degree1; 17 | this.degree2 = degree2; 18 | this.knots1 = knots1; 19 | this.knots2 = knots2; 20 | this.controlPoints = []; 21 | 22 | var len1 = knots1.length - degree1 - 1; 23 | var len2 = knots2.length - degree2 - 1; 24 | 25 | // ensure Vector4 for control points 26 | for ( var i = 0; i < len1; ++ i ) { 27 | 28 | this.controlPoints[ i ] = []; 29 | for ( var j = 0; j < len2; ++ j ) { 30 | 31 | var point = controlPoints[ i ][ j ]; 32 | this.controlPoints[ i ][ j ] = new THREE.Vector4( point.x, point.y, point.z, point.w ); 33 | 34 | } 35 | 36 | } 37 | 38 | }; 39 | 40 | 41 | THREE.NURBSSurface.prototype = { 42 | 43 | constructor: THREE.NURBSSurface, 44 | 45 | getPoint: function ( t1, t2 ) { 46 | 47 | var u = this.knots1[ 0 ] + t1 * ( this.knots1[ this.knots1.length - 1 ] - this.knots1[ 0 ] ); // linear mapping t1->u 48 | var v = this.knots2[ 0 ] + t2 * ( this.knots2[ this.knots2.length - 1 ] - this.knots2[ 0 ] ); // linear mapping t2->u 49 | 50 | return THREE.NURBSUtils.calcSurfacePoint( this.degree1, this.degree2, this.knots1, this.knots2, this.controlPoints, u, v ); 51 | 52 | } 53 | }; 54 | 55 | 56 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/MorphAnimation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com 3 | * @author willy-vvu / http://willy-vvu.github.io 4 | */ 5 | 6 | THREE.MorphAnimation = function ( mesh ) { 7 | 8 | this.mesh = mesh; 9 | this.frames = mesh.morphTargetInfluences.length; 10 | this.currentTime = 0; 11 | this.duration = 1000; 12 | this.loop = true; 13 | this.lastFrame = 0; 14 | this.currentFrame = 0; 15 | 16 | this.isPlaying = false; 17 | 18 | }; 19 | 20 | THREE.MorphAnimation.prototype = { 21 | 22 | constructor: THREE.MorphAnimation, 23 | 24 | play: function () { 25 | 26 | this.isPlaying = true; 27 | 28 | }, 29 | 30 | pause: function () { 31 | 32 | this.isPlaying = false; 33 | 34 | }, 35 | 36 | update: function ( delta ) { 37 | 38 | if ( this.isPlaying === false ) return; 39 | 40 | this.currentTime += delta; 41 | 42 | if ( this.loop === true && this.currentTime > this.duration ) { 43 | 44 | this.currentTime %= this.duration; 45 | 46 | } 47 | 48 | this.currentTime = Math.min( this.currentTime, this.duration ); 49 | 50 | var frameTime = this.duration / this.frames; 51 | var frame = Math.floor( this.currentTime / frameTime ); 52 | 53 | var influences = this.mesh.morphTargetInfluences; 54 | 55 | if ( frame !== this.currentFrame ) { 56 | 57 | influences[ this.lastFrame ] = 0; 58 | influences[ this.currentFrame ] = 1; 59 | influences[ frame ] = 0; 60 | 61 | this.lastFrame = this.currentFrame; 62 | this.currentFrame = frame; 63 | 64 | } 65 | 66 | var mix = ( this.currentTime % frameTime ) / frameTime; 67 | 68 | influences[ frame ] = mix; 69 | influences[ this.lastFrame ] = 1 - mix; 70 | 71 | } 72 | 73 | }; 74 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/postprocessing/ShaderPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.ShaderPass = function ( shader, textureID ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse"; 10 | 11 | if ( shader instanceof THREE.ShaderMaterial ) { 12 | 13 | this.uniforms = shader.uniforms; 14 | 15 | this.material = shader; 16 | 17 | } else if ( shader ) { 18 | 19 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 20 | 21 | this.material = new THREE.ShaderMaterial( { 22 | 23 | defines: shader.defines || {}, 24 | uniforms: this.uniforms, 25 | vertexShader: shader.vertexShader, 26 | fragmentShader: shader.fragmentShader 27 | 28 | } ); 29 | 30 | } 31 | 32 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 33 | this.scene = new THREE.Scene(); 34 | 35 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 36 | this.scene.add( this.quad ); 37 | 38 | }; 39 | 40 | THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 41 | 42 | constructor: THREE.ShaderPass, 43 | 44 | render: function( renderer, writeBuffer, readBuffer, delta, maskActive ) { 45 | 46 | if ( this.uniforms[ this.textureID ] ) { 47 | 48 | this.uniforms[ this.textureID ].value = readBuffer.texture; 49 | 50 | } 51 | 52 | this.quad.material = this.material; 53 | 54 | if ( this.renderToScreen ) { 55 | 56 | renderer.render( this.scene, this.camera ); 57 | 58 | } else { 59 | 60 | renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 61 | 62 | } 63 | 64 | } 65 | 66 | } ); 67 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/TriangleBlurShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Triangle blur shader 5 | * based on glfx.js triangle blur shader 6 | * https://github.com/evanw/glfx.js 7 | * 8 | * A basic blur filter, which convolves the image with a 9 | * pyramid filter. The pyramid filter is separable and is applied as two 10 | * perpendicular triangle filters. 11 | */ 12 | 13 | THREE.TriangleBlurShader = { 14 | 15 | uniforms : { 16 | 17 | "texture": { value: null }, 18 | "delta": { value: new THREE.Vector2( 1, 1 ) } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join( "\n" ), 34 | 35 | fragmentShader: [ 36 | 37 | "#include ", 38 | 39 | "#define ITERATIONS 10.0", 40 | 41 | "uniform sampler2D texture;", 42 | "uniform vec2 delta;", 43 | 44 | "varying vec2 vUv;", 45 | 46 | "void main() {", 47 | 48 | "vec4 color = vec4( 0.0 );", 49 | 50 | "float total = 0.0;", 51 | 52 | // randomize the lookup values to hide the fixed number of samples 53 | 54 | "float offset = rand( vUv );", 55 | 56 | "for ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {", 57 | 58 | "float percent = ( t + offset - 0.5 ) / ITERATIONS;", 59 | "float weight = 1.0 - abs( percent );", 60 | 61 | "color += texture2D( texture, vUv + delta * percent ) * weight;", 62 | "total += weight;", 63 | 64 | "}", 65 | 66 | "gl_FragColor = color / total;", 67 | 68 | "}" 69 | 70 | ].join( "\n" ) 71 | 72 | }; 73 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/MorphAnimation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com 3 | * @author willy-vvu / http://willy-vvu.github.io 4 | */ 5 | 6 | THREE.MorphAnimation = function ( mesh ) { 7 | 8 | this.mesh = mesh; 9 | this.frames = mesh.morphTargetInfluences.length; 10 | this.currentTime = 0; 11 | this.duration = 1000; 12 | this.loop = true; 13 | this.lastFrame = 0; 14 | this.currentFrame = 0; 15 | 16 | this.isPlaying = false; 17 | 18 | }; 19 | 20 | THREE.MorphAnimation.prototype = { 21 | 22 | constructor: THREE.MorphAnimation, 23 | 24 | play: function () { 25 | 26 | this.isPlaying = true; 27 | 28 | }, 29 | 30 | pause: function () { 31 | 32 | this.isPlaying = false; 33 | 34 | }, 35 | 36 | update: function ( delta ) { 37 | 38 | if ( this.isPlaying === false ) return; 39 | 40 | this.currentTime += delta; 41 | 42 | if ( this.loop === true && this.currentTime > this.duration ) { 43 | 44 | this.currentTime %= this.duration; 45 | 46 | } 47 | 48 | this.currentTime = Math.min( this.currentTime, this.duration ); 49 | 50 | var frameTime = this.duration / this.frames; 51 | var frame = Math.floor( this.currentTime / frameTime ); 52 | 53 | var influences = this.mesh.morphTargetInfluences; 54 | 55 | if ( frame !== this.currentFrame ) { 56 | 57 | influences[ this.lastFrame ] = 0; 58 | influences[ this.currentFrame ] = 1; 59 | influences[ frame ] = 0; 60 | 61 | this.lastFrame = this.currentFrame; 62 | this.currentFrame = frame; 63 | 64 | } 65 | 66 | var mix = ( this.currentTime % frameTime ) / frameTime; 67 | 68 | influences[ frame ] = mix; 69 | influences[ this.lastFrame ] = 1 - mix; 70 | 71 | } 72 | 73 | }; 74 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/postprocessing/ShaderPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.ShaderPass = function ( shader, textureID ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse"; 10 | 11 | if ( shader instanceof THREE.ShaderMaterial ) { 12 | 13 | this.uniforms = shader.uniforms; 14 | 15 | this.material = shader; 16 | 17 | } else if ( shader ) { 18 | 19 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 20 | 21 | this.material = new THREE.ShaderMaterial( { 22 | 23 | defines: shader.defines || {}, 24 | uniforms: this.uniforms, 25 | vertexShader: shader.vertexShader, 26 | fragmentShader: shader.fragmentShader 27 | 28 | } ); 29 | 30 | } 31 | 32 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 33 | this.scene = new THREE.Scene(); 34 | 35 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 36 | this.scene.add( this.quad ); 37 | 38 | }; 39 | 40 | THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 41 | 42 | constructor: THREE.ShaderPass, 43 | 44 | render: function( renderer, writeBuffer, readBuffer, delta, maskActive ) { 45 | 46 | if ( this.uniforms[ this.textureID ] ) { 47 | 48 | this.uniforms[ this.textureID ].value = readBuffer.texture; 49 | 50 | } 51 | 52 | this.quad.material = this.material; 53 | 54 | if ( this.renderToScreen ) { 55 | 56 | renderer.render( this.scene, this.camera ); 57 | 58 | } else { 59 | 60 | renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 61 | 62 | } 63 | 64 | } 65 | 66 | } ); 67 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/TriangleBlurShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Triangle blur shader 5 | * based on glfx.js triangle blur shader 6 | * https://github.com/evanw/glfx.js 7 | * 8 | * A basic blur filter, which convolves the image with a 9 | * pyramid filter. The pyramid filter is separable and is applied as two 10 | * perpendicular triangle filters. 11 | */ 12 | 13 | THREE.TriangleBlurShader = { 14 | 15 | uniforms : { 16 | 17 | "texture": { value: null }, 18 | "delta": { value: new THREE.Vector2( 1, 1 ) } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join( "\n" ), 34 | 35 | fragmentShader: [ 36 | 37 | "#include ", 38 | 39 | "#define ITERATIONS 10.0", 40 | 41 | "uniform sampler2D texture;", 42 | "uniform vec2 delta;", 43 | 44 | "varying vec2 vUv;", 45 | 46 | "void main() {", 47 | 48 | "vec4 color = vec4( 0.0 );", 49 | 50 | "float total = 0.0;", 51 | 52 | // randomize the lookup values to hide the fixed number of samples 53 | 54 | "float offset = rand( vUv );", 55 | 56 | "for ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {", 57 | 58 | "float percent = ( t + offset - 0.5 ) / ITERATIONS;", 59 | "float weight = 1.0 - abs( percent );", 60 | 61 | "color += texture2D( texture, vUv + delta * percent ) * weight;", 62 | "total += weight;", 63 | 64 | "}", 65 | 66 | "gl_FragColor = color / total;", 67 | 68 | "}" 69 | 70 | ].join( "\n" ) 71 | 72 | }; 73 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/Gyroscope.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.Gyroscope = function () { 6 | 7 | THREE.Object3D.call( this ); 8 | 9 | }; 10 | 11 | THREE.Gyroscope.prototype = Object.create( THREE.Object3D.prototype ); 12 | THREE.Gyroscope.prototype.constructor = THREE.Gyroscope; 13 | 14 | THREE.Gyroscope.prototype.updateMatrixWorld = ( function () { 15 | 16 | var translationObject = new THREE.Vector3(); 17 | var quaternionObject = new THREE.Quaternion(); 18 | var scaleObject = new THREE.Vector3(); 19 | 20 | var translationWorld = new THREE.Vector3(); 21 | var quaternionWorld = new THREE.Quaternion(); 22 | var scaleWorld = new THREE.Vector3(); 23 | 24 | return function updateMatrixWorld( force ) { 25 | 26 | this.matrixAutoUpdate && this.updateMatrix(); 27 | 28 | // update matrixWorld 29 | 30 | if ( this.matrixWorldNeedsUpdate || force ) { 31 | 32 | if ( this.parent !== null ) { 33 | 34 | this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); 35 | 36 | this.matrixWorld.decompose( translationWorld, quaternionWorld, scaleWorld ); 37 | this.matrix.decompose( translationObject, quaternionObject, scaleObject ); 38 | 39 | this.matrixWorld.compose( translationWorld, quaternionObject, scaleWorld ); 40 | 41 | 42 | } else { 43 | 44 | this.matrixWorld.copy( this.matrix ); 45 | 46 | } 47 | 48 | 49 | this.matrixWorldNeedsUpdate = false; 50 | 51 | force = true; 52 | 53 | } 54 | 55 | // update children 56 | 57 | for ( var i = 0, l = this.children.length; i < l; i ++ ) { 58 | 59 | this.children[ i ].updateMatrixWorld( force ); 60 | 61 | } 62 | 63 | }; 64 | 65 | }() ); 66 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/Gyroscope.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.Gyroscope = function () { 6 | 7 | THREE.Object3D.call( this ); 8 | 9 | }; 10 | 11 | THREE.Gyroscope.prototype = Object.create( THREE.Object3D.prototype ); 12 | THREE.Gyroscope.prototype.constructor = THREE.Gyroscope; 13 | 14 | THREE.Gyroscope.prototype.updateMatrixWorld = ( function () { 15 | 16 | var translationObject = new THREE.Vector3(); 17 | var quaternionObject = new THREE.Quaternion(); 18 | var scaleObject = new THREE.Vector3(); 19 | 20 | var translationWorld = new THREE.Vector3(); 21 | var quaternionWorld = new THREE.Quaternion(); 22 | var scaleWorld = new THREE.Vector3(); 23 | 24 | return function updateMatrixWorld( force ) { 25 | 26 | this.matrixAutoUpdate && this.updateMatrix(); 27 | 28 | // update matrixWorld 29 | 30 | if ( this.matrixWorldNeedsUpdate || force ) { 31 | 32 | if ( this.parent !== null ) { 33 | 34 | this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); 35 | 36 | this.matrixWorld.decompose( translationWorld, quaternionWorld, scaleWorld ); 37 | this.matrix.decompose( translationObject, quaternionObject, scaleObject ); 38 | 39 | this.matrixWorld.compose( translationWorld, quaternionObject, scaleWorld ); 40 | 41 | 42 | } else { 43 | 44 | this.matrixWorld.copy( this.matrix ); 45 | 46 | } 47 | 48 | 49 | this.matrixWorldNeedsUpdate = false; 50 | 51 | force = true; 52 | 53 | } 54 | 55 | // update children 56 | 57 | for ( var i = 0, l = this.children.length; i < l; i ++ ) { 58 | 59 | this.children[ i ].updateMatrixWorld( force ); 60 | 61 | } 62 | 63 | }; 64 | 65 | }() ); 66 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/BumpNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.BumpNode = function( value, coord, scale ) { 6 | 7 | THREE.TempNode.call( this, 'v3' ); 8 | 9 | this.value = value; 10 | this.coord = coord || new THREE.UVNode(); 11 | this.scale = scale || new THREE.Vector2Node( 1, 1 ); 12 | 13 | }; 14 | 15 | THREE.BumpNode.fBumpToNormal = new THREE.FunctionNode( [ 16 | "vec3 bumpToNormal( sampler2D bumpMap, vec2 uv, vec2 scale ) {", 17 | " vec2 dSTdx = dFdx( uv );", 18 | " vec2 dSTdy = dFdy( uv );", 19 | " float Hll = texture2D( bumpMap, uv ).x;", 20 | " float dBx = texture2D( bumpMap, uv + dSTdx ).x - Hll;", 21 | " float dBy = texture2D( bumpMap, uv + dSTdy ).x - Hll;", 22 | " return vec3( .5 + ( dBx * scale.x ), .5 + ( dBy * scale.y ), 1.0 );", 23 | "}" 24 | ].join( "\n" ), null, { derivatives: true } ); 25 | 26 | THREE.BumpNode.prototype = Object.create( THREE.TempNode.prototype ); 27 | THREE.BumpNode.prototype.constructor = THREE.BumpNode; 28 | 29 | THREE.BumpNode.prototype.generate = function( builder, output ) { 30 | 31 | var material = builder.material, func = THREE.BumpNode.fBumpToNormal; 32 | 33 | builder.include( func ); 34 | 35 | if ( builder.isShader( 'fragment' ) ) { 36 | 37 | return builder.format( func.name + '(' + this.value.build( builder, 'sampler2D' ) + ',' + 38 | this.coord.build( builder, 'v2' ) + ',' + 39 | this.scale.build( builder, 'v2' ) + ')', this.getType( builder ), output ); 40 | 41 | } else { 42 | 43 | console.warn( "THREE.BumpNode is not compatible with " + builder.shader + " shader." ); 44 | 45 | return builder.format( 'vec3( 0.0 )', this.getType( builder ), output ); 46 | 47 | } 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/BumpNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.BumpNode = function( value, coord, scale ) { 6 | 7 | THREE.TempNode.call( this, 'v3' ); 8 | 9 | this.value = value; 10 | this.coord = coord || new THREE.UVNode(); 11 | this.scale = scale || new THREE.Vector2Node( 1, 1 ); 12 | 13 | }; 14 | 15 | THREE.BumpNode.fBumpToNormal = new THREE.FunctionNode( [ 16 | "vec3 bumpToNormal( sampler2D bumpMap, vec2 uv, vec2 scale ) {", 17 | " vec2 dSTdx = dFdx( uv );", 18 | " vec2 dSTdy = dFdy( uv );", 19 | " float Hll = texture2D( bumpMap, uv ).x;", 20 | " float dBx = texture2D( bumpMap, uv + dSTdx ).x - Hll;", 21 | " float dBy = texture2D( bumpMap, uv + dSTdy ).x - Hll;", 22 | " return vec3( .5 + ( dBx * scale.x ), .5 + ( dBy * scale.y ), 1.0 );", 23 | "}" 24 | ].join( "\n" ), null, { derivatives: true } ); 25 | 26 | THREE.BumpNode.prototype = Object.create( THREE.TempNode.prototype ); 27 | THREE.BumpNode.prototype.constructor = THREE.BumpNode; 28 | 29 | THREE.BumpNode.prototype.generate = function( builder, output ) { 30 | 31 | var material = builder.material, func = THREE.BumpNode.fBumpToNormal; 32 | 33 | builder.include( func ); 34 | 35 | if ( builder.isShader( 'fragment' ) ) { 36 | 37 | return builder.format( func.name + '(' + this.value.build( builder, 'sampler2D' ) + ',' + 38 | this.coord.build( builder, 'v2' ) + ',' + 39 | this.scale.build( builder, 'v2' ) + ')', this.getType( builder ), output ); 40 | 41 | } else { 42 | 43 | console.warn( "THREE.BumpNode is not compatible with " + builder.shader + " shader." ); 44 | 45 | return builder.format( 'vec3( 0.0 )', this.getType( builder ), output ); 46 | 47 | } 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/MorphAnimMesh.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.MorphAnimMesh = function ( geometry, material ) { 6 | 7 | THREE.Mesh.call( this, geometry, material ); 8 | 9 | this.type = 'MorphAnimMesh'; 10 | 11 | this.mixer = new THREE.AnimationMixer( this ); 12 | this.activeAction = null; 13 | }; 14 | 15 | THREE.MorphAnimMesh.prototype = Object.create( THREE.Mesh.prototype ); 16 | THREE.MorphAnimMesh.prototype.constructor = THREE.MorphAnimMesh; 17 | 18 | THREE.MorphAnimMesh.prototype.setDirectionForward = function () { 19 | 20 | this.mixer.timeScale = 1.0; 21 | 22 | }; 23 | 24 | THREE.MorphAnimMesh.prototype.setDirectionBackward = function () { 25 | 26 | this.mixer.timeScale = -1.0; 27 | 28 | }; 29 | 30 | THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) { 31 | 32 | if( this.activeAction ) { 33 | 34 | this.activeAction.stop(); 35 | this.activeAction = null; 36 | 37 | } 38 | 39 | var clip = THREE.AnimationClip.findByName( this, label ); 40 | 41 | if ( clip ) { 42 | 43 | var action = this.mixer.clipAction( clip ); 44 | action.timeScale = ( clip.tracks.length * fps ) / clip.duration; 45 | this.activeAction = action.play(); 46 | 47 | } else { 48 | 49 | throw new Error( 'THREE.MorphAnimMesh: animations[' + label + '] undefined in .playAnimation()' ); 50 | 51 | } 52 | 53 | }; 54 | 55 | THREE.MorphAnimMesh.prototype.updateAnimation = function ( delta ) { 56 | 57 | this.mixer.update( delta ); 58 | 59 | }; 60 | 61 | THREE.MorphAnimMesh.prototype.copy = function ( source ) { 62 | 63 | THREE.Mesh.prototype.copy.call( this, source ); 64 | 65 | this.mixer = new THREE.AnimationMixer( this ); 66 | 67 | return this; 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/MorphAnimMesh.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.MorphAnimMesh = function ( geometry, material ) { 6 | 7 | THREE.Mesh.call( this, geometry, material ); 8 | 9 | this.type = 'MorphAnimMesh'; 10 | 11 | this.mixer = new THREE.AnimationMixer( this ); 12 | this.activeAction = null; 13 | }; 14 | 15 | THREE.MorphAnimMesh.prototype = Object.create( THREE.Mesh.prototype ); 16 | THREE.MorphAnimMesh.prototype.constructor = THREE.MorphAnimMesh; 17 | 18 | THREE.MorphAnimMesh.prototype.setDirectionForward = function () { 19 | 20 | this.mixer.timeScale = 1.0; 21 | 22 | }; 23 | 24 | THREE.MorphAnimMesh.prototype.setDirectionBackward = function () { 25 | 26 | this.mixer.timeScale = -1.0; 27 | 28 | }; 29 | 30 | THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) { 31 | 32 | if( this.activeAction ) { 33 | 34 | this.activeAction.stop(); 35 | this.activeAction = null; 36 | 37 | } 38 | 39 | var clip = THREE.AnimationClip.findByName( this, label ); 40 | 41 | if ( clip ) { 42 | 43 | var action = this.mixer.clipAction( clip ); 44 | action.timeScale = ( clip.tracks.length * fps ) / clip.duration; 45 | this.activeAction = action.play(); 46 | 47 | } else { 48 | 49 | throw new Error( 'THREE.MorphAnimMesh: animations[' + label + '] undefined in .playAnimation()' ); 50 | 51 | } 52 | 53 | }; 54 | 55 | THREE.MorphAnimMesh.prototype.updateAnimation = function ( delta ) { 56 | 57 | this.mixer.update( delta ); 58 | 59 | }; 60 | 61 | THREE.MorphAnimMesh.prototype.copy = function ( source ) { 62 | 63 | THREE.Mesh.prototype.copy.call( this, source ); 64 | 65 | this.mixer = new THREE.AnimationMixer( this ); 66 | 67 | return this; 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/controls/PointerLockControls.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | THREE.PointerLockControls = function ( camera ) { 6 | 7 | var scope = this; 8 | 9 | camera.rotation.set( 0, 0, 0 ); 10 | 11 | var pitchObject = new THREE.Object3D(); 12 | pitchObject.add( camera ); 13 | 14 | var yawObject = new THREE.Object3D(); 15 | yawObject.position.y = 10; 16 | yawObject.add( pitchObject ); 17 | 18 | var PI_2 = Math.PI / 2; 19 | 20 | var onMouseMove = function ( event ) { 21 | 22 | if ( scope.enabled === false ) return; 23 | 24 | var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0; 25 | var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0; 26 | 27 | yawObject.rotation.y -= movementX * 0.002; 28 | pitchObject.rotation.x -= movementY * 0.002; 29 | 30 | pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) ); 31 | 32 | }; 33 | 34 | this.dispose = function() { 35 | 36 | document.removeEventListener( 'mousemove', onMouseMove, false ); 37 | 38 | }; 39 | 40 | document.addEventListener( 'mousemove', onMouseMove, false ); 41 | 42 | this.enabled = false; 43 | 44 | this.getObject = function () { 45 | 46 | return yawObject; 47 | 48 | }; 49 | 50 | this.getDirection = function() { 51 | 52 | // assumes the camera itself is not rotated 53 | 54 | var direction = new THREE.Vector3( 0, 0, - 1 ); 55 | var rotation = new THREE.Euler( 0, 0, 0, "YXZ" ); 56 | 57 | return function( v ) { 58 | 59 | rotation.set( pitchObject.rotation.x, yawObject.rotation.y, 0 ); 60 | 61 | v.copy( direction ).applyEuler( rotation ); 62 | 63 | return v; 64 | 65 | }; 66 | 67 | }(); 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/controls/PointerLockControls.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | THREE.PointerLockControls = function ( camera ) { 6 | 7 | var scope = this; 8 | 9 | camera.rotation.set( 0, 0, 0 ); 10 | 11 | var pitchObject = new THREE.Object3D(); 12 | pitchObject.add( camera ); 13 | 14 | var yawObject = new THREE.Object3D(); 15 | yawObject.position.y = 10; 16 | yawObject.add( pitchObject ); 17 | 18 | var PI_2 = Math.PI / 2; 19 | 20 | var onMouseMove = function ( event ) { 21 | 22 | if ( scope.enabled === false ) return; 23 | 24 | var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0; 25 | var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0; 26 | 27 | yawObject.rotation.y -= movementX * 0.002; 28 | pitchObject.rotation.x -= movementY * 0.002; 29 | 30 | pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) ); 31 | 32 | }; 33 | 34 | this.dispose = function() { 35 | 36 | document.removeEventListener( 'mousemove', onMouseMove, false ); 37 | 38 | }; 39 | 40 | document.addEventListener( 'mousemove', onMouseMove, false ); 41 | 42 | this.enabled = false; 43 | 44 | this.getObject = function () { 45 | 46 | return yawObject; 47 | 48 | }; 49 | 50 | this.getDirection = function() { 51 | 52 | // assumes the camera itself is not rotated 53 | 54 | var direction = new THREE.Vector3( 0, 0, - 1 ); 55 | var rotation = new THREE.Euler( 0, 0, 0, "YXZ" ); 56 | 57 | return function( v ) { 58 | 59 | rotation.set( pitchObject.rotation.x, yawObject.rotation.y, 0 ); 60 | 61 | v.copy( direction ).applyEuler( rotation ); 62 | 63 | return v; 64 | 65 | }; 66 | 67 | }(); 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/postprocessing/TexturePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.TexturePass = function ( map, opacity ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | if ( THREE.CopyShader === undefined ) 10 | console.error( "THREE.TexturePass relies on THREE.CopyShader" ); 11 | 12 | var shader = THREE.CopyShader; 13 | 14 | this.map = map; 15 | this.opacity = ( opacity !== undefined ) ? opacity : 1.0; 16 | 17 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 18 | 19 | this.material = new THREE.ShaderMaterial( { 20 | 21 | uniforms: this.uniforms, 22 | vertexShader: shader.vertexShader, 23 | fragmentShader: shader.fragmentShader, 24 | depthTest: false, 25 | depthWrite: false 26 | 27 | } ); 28 | 29 | this.needsSwap = false; 30 | 31 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 32 | this.scene = new THREE.Scene(); 33 | 34 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 35 | this.scene.add( this.quad ); 36 | 37 | }; 38 | 39 | THREE.TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 40 | 41 | constructor: THREE.TexturePass, 42 | 43 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 44 | 45 | var oldAutoClear = renderer.autoClear; 46 | renderer.autoClear = false; 47 | 48 | this.quad.material = this.material; 49 | 50 | this.uniforms[ "opacity" ].value = this.opacity; 51 | this.uniforms[ "tDiffuse" ].value = this.map; 52 | this.material.transparent = ( this.opacity < 1.0 ); 53 | 54 | renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear ); 55 | 56 | renderer.autoClear = oldAutoClear; 57 | } 58 | 59 | } ); 60 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/postprocessing/TexturePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.TexturePass = function ( map, opacity ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | if ( THREE.CopyShader === undefined ) 10 | console.error( "THREE.TexturePass relies on THREE.CopyShader" ); 11 | 12 | var shader = THREE.CopyShader; 13 | 14 | this.map = map; 15 | this.opacity = ( opacity !== undefined ) ? opacity : 1.0; 16 | 17 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 18 | 19 | this.material = new THREE.ShaderMaterial( { 20 | 21 | uniforms: this.uniforms, 22 | vertexShader: shader.vertexShader, 23 | fragmentShader: shader.fragmentShader, 24 | depthTest: false, 25 | depthWrite: false 26 | 27 | } ); 28 | 29 | this.needsSwap = false; 30 | 31 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 32 | this.scene = new THREE.Scene(); 33 | 34 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 35 | this.scene.add( this.quad ); 36 | 37 | }; 38 | 39 | THREE.TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 40 | 41 | constructor: THREE.TexturePass, 42 | 43 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 44 | 45 | var oldAutoClear = renderer.autoClear; 46 | renderer.autoClear = false; 47 | 48 | this.quad.material = this.material; 49 | 50 | this.uniforms[ "opacity" ].value = this.opacity; 51 | this.uniforms[ "tDiffuse" ].value = this.map; 52 | this.material.transparent = ( this.opacity < 1.0 ); 53 | 54 | renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear ); 55 | 56 | renderer.autoClear = oldAutoClear; 57 | } 58 | 59 | } ); 60 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/SwitchNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.SwitchNode = function( node, components ) { 6 | 7 | THREE.GLNode.call( this ); 8 | 9 | this.node = node; 10 | this.components = components || 'x'; 11 | 12 | }; 13 | 14 | THREE.SwitchNode.prototype = Object.create( THREE.GLNode.prototype ); 15 | THREE.SwitchNode.prototype.constructor = THREE.SwitchNode; 16 | 17 | THREE.SwitchNode.prototype.getType = function( builder ) { 18 | 19 | return builder.getFormatFromLength( this.components.length ); 20 | 21 | }; 22 | 23 | THREE.SwitchNode.prototype.generate = function( builder, output ) { 24 | 25 | var type = this.node.getType( builder ); 26 | var inputLength = builder.getFormatLength( type ) - 1; 27 | 28 | var node = this.node.build( builder, type ); 29 | 30 | if ( inputLength > 0 ) { 31 | 32 | // get max length 33 | 34 | var outputLength = 0; 35 | var components = builder.colorToVector( this.components ); 36 | 37 | var i, len = components.length; 38 | 39 | for ( i = 0; i < len; i ++ ) { 40 | 41 | outputLength = Math.max( outputLength, builder.getIndexByElement( components.charAt( i ) ) ); 42 | 43 | } 44 | 45 | if ( outputLength > inputLength ) outputLength = inputLength; 46 | 47 | // split 48 | 49 | node += '.'; 50 | 51 | for ( i = 0; i < len; i ++ ) { 52 | 53 | var elm = components.charAt( i ); 54 | var idx = builder.getIndexByElement( components.charAt( i ) ); 55 | 56 | if ( idx > outputLength ) idx = outputLength; 57 | 58 | node += builder.getElementByIndex( idx ); 59 | 60 | } 61 | 62 | return builder.format( node, this.getType( builder ), output ); 63 | 64 | } else { 65 | 66 | // join 67 | 68 | return builder.format( node, type, output ) 69 | 70 | } 71 | 72 | }; 73 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/postprocessing/DotScreenPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.DotScreenPass = function ( center, angle, scale ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | if ( THREE.DotScreenShader === undefined ) 10 | console.error( "THREE.DotScreenPass relies on THREE.DotScreenShader" ); 11 | 12 | var shader = THREE.DotScreenShader; 13 | 14 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 15 | 16 | if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center ); 17 | if ( angle !== undefined ) this.uniforms[ "angle" ].value = angle; 18 | if ( scale !== undefined ) this.uniforms[ "scale" ].value = scale; 19 | 20 | this.material = new THREE.ShaderMaterial( { 21 | 22 | uniforms: this.uniforms, 23 | vertexShader: shader.vertexShader, 24 | fragmentShader: shader.fragmentShader 25 | 26 | } ); 27 | 28 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 29 | this.scene = new THREE.Scene(); 30 | 31 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 32 | this.scene.add( this.quad ); 33 | 34 | }; 35 | 36 | THREE.DotScreenPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 37 | 38 | constructor: THREE.DotScreenPass, 39 | 40 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 41 | 42 | this.uniforms[ "tDiffuse" ].value = readBuffer.texture; 43 | this.uniforms[ "tSize" ].value.set( readBuffer.width, readBuffer.height ); 44 | 45 | this.quad.material = this.material; 46 | 47 | if ( this.renderToScreen ) { 48 | 49 | renderer.render( this.scene, this.camera ); 50 | 51 | } else { 52 | 53 | renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 54 | 55 | } 56 | 57 | } 58 | 59 | } ); 60 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/SwitchNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.SwitchNode = function( node, components ) { 6 | 7 | THREE.GLNode.call( this ); 8 | 9 | this.node = node; 10 | this.components = components || 'x'; 11 | 12 | }; 13 | 14 | THREE.SwitchNode.prototype = Object.create( THREE.GLNode.prototype ); 15 | THREE.SwitchNode.prototype.constructor = THREE.SwitchNode; 16 | 17 | THREE.SwitchNode.prototype.getType = function( builder ) { 18 | 19 | return builder.getFormatFromLength( this.components.length ); 20 | 21 | }; 22 | 23 | THREE.SwitchNode.prototype.generate = function( builder, output ) { 24 | 25 | var type = this.node.getType( builder ); 26 | var inputLength = builder.getFormatLength( type ) - 1; 27 | 28 | var node = this.node.build( builder, type ); 29 | 30 | if ( inputLength > 0 ) { 31 | 32 | // get max length 33 | 34 | var outputLength = 0; 35 | var components = builder.colorToVector( this.components ); 36 | 37 | var i, len = components.length; 38 | 39 | for ( i = 0; i < len; i ++ ) { 40 | 41 | outputLength = Math.max( outputLength, builder.getIndexByElement( components.charAt( i ) ) ); 42 | 43 | } 44 | 45 | if ( outputLength > inputLength ) outputLength = inputLength; 46 | 47 | // split 48 | 49 | node += '.'; 50 | 51 | for ( i = 0; i < len; i ++ ) { 52 | 53 | var elm = components.charAt( i ); 54 | var idx = builder.getIndexByElement( components.charAt( i ) ); 55 | 56 | if ( idx > outputLength ) idx = outputLength; 57 | 58 | node += builder.getElementByIndex( idx ); 59 | 60 | } 61 | 62 | return builder.format( node, this.getType( builder ), output ); 63 | 64 | } else { 65 | 66 | // join 67 | 68 | return builder.format( node, type, output ) 69 | 70 | } 71 | 72 | }; 73 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/postprocessing/DotScreenPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.DotScreenPass = function ( center, angle, scale ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | if ( THREE.DotScreenShader === undefined ) 10 | console.error( "THREE.DotScreenPass relies on THREE.DotScreenShader" ); 11 | 12 | var shader = THREE.DotScreenShader; 13 | 14 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 15 | 16 | if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center ); 17 | if ( angle !== undefined ) this.uniforms[ "angle" ].value = angle; 18 | if ( scale !== undefined ) this.uniforms[ "scale" ].value = scale; 19 | 20 | this.material = new THREE.ShaderMaterial( { 21 | 22 | uniforms: this.uniforms, 23 | vertexShader: shader.vertexShader, 24 | fragmentShader: shader.fragmentShader 25 | 26 | } ); 27 | 28 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 29 | this.scene = new THREE.Scene(); 30 | 31 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 32 | this.scene.add( this.quad ); 33 | 34 | }; 35 | 36 | THREE.DotScreenPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 37 | 38 | constructor: THREE.DotScreenPass, 39 | 40 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 41 | 42 | this.uniforms[ "tDiffuse" ].value = readBuffer.texture; 43 | this.uniforms[ "tSize" ].value.set( readBuffer.width, readBuffer.height ); 44 | 45 | this.quad.material = this.material; 46 | 47 | if ( this.renderToScreen ) { 48 | 49 | renderer.render( this.scene, this.camera ); 50 | 51 | } else { 52 | 53 | renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 54 | 55 | } 56 | 57 | } 58 | 59 | } ); 60 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/inputs/CubeTextureNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.CubeTextureNode = function( value, coord, bias ) { 6 | 7 | THREE.InputNode.call( this, 'v4', { shared : true } ); 8 | 9 | this.value = value; 10 | this.coord = coord || new THREE.ReflectNode(); 11 | this.bias = bias; 12 | 13 | }; 14 | 15 | THREE.CubeTextureNode.prototype = Object.create( THREE.InputNode.prototype ); 16 | THREE.CubeTextureNode.prototype.constructor = THREE.CubeTextureNode; 17 | 18 | THREE.CubeTextureNode.prototype.getTexture = function( builder, output ) { 19 | 20 | return THREE.InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 't' ); 21 | 22 | }; 23 | 24 | THREE.CubeTextureNode.prototype.generate = function( builder, output ) { 25 | 26 | if ( output === 'samplerCube' ) { 27 | 28 | return this.getTexture( builder, output ); 29 | 30 | } 31 | 32 | var cubetex = this.getTexture( builder, output ); 33 | var coord = this.coord.build( builder, 'v3' ); 34 | var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined; 35 | 36 | if ( bias == undefined && builder.requires.bias ) { 37 | 38 | bias = builder.requires.bias.build( builder, 'fv1' ); 39 | 40 | } 41 | 42 | var code; 43 | 44 | if ( bias ) code = 'texCubeBias(' + cubetex + ',' + coord + ',' + bias + ')'; 45 | else code = 'texCube(' + cubetex + ',' + coord + ')'; 46 | 47 | if ( builder.isSlot( 'color' ) ) { 48 | 49 | code = 'mapTexelToLinear(' + code + ')'; 50 | 51 | } else if ( builder.isSlot( 'emissive' ) ) { 52 | 53 | code = 'emissiveMapTexelToLinear(' + code + ')'; 54 | 55 | } else if ( builder.isSlot( 'environment' ) ) { 56 | 57 | code = 'envMapTexelToLinear(' + code + ')'; 58 | 59 | } 60 | 61 | return builder.format( code, this.type, output ); 62 | 63 | }; 64 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/inputs/CubeTextureNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.CubeTextureNode = function( value, coord, bias ) { 6 | 7 | THREE.InputNode.call( this, 'v4', { shared : true } ); 8 | 9 | this.value = value; 10 | this.coord = coord || new THREE.ReflectNode(); 11 | this.bias = bias; 12 | 13 | }; 14 | 15 | THREE.CubeTextureNode.prototype = Object.create( THREE.InputNode.prototype ); 16 | THREE.CubeTextureNode.prototype.constructor = THREE.CubeTextureNode; 17 | 18 | THREE.CubeTextureNode.prototype.getTexture = function( builder, output ) { 19 | 20 | return THREE.InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 't' ); 21 | 22 | }; 23 | 24 | THREE.CubeTextureNode.prototype.generate = function( builder, output ) { 25 | 26 | if ( output === 'samplerCube' ) { 27 | 28 | return this.getTexture( builder, output ); 29 | 30 | } 31 | 32 | var cubetex = this.getTexture( builder, output ); 33 | var coord = this.coord.build( builder, 'v3' ); 34 | var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined; 35 | 36 | if ( bias == undefined && builder.requires.bias ) { 37 | 38 | bias = builder.requires.bias.build( builder, 'fv1' ); 39 | 40 | } 41 | 42 | var code; 43 | 44 | if ( bias ) code = 'texCubeBias(' + cubetex + ',' + coord + ',' + bias + ')'; 45 | else code = 'texCube(' + cubetex + ',' + coord + ')'; 46 | 47 | if ( builder.isSlot( 'color' ) ) { 48 | 49 | code = 'mapTexelToLinear(' + code + ')'; 50 | 51 | } else if ( builder.isSlot( 'emissive' ) ) { 52 | 53 | code = 'emissiveMapTexelToLinear(' + code + ')'; 54 | 55 | } else if ( builder.isSlot( 'environment' ) ) { 56 | 57 | code = 'envMapTexelToLinear(' + code + ')'; 58 | 59 | } 60 | 61 | return builder.format( code, this.type, output ); 62 | 63 | }; 64 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/exporters/STLExporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author kovacsv / http://kovacsv.hu/ 3 | * @author mrdoob / http://mrdoob.com/ 4 | */ 5 | 6 | THREE.STLExporter = function () {}; 7 | 8 | THREE.STLExporter.prototype = { 9 | 10 | constructor: THREE.STLExporter, 11 | 12 | parse: ( function () { 13 | 14 | var vector = new THREE.Vector3(); 15 | var normalMatrixWorld = new THREE.Matrix3(); 16 | 17 | return function parse( scene ) { 18 | 19 | var output = ''; 20 | 21 | output += 'solid exported\n'; 22 | 23 | scene.traverse( function ( object ) { 24 | 25 | if ( object instanceof THREE.Mesh ) { 26 | 27 | var geometry = object.geometry; 28 | var matrixWorld = object.matrixWorld; 29 | 30 | if ( geometry instanceof THREE.Geometry ) { 31 | 32 | var vertices = geometry.vertices; 33 | var faces = geometry.faces; 34 | 35 | normalMatrixWorld.getNormalMatrix( matrixWorld ); 36 | 37 | for ( var i = 0, l = faces.length; i < l; i ++ ) { 38 | 39 | var face = faces[ i ]; 40 | 41 | vector.copy( face.normal ).applyMatrix3( normalMatrixWorld ).normalize(); 42 | 43 | output += '\tfacet normal ' + vector.x + ' ' + vector.y + ' ' + vector.z + '\n'; 44 | output += '\t\touter loop\n'; 45 | 46 | var indices = [ face.a, face.b, face.c ]; 47 | 48 | for ( var j = 0; j < 3; j ++ ) { 49 | 50 | vector.copy( vertices[ indices[ j ] ] ).applyMatrix4( matrixWorld ); 51 | 52 | output += '\t\t\tvertex ' + vector.x + ' ' + vector.y + ' ' + vector.z + '\n'; 53 | 54 | } 55 | 56 | output += '\t\tendloop\n'; 57 | output += '\tendfacet\n'; 58 | 59 | } 60 | 61 | } 62 | 63 | } 64 | 65 | } ); 66 | 67 | output += 'endsolid exported\n'; 68 | 69 | return output; 70 | 71 | }; 72 | 73 | }() ) 74 | 75 | }; 76 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/postprocessing/CubeTexturePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author bhouston / http://clara.io/ 3 | */ 4 | 5 | THREE.CubeTexturePass = function ( camera, envMap, opacity ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.camera = camera; 10 | 11 | this.needsSwap = false; 12 | 13 | this.cubeShader = THREE.ShaderLib[ 'cube' ]; 14 | this.cubeMesh = new THREE.Mesh( 15 | new THREE.BoxBufferGeometry( 10, 10, 10 ), 16 | new THREE.ShaderMaterial( { 17 | uniforms: this.cubeShader.uniforms, 18 | vertexShader: this.cubeShader.vertexShader, 19 | fragmentShader: this.cubeShader.fragmentShader, 20 | depthTest: false, 21 | depthWrite: false, 22 | side: THREE.BackSide 23 | } ) 24 | ); 25 | 26 | this.envMap = envMap; 27 | this.opacity = ( opacity !== undefined ) ? opacity : 1.0; 28 | 29 | this.cubeScene = new THREE.Scene(); 30 | this.cubeCamera = new THREE.PerspectiveCamera(); 31 | this.cubeScene.add( this.cubeMesh ); 32 | 33 | }; 34 | 35 | THREE.CubeTexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 36 | 37 | constructor: THREE.CubeTexturePass, 38 | 39 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 40 | 41 | var oldAutoClear = renderer.autoClear; 42 | renderer.autoClear = false; 43 | 44 | this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix ); 45 | this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld ); 46 | 47 | this.cubeMesh.material.uniforms[ "tCube" ].value = this.envMap; 48 | this.cubeMesh.material.uniforms[ "opacity" ].value = this.opacity; 49 | this.cubeMesh.material.transparent = ( this.opacity < 1.0 ); 50 | 51 | renderer.render( this.cubeScene, this.cubeCamera, this.renderToScreen ? null : readBuffer, this.clear ); 52 | 53 | renderer.autoClear = oldAutoClear; 54 | 55 | } 56 | 57 | } ); 58 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/exporters/STLExporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author kovacsv / http://kovacsv.hu/ 3 | * @author mrdoob / http://mrdoob.com/ 4 | */ 5 | 6 | THREE.STLExporter = function () {}; 7 | 8 | THREE.STLExporter.prototype = { 9 | 10 | constructor: THREE.STLExporter, 11 | 12 | parse: ( function () { 13 | 14 | var vector = new THREE.Vector3(); 15 | var normalMatrixWorld = new THREE.Matrix3(); 16 | 17 | return function parse( scene ) { 18 | 19 | var output = ''; 20 | 21 | output += 'solid exported\n'; 22 | 23 | scene.traverse( function ( object ) { 24 | 25 | if ( object instanceof THREE.Mesh ) { 26 | 27 | var geometry = object.geometry; 28 | var matrixWorld = object.matrixWorld; 29 | 30 | if ( geometry instanceof THREE.Geometry ) { 31 | 32 | var vertices = geometry.vertices; 33 | var faces = geometry.faces; 34 | 35 | normalMatrixWorld.getNormalMatrix( matrixWorld ); 36 | 37 | for ( var i = 0, l = faces.length; i < l; i ++ ) { 38 | 39 | var face = faces[ i ]; 40 | 41 | vector.copy( face.normal ).applyMatrix3( normalMatrixWorld ).normalize(); 42 | 43 | output += '\tfacet normal ' + vector.x + ' ' + vector.y + ' ' + vector.z + '\n'; 44 | output += '\t\touter loop\n'; 45 | 46 | var indices = [ face.a, face.b, face.c ]; 47 | 48 | for ( var j = 0; j < 3; j ++ ) { 49 | 50 | vector.copy( vertices[ indices[ j ] ] ).applyMatrix4( matrixWorld ); 51 | 52 | output += '\t\t\tvertex ' + vector.x + ' ' + vector.y + ' ' + vector.z + '\n'; 53 | 54 | } 55 | 56 | output += '\t\tendloop\n'; 57 | output += '\tendfacet\n'; 58 | 59 | } 60 | 61 | } 62 | 63 | } 64 | 65 | } ); 66 | 67 | output += 'endsolid exported\n'; 68 | 69 | return output; 70 | 71 | }; 72 | 73 | }() ) 74 | 75 | }; 76 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/postprocessing/CubeTexturePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author bhouston / http://clara.io/ 3 | */ 4 | 5 | THREE.CubeTexturePass = function ( camera, envMap, opacity ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.camera = camera; 10 | 11 | this.needsSwap = false; 12 | 13 | this.cubeShader = THREE.ShaderLib[ 'cube' ]; 14 | this.cubeMesh = new THREE.Mesh( 15 | new THREE.BoxBufferGeometry( 10, 10, 10 ), 16 | new THREE.ShaderMaterial( { 17 | uniforms: this.cubeShader.uniforms, 18 | vertexShader: this.cubeShader.vertexShader, 19 | fragmentShader: this.cubeShader.fragmentShader, 20 | depthTest: false, 21 | depthWrite: false, 22 | side: THREE.BackSide 23 | } ) 24 | ); 25 | 26 | this.envMap = envMap; 27 | this.opacity = ( opacity !== undefined ) ? opacity : 1.0; 28 | 29 | this.cubeScene = new THREE.Scene(); 30 | this.cubeCamera = new THREE.PerspectiveCamera(); 31 | this.cubeScene.add( this.cubeMesh ); 32 | 33 | }; 34 | 35 | THREE.CubeTexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 36 | 37 | constructor: THREE.CubeTexturePass, 38 | 39 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 40 | 41 | var oldAutoClear = renderer.autoClear; 42 | renderer.autoClear = false; 43 | 44 | this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix ); 45 | this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld ); 46 | 47 | this.cubeMesh.material.uniforms[ "tCube" ].value = this.envMap; 48 | this.cubeMesh.material.uniforms[ "opacity" ].value = this.opacity; 49 | this.cubeMesh.material.transparent = ( this.opacity < 1.0 ); 50 | 51 | renderer.render( this.cubeScene, this.cubeCamera, this.renderToScreen ? null : readBuffer, this.clear ); 52 | 53 | renderer.autoClear = oldAutoClear; 54 | 55 | } 56 | 57 | } ); 58 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/postprocessing/SavePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.SavePass = function ( renderTarget ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | if ( THREE.CopyShader === undefined ) 10 | console.error( "THREE.SavePass relies on THREE.CopyShader" ); 11 | 12 | var shader = THREE.CopyShader; 13 | 14 | this.textureID = "tDiffuse"; 15 | 16 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 17 | 18 | this.material = new THREE.ShaderMaterial( { 19 | 20 | uniforms: this.uniforms, 21 | vertexShader: shader.vertexShader, 22 | fragmentShader: shader.fragmentShader 23 | 24 | } ); 25 | 26 | this.renderTarget = renderTarget; 27 | 28 | if ( this.renderTarget === undefined ) { 29 | 30 | this.renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false }; 31 | this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters ); 32 | 33 | } 34 | 35 | this.needsSwap = false; 36 | 37 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 38 | this.scene = new THREE.Scene(); 39 | 40 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 41 | this.scene.add( this.quad ); 42 | 43 | }; 44 | 45 | THREE.SavePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 46 | 47 | constructor: THREE.SavePass, 48 | 49 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 50 | 51 | if ( this.uniforms[ this.textureID ] ) { 52 | 53 | this.uniforms[ this.textureID ].value = readBuffer.texture; 54 | 55 | } 56 | 57 | this.quad.material = this.material; 58 | 59 | renderer.render( this.scene, this.camera, this.renderTarget, this.clear ); 60 | 61 | } 62 | 63 | } ); 64 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/postprocessing/SavePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.SavePass = function ( renderTarget ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | if ( THREE.CopyShader === undefined ) 10 | console.error( "THREE.SavePass relies on THREE.CopyShader" ); 11 | 12 | var shader = THREE.CopyShader; 13 | 14 | this.textureID = "tDiffuse"; 15 | 16 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 17 | 18 | this.material = new THREE.ShaderMaterial( { 19 | 20 | uniforms: this.uniforms, 21 | vertexShader: shader.vertexShader, 22 | fragmentShader: shader.fragmentShader 23 | 24 | } ); 25 | 26 | this.renderTarget = renderTarget; 27 | 28 | if ( this.renderTarget === undefined ) { 29 | 30 | this.renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false }; 31 | this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters ); 32 | 33 | } 34 | 35 | this.needsSwap = false; 36 | 37 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 38 | this.scene = new THREE.Scene(); 39 | 40 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 41 | this.scene.add( this.quad ); 42 | 43 | }; 44 | 45 | THREE.SavePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 46 | 47 | constructor: THREE.SavePass, 48 | 49 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 50 | 51 | if ( this.uniforms[ this.textureID ] ) { 52 | 53 | this.uniforms[ this.textureID ].value = readBuffer.texture; 54 | 55 | } 56 | 57 | this.quad.material = this.material; 58 | 59 | renderer.render( this.scene, this.camera, this.renderTarget, this.clear ); 60 | 61 | } 62 | 63 | } ); 64 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/libs/stats.min.js: -------------------------------------------------------------------------------- 1 | // stats.js - http://github.com/mrdoob/stats.js 2 | var Stats=function(){function h(a){c.appendChild(a.dom);return a}function k(a){for(var d=0;de+1E3&&(r.update(1E3*a/(c-e),100),e=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){g=this.end()},domElement:c,setMode:k}}; 4 | Stats.Panel=function(h,k,l){var c=Infinity,g=0,e=Math.round,a=e(window.devicePixelRatio||1),r=80*a,f=48*a,t=3*a,u=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=f;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,f);b.fillStyle=k;b.fillText(h,t,u);b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(f, 5 | v){c=Math.min(c,f);g=Math.max(g,f);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=k;b.fillText(e(f)+" "+h+" ("+e(c)+"-"+e(g)+")",t,u);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,e((1-f/v)*p))}}};"object"===typeof module&&(module.exports=Stats); 6 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/libs/stats.min.js: -------------------------------------------------------------------------------- 1 | // stats.js - http://github.com/mrdoob/stats.js 2 | var Stats=function(){function h(a){c.appendChild(a.dom);return a}function k(a){for(var d=0;de+1E3&&(r.update(1E3*a/(c-e),100),e=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){g=this.end()},domElement:c,setMode:k}}; 4 | Stats.Panel=function(h,k,l){var c=Infinity,g=0,e=Math.round,a=e(window.devicePixelRatio||1),r=80*a,f=48*a,t=3*a,u=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=f;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,f);b.fillStyle=k;b.fillText(h,t,u);b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(f, 5 | v){c=Math.min(c,f);g=Math.max(g,f);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=k;b.fillText(e(f)+" "+h+" ("+e(c)+"-"+e(g)+")",t,u);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,e((1-f/v)*p))}}};"object"===typeof module&&(module.exports=Stats); 6 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/postprocessing/FilmPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | if ( THREE.FilmShader === undefined ) 10 | console.error( "THREE.FilmPass relies on THREE.FilmShader" ); 11 | 12 | var shader = THREE.FilmShader; 13 | 14 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 15 | 16 | this.material = new THREE.ShaderMaterial( { 17 | 18 | uniforms: this.uniforms, 19 | vertexShader: shader.vertexShader, 20 | fragmentShader: shader.fragmentShader 21 | 22 | } ); 23 | 24 | if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale; 25 | if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity; 26 | if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity; 27 | if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount; 28 | 29 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 30 | this.scene = new THREE.Scene(); 31 | 32 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 33 | this.scene.add( this.quad ); 34 | 35 | }; 36 | 37 | THREE.FilmPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 38 | 39 | constructor: THREE.FilmPass, 40 | 41 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 42 | 43 | this.uniforms[ "tDiffuse" ].value = readBuffer.texture; 44 | this.uniforms[ "time" ].value += delta; 45 | 46 | this.quad.material = this.material; 47 | 48 | if ( this.renderToScreen ) { 49 | 50 | renderer.render( this.scene, this.camera ); 51 | 52 | } else { 53 | 54 | renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 55 | 56 | } 57 | 58 | } 59 | 60 | } ); 61 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/postprocessing/FilmPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | if ( THREE.FilmShader === undefined ) 10 | console.error( "THREE.FilmPass relies on THREE.FilmShader" ); 11 | 12 | var shader = THREE.FilmShader; 13 | 14 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 15 | 16 | this.material = new THREE.ShaderMaterial( { 17 | 18 | uniforms: this.uniforms, 19 | vertexShader: shader.vertexShader, 20 | fragmentShader: shader.fragmentShader 21 | 22 | } ); 23 | 24 | if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale; 25 | if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity; 26 | if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity; 27 | if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount; 28 | 29 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 30 | this.scene = new THREE.Scene(); 31 | 32 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 33 | this.scene.add( this.quad ); 34 | 35 | }; 36 | 37 | THREE.FilmPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 38 | 39 | constructor: THREE.FilmPass, 40 | 41 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 42 | 43 | this.uniforms[ "tDiffuse" ].value = readBuffer.texture; 44 | this.uniforms[ "time" ].value += delta; 45 | 46 | this.quad.material = this.material; 47 | 48 | if ( this.renderToScreen ) { 49 | 50 | renderer.render( this.scene, this.camera ); 51 | 52 | } else { 53 | 54 | renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 55 | 56 | } 57 | 58 | } 59 | 60 | } ); 61 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/HueSaturationShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author tapio / http://tapio.github.com/ 3 | * 4 | * Hue and saturation adjustment 5 | * https://github.com/evanw/glfx.js 6 | * hue: -1 to 1 (-1 is 180 degrees in the negative direction, 0 is no change, etc. 7 | * saturation: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) 8 | */ 9 | 10 | THREE.HueSaturationShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { value: null }, 15 | "hue": { value: 0 }, 16 | "saturation": { value: 0 } 17 | 18 | }, 19 | 20 | vertexShader: [ 21 | 22 | "varying vec2 vUv;", 23 | 24 | "void main() {", 25 | 26 | "vUv = uv;", 27 | 28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 29 | 30 | "}" 31 | 32 | ].join( "\n" ), 33 | 34 | fragmentShader: [ 35 | 36 | "uniform sampler2D tDiffuse;", 37 | "uniform float hue;", 38 | "uniform float saturation;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "gl_FragColor = texture2D( tDiffuse, vUv );", 45 | 46 | // hue 47 | "float angle = hue * 3.14159265;", 48 | "float s = sin(angle), c = cos(angle);", 49 | "vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;", 50 | "float len = length(gl_FragColor.rgb);", 51 | "gl_FragColor.rgb = vec3(", 52 | "dot(gl_FragColor.rgb, weights.xyz),", 53 | "dot(gl_FragColor.rgb, weights.zxy),", 54 | "dot(gl_FragColor.rgb, weights.yzx)", 55 | ");", 56 | 57 | // saturation 58 | "float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;", 59 | "if (saturation > 0.0) {", 60 | "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));", 61 | "} else {", 62 | "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);", 63 | "}", 64 | 65 | "}" 66 | 67 | ].join( "\n" ) 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/HueSaturationShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author tapio / http://tapio.github.com/ 3 | * 4 | * Hue and saturation adjustment 5 | * https://github.com/evanw/glfx.js 6 | * hue: -1 to 1 (-1 is 180 degrees in the negative direction, 0 is no change, etc. 7 | * saturation: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) 8 | */ 9 | 10 | THREE.HueSaturationShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { value: null }, 15 | "hue": { value: 0 }, 16 | "saturation": { value: 0 } 17 | 18 | }, 19 | 20 | vertexShader: [ 21 | 22 | "varying vec2 vUv;", 23 | 24 | "void main() {", 25 | 26 | "vUv = uv;", 27 | 28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 29 | 30 | "}" 31 | 32 | ].join( "\n" ), 33 | 34 | fragmentShader: [ 35 | 36 | "uniform sampler2D tDiffuse;", 37 | "uniform float hue;", 38 | "uniform float saturation;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "gl_FragColor = texture2D( tDiffuse, vUv );", 45 | 46 | // hue 47 | "float angle = hue * 3.14159265;", 48 | "float s = sin(angle), c = cos(angle);", 49 | "vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;", 50 | "float len = length(gl_FragColor.rgb);", 51 | "gl_FragColor.rgb = vec3(", 52 | "dot(gl_FragColor.rgb, weights.xyz),", 53 | "dot(gl_FragColor.rgb, weights.zxy),", 54 | "dot(gl_FragColor.rgb, weights.yzx)", 55 | ");", 56 | 57 | // saturation 58 | "float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;", 59 | "if (saturation > 0.0) {", 60 | "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));", 61 | "} else {", 62 | "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);", 63 | "}", 64 | 65 | "}" 66 | 67 | ].join( "\n" ) 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/VerticalBlurShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Two pass Gaussian blur filter (horizontal and vertical blur shaders) 5 | * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ 6 | * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html 7 | * 8 | * - 9 samples per pass 9 | * - standard deviation 2.7 10 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height" 11 | */ 12 | 13 | THREE.VerticalBlurShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { value: null }, 18 | "v": { value: 1.0 / 512.0 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join( "\n" ), 34 | 35 | fragmentShader: [ 36 | 37 | "uniform sampler2D tDiffuse;", 38 | "uniform float v;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "vec4 sum = vec4( 0.0 );", 45 | 46 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;", 47 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;", 48 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;", 49 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;", 50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", 51 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;", 52 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;", 53 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;", 54 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;", 55 | 56 | "gl_FragColor = sum;", 57 | 58 | "}" 59 | 60 | ].join( "\n" ) 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/VerticalBlurShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Two pass Gaussian blur filter (horizontal and vertical blur shaders) 5 | * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ 6 | * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html 7 | * 8 | * - 9 samples per pass 9 | * - standard deviation 2.7 10 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height" 11 | */ 12 | 13 | THREE.VerticalBlurShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { value: null }, 18 | "v": { value: 1.0 / 512.0 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join( "\n" ), 34 | 35 | fragmentShader: [ 36 | 37 | "uniform sampler2D tDiffuse;", 38 | "uniform float v;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "vec4 sum = vec4( 0.0 );", 45 | 46 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;", 47 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;", 48 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;", 49 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;", 50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", 51 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;", 52 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;", 53 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;", 54 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;", 55 | 56 | "gl_FragColor = sum;", 57 | 58 | "}" 59 | 60 | ].join( "\n" ) 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/shaders/HorizontalBlurShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Two pass Gaussian blur filter (horizontal and vertical blur shaders) 5 | * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ 6 | * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html 7 | * 8 | * - 9 samples per pass 9 | * - standard deviation 2.7 10 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height" 11 | */ 12 | 13 | THREE.HorizontalBlurShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { value: null }, 18 | "h": { value: 1.0 / 512.0 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join( "\n" ), 34 | 35 | fragmentShader: [ 36 | 37 | "uniform sampler2D tDiffuse;", 38 | "uniform float h;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "vec4 sum = vec4( 0.0 );", 45 | 46 | "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;", 47 | "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;", 48 | "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;", 49 | "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;", 50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", 51 | "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;", 52 | "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;", 53 | "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;", 54 | "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;", 55 | 56 | "gl_FragColor = sum;", 57 | 58 | "}" 59 | 60 | ].join( "\n" ) 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/shaders/HorizontalBlurShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Two pass Gaussian blur filter (horizontal and vertical blur shaders) 5 | * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ 6 | * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html 7 | * 8 | * - 9 samples per pass 9 | * - standard deviation 2.7 10 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height" 11 | */ 12 | 13 | THREE.HorizontalBlurShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { value: null }, 18 | "h": { value: 1.0 / 512.0 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join( "\n" ), 34 | 35 | fragmentShader: [ 36 | 37 | "uniform sampler2D tDiffuse;", 38 | "uniform float h;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "vec4 sum = vec4( 0.0 );", 45 | 46 | "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;", 47 | "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;", 48 | "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;", 49 | "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;", 50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", 51 | "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;", 52 | "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;", 53 | "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;", 54 | "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;", 55 | 56 | "gl_FragColor = sum;", 57 | 58 | "}" 59 | 60 | ].join( "\n" ) 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /ThreeJSshader1/js/nodes/utils/ColorAdjustmentNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ColorAdjustmentNode = function( rgb, adjustment, method ) { 6 | 7 | THREE.TempNode.call( this, 'v3' ); 8 | 9 | this.rgb = rgb; 10 | this.adjustment = adjustment; 11 | 12 | this.method = method || THREE.ColorAdjustmentNode.SATURATION; 13 | 14 | }; 15 | 16 | THREE.ColorAdjustmentNode.SATURATION = 'saturation'; 17 | THREE.ColorAdjustmentNode.HUE = 'hue'; 18 | THREE.ColorAdjustmentNode.VIBRANCE = 'vibrance'; 19 | THREE.ColorAdjustmentNode.BRIGHTNESS = 'brightness'; 20 | THREE.ColorAdjustmentNode.CONTRAST = 'contrast'; 21 | 22 | THREE.ColorAdjustmentNode.prototype = Object.create( THREE.TempNode.prototype ); 23 | THREE.ColorAdjustmentNode.prototype.constructor = THREE.ColorAdjustmentNode; 24 | 25 | THREE.ColorAdjustmentNode.prototype.generate = function( builder, output ) { 26 | 27 | var rgb = this.rgb.build( builder, 'v3' ); 28 | var adjustment = this.adjustment.build( builder, 'fv1' ); 29 | 30 | var name; 31 | 32 | switch ( this.method ) { 33 | 34 | case THREE.ColorAdjustmentNode.SATURATION: 35 | 36 | name = 'saturation_rgb'; 37 | 38 | break; 39 | 40 | case THREE.ColorAdjustmentNode.HUE: 41 | 42 | name = 'hue_rgb'; 43 | 44 | break; 45 | 46 | case THREE.ColorAdjustmentNode.VIBRANCE: 47 | 48 | name = 'vibrance_rgb'; 49 | 50 | break; 51 | 52 | case THREE.ColorAdjustmentNode.BRIGHTNESS: 53 | 54 | return builder.format( '(' + rgb + '+' + adjustment + ')', this.getType( builder ), output ); 55 | 56 | break; 57 | 58 | case THREE.ColorAdjustmentNode.CONTRAST: 59 | 60 | return builder.format( '(' + rgb + '*' + adjustment + ')', this.getType( builder ), output ); 61 | 62 | break; 63 | 64 | } 65 | 66 | builder.include( name ); 67 | 68 | return builder.format( name + '(' + rgb + ',' + adjustment + ')', this.getType( builder ), output ); 69 | 70 | }; 71 | -------------------------------------------------------------------------------- /ThreeJSshader2/js/nodes/utils/ColorAdjustmentNode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sunag / http://www.sunag.com.br/ 3 | */ 4 | 5 | THREE.ColorAdjustmentNode = function( rgb, adjustment, method ) { 6 | 7 | THREE.TempNode.call( this, 'v3' ); 8 | 9 | this.rgb = rgb; 10 | this.adjustment = adjustment; 11 | 12 | this.method = method || THREE.ColorAdjustmentNode.SATURATION; 13 | 14 | }; 15 | 16 | THREE.ColorAdjustmentNode.SATURATION = 'saturation'; 17 | THREE.ColorAdjustmentNode.HUE = 'hue'; 18 | THREE.ColorAdjustmentNode.VIBRANCE = 'vibrance'; 19 | THREE.ColorAdjustmentNode.BRIGHTNESS = 'brightness'; 20 | THREE.ColorAdjustmentNode.CONTRAST = 'contrast'; 21 | 22 | THREE.ColorAdjustmentNode.prototype = Object.create( THREE.TempNode.prototype ); 23 | THREE.ColorAdjustmentNode.prototype.constructor = THREE.ColorAdjustmentNode; 24 | 25 | THREE.ColorAdjustmentNode.prototype.generate = function( builder, output ) { 26 | 27 | var rgb = this.rgb.build( builder, 'v3' ); 28 | var adjustment = this.adjustment.build( builder, 'fv1' ); 29 | 30 | var name; 31 | 32 | switch ( this.method ) { 33 | 34 | case THREE.ColorAdjustmentNode.SATURATION: 35 | 36 | name = 'saturation_rgb'; 37 | 38 | break; 39 | 40 | case THREE.ColorAdjustmentNode.HUE: 41 | 42 | name = 'hue_rgb'; 43 | 44 | break; 45 | 46 | case THREE.ColorAdjustmentNode.VIBRANCE: 47 | 48 | name = 'vibrance_rgb'; 49 | 50 | break; 51 | 52 | case THREE.ColorAdjustmentNode.BRIGHTNESS: 53 | 54 | return builder.format( '(' + rgb + '+' + adjustment + ')', this.getType( builder ), output ); 55 | 56 | break; 57 | 58 | case THREE.ColorAdjustmentNode.CONTRAST: 59 | 60 | return builder.format( '(' + rgb + '*' + adjustment + ')', this.getType( builder ), output ); 61 | 62 | break; 63 | 64 | } 65 | 66 | builder.include( name ); 67 | 68 | return builder.format( name + '(' + rgb + ',' + adjustment + ')', this.getType( builder ), output ); 69 | 70 | }; 71 | --------------------------------------------------------------------------------