From ac252fa6e6ec8290e7360938876ecb217930c779 Mon Sep 17 00:00:00 2001 From: tamat Date: Wed, 7 Mar 2018 19:27:08 +0100 Subject: [PATCH] fix --- build/litegraph.js | 6 ++++-- build/litegraph.min.js | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build/litegraph.js b/build/litegraph.js index 3dd8c4a90..9f338fe16 100644 --- a/build/litegraph.js +++ b/build/litegraph.js @@ -1815,7 +1815,7 @@ LGraphNode.prototype.trigger = function( action, param ) for(var i = 0; i < this.outputs.length; ++i) { - var output = this.outputs[ slot ]; + var output = this.outputs[ i ]; if(!output || output.type !== LiteGraph.EVENT || (action && output.name != action) ) continue; this.triggerSlot( i, param ); @@ -11966,7 +11966,10 @@ if(typeof(LiteGraph) != "undefined") this.properties = { aberration:1.0, distortion: 1.0, blur: 1.0, precision: LGraphTexture.DEFAULT }; if(!LGraphFXLens._shader) + { LGraphFXLens._shader = new GL.Shader( Shader.SCREEN_VERTEX_SHADER, LGraphFXLens.pixel_shader ); + LGraphFXLens._texture = new GL.Texture(3,1,{ format: gl.RGB, wrap: gl.CLAMP_TO_EDGE, magFilter: gl.LINEAR, minFilter: gl.LINEAR, pixel_data: [255,0,0, 0,255,0, 0,0,255] }); + } } LGraphFXLens.title = "Lens"; @@ -11988,7 +11991,6 @@ if(typeof(LiteGraph) != "undefined") this._tex = LGraphTexture.getTargetTexture( tex, this._tex, this.properties.precision ); - //iterations var aberration = this.properties.aberration; if( this.isInputConnected(1) ) { diff --git a/build/litegraph.min.js b/build/litegraph.min.js index 3def63e87..405e0cb6a 100755 --- a/build/litegraph.min.js +++ b/build/litegraph.min.js @@ -39,7 +39,7 @@ null;if(b.outputs)for(c=0;c=this.inputs.length||null==this.inputs[a].link)){var c=this.graph.links[this.inputs[a].link];if(!c)return null;if(!b)return c.data;var h=this.graph.getNodeById(c.origin_id);if(!h)return c.data;if(h.updateOutputData)h.updateOutputData(c.origin_slot);else if(h.onExecute)h.onExecute();return c.data}};LGraphNode.prototype.isInputConnected=function(a){return this.inputs?a=this.inputs.length)return null;a=this.inputs[a];return a&&a.link?(a=this.graph.links[a.link])?this.graph.getNodeById(a.origin_id):null:null};LGraphNode.prototype.getOutputData=function(a){return!this.outputs||a>=this.outputs.length?null:this.outputs[a]._data};LGraphNode.prototype.getOutputInfo=function(a){return this.outputs?a=this.outputs.length)return null;a=this.outputs[a];if(!a.links||0==a.links.length)return null;for(var b=[],c=0;c=this.size[1]||d.webgl&&(gl.meshes.cube||(gl.meshes.cube=GL.Mesh.cube({size:1})))};LiteGraph.registerNodeType("texture/cubemap",LGraphCubemap)} -if("undefined"!=typeof LiteGraph){var LGraphFXLens=function(){this.addInput("Texture","Texture");this.addInput("Aberration","number");this.addInput("Distortion","number");this.addInput("Blur","number");this.addOutput("Texture","Texture");this.properties={aberration:1,distortion:1,blur:1,precision:LGraphTexture.DEFAULT};LGraphFXLens._shader||(LGraphFXLens._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,LGraphFXLens.pixel_shader))};LGraphFXLens.title="Lens";LGraphFXLens.desc="Camera Lens distortion"; -LGraphFXLens.widgets_info={precision:{widget:"combo",values:LGraphTexture.MODE_VALUES}};LGraphFXLens.prototype.onExecute=function(){var d=this.getInputData(0);if(this.properties.precision===LGraphTexture.PASS_THROUGH)this.setOutputData(0,d);else if(d){this._tex=LGraphTexture.getTargetTexture(d,this._tex,this.properties.precision);var e=this.properties.aberration;this.isInputConnected(1)&&(e=this.getInputData(1),this.properties.aberration=e);var f=this.properties.distortion;this.isInputConnected(2)&& -(f=this.getInputData(2),this.properties.distortion=f);var g=this.properties.blur;this.isInputConnected(3)&&(g=this.getInputData(3),this.properties.blur=g);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var l=Mesh.getScreenQuad(),k=LGraphFXLens._shader;this._tex.drawTo(function(){d.bind(0);k.uniforms({u_texture:0,u_aberration:e,u_distortion:f,u_blur:g}).draw(l)});this.setOutputData(0,this._tex)}};LGraphFXLens.pixel_shader="precision highp float;\n\t\t\tprecision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform vec2 u_camera_planes;\n\t\t\tuniform float u_aberration;\n\t\t\tuniform float u_distortion;\n\t\t\tuniform float u_blur;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec2 coord = v_coord;\n\t\t\t\tfloat dist = distance(vec2(0.5), coord);\n\t\t\t\tvec2 dist_coord = coord - vec2(0.5);\n\t\t\t\tfloat percent = 1.0 + ((0.5 - dist) / 0.5) * u_distortion;\n\t\t\t\tdist_coord *= percent;\n\t\t\t\tcoord = dist_coord + vec2(0.5);\n\t\t\t\tvec4 color = texture2D(u_texture,coord, u_blur * dist);\n\t\t\t\tcolor.r = texture2D(u_texture,vec2(0.5) + dist_coord * (1.0+0.01*u_aberration), u_blur * dist ).r;\n\t\t\t\tcolor.b = texture2D(u_texture,vec2(0.5) + dist_coord * (1.0-0.01*u_aberration), u_blur * dist ).b;\n\t\t\t\tgl_FragColor = color;\n\t\t\t}\n\t\t\t"; +if("undefined"!=typeof LiteGraph){var LGraphFXLens=function(){this.addInput("Texture","Texture");this.addInput("Aberration","number");this.addInput("Distortion","number");this.addInput("Blur","number");this.addOutput("Texture","Texture");this.properties={aberration:1,distortion:1,blur:1,precision:LGraphTexture.DEFAULT};LGraphFXLens._shader||(LGraphFXLens._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,LGraphFXLens.pixel_shader),LGraphFXLens._texture=new GL.Texture(3,1,{format:gl.RGB,wrap:gl.CLAMP_TO_EDGE, +magFilter:gl.LINEAR,minFilter:gl.LINEAR,pixel_data:[255,0,0,0,255,0,0,0,255]}))};LGraphFXLens.title="Lens";LGraphFXLens.desc="Camera Lens distortion";LGraphFXLens.widgets_info={precision:{widget:"combo",values:LGraphTexture.MODE_VALUES}};LGraphFXLens.prototype.onExecute=function(){var d=this.getInputData(0);if(this.properties.precision===LGraphTexture.PASS_THROUGH)this.setOutputData(0,d);else if(d){this._tex=LGraphTexture.getTargetTexture(d,this._tex,this.properties.precision);var e=this.properties.aberration; +this.isInputConnected(1)&&(e=this.getInputData(1),this.properties.aberration=e);var f=this.properties.distortion;this.isInputConnected(2)&&(f=this.getInputData(2),this.properties.distortion=f);var g=this.properties.blur;this.isInputConnected(3)&&(g=this.getInputData(3),this.properties.blur=g);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var l=Mesh.getScreenQuad(),k=LGraphFXLens._shader;this._tex.drawTo(function(){d.bind(0);k.uniforms({u_texture:0,u_aberration:e,u_distortion:f,u_blur:g}).draw(l)}); +this.setOutputData(0,this._tex)}};LGraphFXLens.pixel_shader="precision highp float;\n\t\t\tprecision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform vec2 u_camera_planes;\n\t\t\tuniform float u_aberration;\n\t\t\tuniform float u_distortion;\n\t\t\tuniform float u_blur;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec2 coord = v_coord;\n\t\t\t\tfloat dist = distance(vec2(0.5), coord);\n\t\t\t\tvec2 dist_coord = coord - vec2(0.5);\n\t\t\t\tfloat percent = 1.0 + ((0.5 - dist) / 0.5) * u_distortion;\n\t\t\t\tdist_coord *= percent;\n\t\t\t\tcoord = dist_coord + vec2(0.5);\n\t\t\t\tvec4 color = texture2D(u_texture,coord, u_blur * dist);\n\t\t\t\tcolor.r = texture2D(u_texture,vec2(0.5) + dist_coord * (1.0+0.01*u_aberration), u_blur * dist ).r;\n\t\t\t\tcolor.b = texture2D(u_texture,vec2(0.5) + dist_coord * (1.0-0.01*u_aberration), u_blur * dist ).b;\n\t\t\t\tgl_FragColor = color;\n\t\t\t}\n\t\t\t"; LiteGraph.registerNodeType("fx/lens",LGraphFXLens);window.LGraphFXLens=LGraphFXLens;var LGraphFXBokeh=function(){this.addInput("Texture","Texture");this.addInput("Blurred","Texture");this.addInput("Mask","Texture");this.addInput("Threshold","number");this.addOutput("Texture","Texture");this.properties={shape:"",size:10,alpha:1,threshold:1,high_precision:!1}};LGraphFXBokeh.title="Bokeh";LGraphFXBokeh.desc="applies an Bokeh effect";LGraphFXBokeh.widgets_info={shape:{widget:"texture"}};LGraphFXBokeh.prototype.onExecute= function(){var d=this.getInputData(0),e=this.getInputData(1),f=this.getInputData(2);if(d&&f&&this.properties.shape){e||(e=d);var g=LGraphTexture.getTexture(this.properties.shape);if(g){var l=this.properties.threshold;this.isInputConnected(3)&&(l=this.getInputData(3),this.properties.threshold=l);var k=gl.UNSIGNED_BYTE;this.properties.high_precision&&(k=gl.half_float_ext?gl.HALF_FLOAT_OES:gl.FLOAT);this._temp_texture&&this._temp_texture.type==k&&this._temp_texture.width==d.width&&this._temp_texture.height== d.height||(this._temp_texture=new GL.Texture(d.width,d.height,{type:k,format:gl.RGBA,filter:gl.LINEAR}));var a=LGraphFXBokeh._first_shader;a||(a=LGraphFXBokeh._first_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,LGraphFXBokeh._first_pixel_shader));var b=LGraphFXBokeh._second_shader;b||(b=LGraphFXBokeh._second_shader=new GL.Shader(LGraphFXBokeh._second_vertex_shader,LGraphFXBokeh._second_pixel_shader));var c=this._points_mesh;c&&c._width==d.width&&c._height==d.height&&2==c._spacing||(c=this.createPointsMesh(d.width,