diff --git a/build/litegraph.js b/build/litegraph.js
index 0fd7b38f4..ffc33fffe 100644
--- a/build/litegraph.js
+++ b/build/litegraph.js
@@ -6117,7 +6117,7 @@ LGraphNode.prototype.executeAction = function(action)
this.adjustMouseEvent(e);
var pos = [e.canvasX, e.canvasY];
- var node = this.graph.getNodeOnPos(pos[0], pos[1]);
+ var node = this.graph ? this.graph.getNodeOnPos(pos[0], pos[1]) : null;
if (!node) {
var r = null;
@@ -8414,7 +8414,7 @@ LGraphNode.prototype.executeAction = function(action)
break;
default:
if (w.draw) {
- w.draw(ctx, node, w, y, H);
+ w.draw(ctx, node, width, y, H);
}
break;
}
@@ -13970,6 +13970,10 @@ if (typeof exports != "undefined") {
this.addProperty("min", 0);
this.addProperty("max", 1);
this.addProperty("smooth", true);
+ this.addProperty("seed", 0);
+ this.addProperty("octaves", 1);
+ this.addProperty("persistence", 0.8);
+ this.addProperty("speed", 1);
this.size = [90, 30];
}
@@ -14000,7 +14004,22 @@ if (typeof exports != "undefined") {
MathNoise.prototype.onExecute = function() {
var f = this.getInputData(0) || 0;
- var r = MathNoise.getValue(f, this.properties.smooth);
+ var iterations = this.properties.octaves || 1;
+ var r = 0;
+ var amp = 1;
+ var seed = this.properties.seed || 0;
+ f += seed;
+ var speed = this.properties.speed || 1;
+ var total_amp = 0;
+ for(var i = 0; i < iterations; ++i)
+ {
+ r += MathNoise.getValue(f * (1+i) * speed, this.properties.smooth) * amp;
+ total_amp += amp;
+ amp *= this.properties.persistence;
+ if(amp < 0.001)
+ break;
+ }
+ r /= total_amp;
var min = this.properties.min;
var max = this.properties.max;
this._last_v = r * (max - min) + min;
@@ -20890,7 +20909,7 @@ void main(void){\n\
LiteGraph.registerNodeType("texture/lensfx", LGraphLensFX);
-
+ //applies a curve (or generates one)
function LGraphTextureCurve() {
this.addInput("in", "Texture");
this.addOutput("out", "Texture");
@@ -20914,21 +20933,32 @@ void main(void){\n\
}
LGraphTextureCurve.title = "Curve";
+ LGraphTextureCurve.desc = "Generates or applies a curve to a texture";
+ LGraphTextureCurve.widgets_info = {
+ precision: { widget: "combo", values: LGraphTexture.MODE_VALUES }
+ };
LGraphTextureCurve.prototype.onExecute = function() {
- var tex = this.getInputData(0);
- if (!tex) {
- return;
- }
-
if (!this.isOutputConnected(0)) {
return;
} //saves work
+ var tex = this.getInputData(0);
+
var temp = this._temp_texture;
- if ( !temp || temp.width != tex.width || temp.height != tex.height || temp.type != tex.type ) {
- temp = this._temp_texture = new GL.Texture( tex.width, tex.height, { type: tex.type, format: gl.RGBA, filter: gl.LINEAR } );
+ var type = LGraphTexture.getTextureType(this.properties.precision);
+
+ if(!tex) //generate one texture, nothing else
+ {
+ if(this._must_update || !this._curve_texture )
+ this.updateCurve();
+ this.setOutputData(0, this._curve_texture);
+ return;
}
+
+ //apply curve to input texture
+ if ( !temp || temp.type != type )
+ temp = this._temp_texture = new GL.Texture( 256, 1, { type: type, format: gl.RGBA, filter: gl.LINEAR } );
var shader = LGraphTextureCurve._shader;
if (!shader) {
diff --git a/demo/index.html b/demo/index.html
index 24667f13b..01dce5054 100755
--- a/demo/index.html
+++ b/demo/index.html
@@ -31,6 +31,7 @@
+
diff --git a/demo/js/code.js b/demo/js/code.js
index cf7fd00bf..7038567a6 100644
--- a/demo/js/code.js
+++ b/demo/js/code.js
@@ -1,7 +1,7 @@
var webgl_canvas = null;
LiteGraph.node_images_path = "../nodes_data/";
-var editor = new LiteGraph.Editor("main");
+var editor = new LiteGraph.Editor("main",{miniwindow:true});
window.graphcanvas = editor.graphcanvas;
window.graph = editor.graph;
window.addEventListener("resize", function() { editor.graphcanvas.resize(); } );
diff --git a/src/litegraph-editor.js b/src/litegraph-editor.js
index 8f300e11e..25a40f7bf 100755
--- a/src/litegraph-editor.js
+++ b/src/litegraph-editor.js
@@ -504,7 +504,7 @@ Editor.prototype.addMiniWindow = function(w, h) {
var close_button = document.createElement("div");
close_button.className = "corner-button";
- close_button.innerHTML = "X";
+ close_button.innerHTML = "❌";
close_button.addEventListener("click", function(e) {
graphcanvas.setGraph(null);
miniwindow.parentNode.removeChild(miniwindow);
diff --git a/src/litegraph.js b/src/litegraph.js
index 94a2058b3..8aa5e09e1 100755
--- a/src/litegraph.js
+++ b/src/litegraph.js
@@ -6115,7 +6115,7 @@ LGraphNode.prototype.executeAction = function(action)
this.adjustMouseEvent(e);
var pos = [e.canvasX, e.canvasY];
- var node = this.graph.getNodeOnPos(pos[0], pos[1]);
+ var node = this.graph ? this.graph.getNodeOnPos(pos[0], pos[1]) : null;
if (!node) {
var r = null;
@@ -8412,7 +8412,7 @@ LGraphNode.prototype.executeAction = function(action)
break;
default:
if (w.draw) {
- w.draw(ctx, node, w, y, H);
+ w.draw(ctx, node, width, y, H);
}
break;
}
diff --git a/src/nodes/gltextures.js b/src/nodes/gltextures.js
index 1080a2122..3771b5f36 100755
--- a/src/nodes/gltextures.js
+++ b/src/nodes/gltextures.js
@@ -4259,7 +4259,7 @@ void main(void){\n\
LiteGraph.registerNodeType("texture/lensfx", LGraphLensFX);
-
+ //applies a curve (or generates one)
function LGraphTextureCurve() {
this.addInput("in", "Texture");
this.addOutput("out", "Texture");
@@ -4283,21 +4283,32 @@ void main(void){\n\
}
LGraphTextureCurve.title = "Curve";
+ LGraphTextureCurve.desc = "Generates or applies a curve to a texture";
+ LGraphTextureCurve.widgets_info = {
+ precision: { widget: "combo", values: LGraphTexture.MODE_VALUES }
+ };
LGraphTextureCurve.prototype.onExecute = function() {
- var tex = this.getInputData(0);
- if (!tex) {
- return;
- }
-
if (!this.isOutputConnected(0)) {
return;
} //saves work
+ var tex = this.getInputData(0);
+
var temp = this._temp_texture;
- if ( !temp || temp.width != tex.width || temp.height != tex.height || temp.type != tex.type ) {
- temp = this._temp_texture = new GL.Texture( tex.width, tex.height, { type: tex.type, format: gl.RGBA, filter: gl.LINEAR } );
+ var type = LGraphTexture.getTextureType(this.properties.precision);
+
+ if(!tex) //generate one texture, nothing else
+ {
+ if(this._must_update || !this._curve_texture )
+ this.updateCurve();
+ this.setOutputData(0, this._curve_texture);
+ return;
}
+
+ //apply curve to input texture
+ if ( !temp || temp.type != type )
+ temp = this._temp_texture = new GL.Texture( 256, 1, { type: type, format: gl.RGBA, filter: gl.LINEAR } );
var shader = LGraphTextureCurve._shader;
if (!shader) {
diff --git a/src/nodes/math.js b/src/nodes/math.js
index 2761eafa8..cfc7cd02d 100755
--- a/src/nodes/math.js
+++ b/src/nodes/math.js
@@ -236,6 +236,10 @@
this.addProperty("min", 0);
this.addProperty("max", 1);
this.addProperty("smooth", true);
+ this.addProperty("seed", 0);
+ this.addProperty("octaves", 1);
+ this.addProperty("persistence", 0.8);
+ this.addProperty("speed", 1);
this.size = [90, 30];
}
@@ -266,7 +270,22 @@
MathNoise.prototype.onExecute = function() {
var f = this.getInputData(0) || 0;
- var r = MathNoise.getValue(f, this.properties.smooth);
+ var iterations = this.properties.octaves || 1;
+ var r = 0;
+ var amp = 1;
+ var seed = this.properties.seed || 0;
+ f += seed;
+ var speed = this.properties.speed || 1;
+ var total_amp = 0;
+ for(var i = 0; i < iterations; ++i)
+ {
+ r += MathNoise.getValue(f * (1+i) * speed, this.properties.smooth) * amp;
+ total_amp += amp;
+ amp *= this.properties.persistence;
+ if(amp < 0.001)
+ break;
+ }
+ r /= total_amp;
var min = this.properties.min;
var max = this.properties.max;
this._last_v = r * (max - min) + min;