diff --git a/src/litegraph.js b/src/litegraph.js index f6022c417..5d3d293f1 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -480,7 +480,7 @@ }, registerSearchboxExtra: function(node_type, description, data) { - this.searchbox_extras[description] = { + this.searchbox_extras[description.toLowerCase()] = { type: node_type, desc: description, data: data @@ -9109,7 +9109,7 @@ LGraphNode.prototype.executeAction = function(action) if (that.onSearchBoxSelection) { that.onSearchBoxSelection(name, event, graphcanvas); } else { - var extra = LiteGraph.searchbox_extras[name]; + var extra = LiteGraph.searchbox_extras[name.toLowerCase()]; if (extra) { name = extra.type; } @@ -9125,10 +9125,7 @@ LGraphNode.prototype.executeAction = function(action) if (extra && extra.data) { if (extra.data.properties) { for (var i in extra.data.properties) { - node.addProperty( - extra.data.properties[i][0], - extra.data.properties[i][0] - ); + node.addProperty( i, extra.data.properties[i] ); } } if (extra.data.inputs) { diff --git a/src/nodes/gltextures.js b/src/nodes/gltextures.js index 5424e6909..dd2639c52 100755 --- a/src/nodes/gltextures.js +++ b/src/nodes/gltextures.js @@ -470,8 +470,7 @@ this.addInput("TextureB", "Texture"); this.addInput("value", "number"); this.addOutput("Texture", "Texture"); - this.help = - "

pixelcode must be vec3, uvcode must be vec2, is optional

\ + this.help = "

pixelcode must be vec3, uvcode must be vec2, is optional

\

uv: tex. coords

color: texture colorB: textureB

time: scene time value: input value

For multiline you must type: result = ...

"; this.properties = { @@ -845,10 +844,7 @@ } var uniforms = this._uniforms; - var type = LGraphTexture.getTextureType( - this.properties.precision, - in_tex - ); + var type = LGraphTexture.getTextureType( this.properties.precision, in_tex ); //render to texture var w = this.properties.width | 0; @@ -920,10 +916,7 @@ var width = tex.width; var height = tex.height; - var type = - this.precision === LGraphTexture.LOW - ? gl.UNSIGNED_BYTE - : gl.HIGH_PRECISION_FORMAT; + var type = this.precision === LGraphTexture.LOW ? gl.UNSIGNED_BYTE : gl.HIGH_PRECISION_FORMAT; if (this.precision === LGraphTexture.DEFAULT) { type = tex.type; } @@ -4387,6 +4380,7 @@ code: "", width: 512, height: 512, + clear: true, precision: LGraphTexture.DEFAULT }; this._func = null; @@ -4394,8 +4388,8 @@ } LGraphTextureCanvas2D.title = "Canvas2D"; - LGraphTextureCanvas2D.desc = - "Executes Canvas2D code inside a texture or the viewport"; + LGraphTextureCanvas2D.desc = "Executes Canvas2D code inside a texture or the viewport."; + LGraphTextureCanvas2D.help = "Set width and height to 0 to match viewport size."; LGraphTextureCanvas2D.widgets_info = { precision: { widget: "combo", values: LGraphTexture.MODE_VALUES }, @@ -4411,13 +4405,7 @@ if (name == "code" && LiteGraph.allow_scripts) { this._func = null; try { - this._func = new Function( - "canvas", - "ctx", - "time", - "script", - value - ); + this._func = new Function( "canvas", "ctx", "time", "script", value ); this.boxcolor = "#00FF00"; } catch (err) { this.boxcolor = "#FF0000"; @@ -4443,17 +4431,26 @@ var width = this.properties.width || gl.canvas.width; var height = this.properties.height || gl.canvas.height; var temp = this._temp_texture; - if (!temp || temp.width != width || temp.height != height) { + var type = LGraphTexture.getTextureType( this.properties.precision ); + if (!temp || temp.width != width || temp.height != height || temp.type != type ) { temp = this._temp_texture = new GL.Texture(width, height, { format: gl.RGBA, - filter: gl.LINEAR + filter: gl.LINEAR, + type: type }); } + var properties = this.properties; var that = this; var time = this.graph.getTime(); temp.drawTo(function() { gl.start2D(); + if(properties.clear) + { + gl.clearColor(0,0,0,0); + gl.clear( gl.COLOR_BUFFER_BIT ); + } + try { if (func.draw) { func.draw.call(that, gl.canvas, gl, time, func); @@ -4474,6 +4471,8 @@ LiteGraph.registerNodeType("texture/canvas2D", LGraphTextureCanvas2D); + // To do chroma keying ***************** + function LGraphTextureMatte() { this.addInput("in", "Texture"); diff --git a/src/nodes/math.js b/src/nodes/math.js index e8f1d7410..817472dd1 100755 --- a/src/nodes/math.js +++ b/src/nodes/math.js @@ -584,9 +584,9 @@ this.addProperty("OP", "+", "enum", { values: MathOperation.values }); } - MathOperation.values = ["+", "-", "*", "/", "%", "^"]; + MathOperation.values = ["+", "-", "*", "/", "%", "^", "max", "min"]; - MathOperation.title = "Operation"; + MathOperation.title = "Operation"; MathOperation.desc = "Easy math operators"; MathOperation["@OP"] = { type: "enum", @@ -596,6 +596,8 @@ MathOperation.size = [100, 60]; MathOperation.prototype.getTitle = function() { + if(this.properties.OP == "max" || this.properties.OP == "min") + return this.properties.OP + "(A,B)"; return "A " + this.properties.OP + " B"; }; @@ -643,6 +645,12 @@ case "^": result = Math.pow(A, B); break; + case "max": + result = Math.max(A, B); + break; + case "min": + result = Math.min(A, B); + break; default: console.warn("Unknown operation: " + this.properties.OP); } @@ -667,6 +675,16 @@ LiteGraph.registerNodeType("math/operation", MathOperation); + LiteGraph.registerSearchboxExtra("math/operation", "MAX", { + properties: {OP:"max"}, + title: "MAX()" + }); + + LiteGraph.registerSearchboxExtra("math/operation", "MIN", { + properties: {OP:"min"}, + title: "MIN()" + }); + //Math compare function MathCompare() { this.addInput("A", "number"); @@ -864,7 +882,7 @@ MathTrigonometry.title = "Trigonometry"; MathTrigonometry.desc = "Sin Cos Tan"; - MathTrigonometry.filter = "shader"; + //MathTrigonometry.filter = "shader"; MathTrigonometry.prototype.onExecute = function() { var v = this.getInputData(0);