[Anisotropic Noise] Add separate random color seed.

This commit is contained in:
Tanasart 2024-09-23 18:27:31 +07:00
parent d9f8d006b7
commit 51d30d1115
17 changed files with 73 additions and 41 deletions

View file

@ -337,7 +337,8 @@ function shader_set_gradient(gradient, surface, range, junc) {
var t = shader_set_surface("gradient_map", surface); var t = shader_set_surface("gradient_map", surface);
gpu_set_tex_filter_ext(t, true); gpu_set_tex_filter_ext(t, true);
gradient.shader_submit(); if(is_instanceof(gradient, gradientObject))
gradient.shader_submit();
} }
function evaluate_gradient_map(_x, gradient, surface, range, junc, fast = false) { function evaluate_gradient_map(_x, gradient, surface, range, junc, fast = false) {

View file

@ -6,11 +6,11 @@ function Node_Application_In(_x, _y, _group = noone) : Node(_x, _y, _group) cons
APP_SURF_OVERRIDE = true; APP_SURF_OVERRIDE = true;
static step = function() { #region static step = function() {
LIVE_UPDATE = true; LIVE_UPDATE = true;
} #endregion }
static update = function() { #region static update = function() {
var s = inputs[0].getValue(); var s = inputs[0].getValue();
if(!is_surface(s)) return; if(!is_surface(s)) return;
@ -20,5 +20,5 @@ function Node_Application_In(_x, _y, _group = noone) : Node(_x, _y, _group) cons
draw_surface_stretched(s, 0, 0, WIN_W, WIN_H); draw_surface_stretched(s, 0, 0, WIN_W, WIN_H);
BLEND_NORMAL BLEND_NORMAL
surface_reset_target(); surface_reset_target();
} #endregion }
} }

View file

@ -12,11 +12,11 @@ function Node_Application_Out(_x, _y, _group = noone) : Node(_x, _y, _group) con
APP_SURF_OVERRIDE = true; APP_SURF_OVERRIDE = true;
static step = function() { #region static step = function() {
LIVE_UPDATE = true; LIVE_UPDATE = true;
} #endregion }
static update = function() { #region static update = function() {
outputs[0].setValue(PRE_APP_SURF); outputs[0].setValue(PRE_APP_SURF);
} #endregion }
} }

View file

@ -18,8 +18,7 @@ function Node_Atlas_Draw(_x, _y, _group = noone) : Node(_x, _y, _group) construc
if(atl == noone) return; if(atl == noone) return;
if(is_array(atl) && array_length(atl) == 0) return; if(is_array(atl) && array_length(atl) == 0) return;
if(!is_array(atl)) if(!is_array(atl)) atl = [ atl ];
atl = [ atl ];
var outSurf = outputs[0].getValue(); var outSurf = outputs[0].getValue();
outSurf = surface_verify(outSurf, dim[0], dim[1]); outSurf = surface_verify(outSurf, dim[0], dim[1]);
@ -27,8 +26,11 @@ function Node_Atlas_Draw(_x, _y, _group = noone) : Node(_x, _y, _group) construc
surface_set_shader(outSurf,,, BLEND.alpha); surface_set_shader(outSurf,,, BLEND.alpha);
for( var i = 0, n = array_length(atl); i < n; i++ ) { for( var i = 0, n = array_length(atl); i < n; i++ ) {
shader_set_interpolation(atl[i].getSurface()) var _a = atl[i];
atl[i].draw(); if(!is_instanceof(_a, Atlas)) continue;
shader_set_interpolation(_a.getSurface())
_a.draw();
} }
surface_reset_shader(); surface_reset_shader();
} }

View file

@ -70,11 +70,9 @@ function Node_Feedback_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) con
if(!junc_in || !junc_out) return noone; if(!junc_in || !junc_out) return noone;
if(!junc_in.node.active || !junc_out.node.active) return noone; if(!junc_in.node.active || !junc_out.node.active) return noone;
params.dashed = true; params.dashed = true; params.loop = true;
params.loop = true;
drawJuncConnection(junc_out, junc_in, params); drawJuncConnection(junc_out, junc_in, params);
params.dashed = false; params.dashed = false; params.loop = false;
params.loop = false;
return noone; return noone;
} }

View file

@ -92,7 +92,10 @@ function Node_Iterate_Inline(_x, _y, _group = noone) : Node_Collection_Inline(_x
if(!junc_in || !junc_out) return noone; if(!junc_in || !junc_out) return noone;
if(!junc_in.node.active || !junc_out.node.active) return noone; if(!junc_in.node.active || !junc_out.node.active) return noone;
params.dashed = true; params.loop = true;
drawJuncConnection(junc_out, junc_in, params); drawJuncConnection(junc_out, junc_in, params);
params.dashed = false; params.loop = false;
return noone; return noone;
} }

View file

@ -17,7 +17,7 @@ function Node_Iterator_Each_Inline_Input(_x, _y, _group = noone) : Node(_x, _y,
array_push(arr, loop); array_push(arr, loop);
} }
static update = function() { #region static update = function() {
if(!is_instanceof(loop, Node_Iterate_Each_Inline)) return; if(!is_instanceof(loop, Node_Iterate_Each_Inline)) return;
var _typ = inputs[0].value_from == noone? VALUE_TYPE.any : inputs[0].value_from.type; var _typ = inputs[0].value_from == noone? VALUE_TYPE.any : inputs[0].value_from.type;
@ -30,5 +30,5 @@ function Node_Iterator_Each_Inline_Input(_x, _y, _group = noone) : Node(_x, _y,
if(!is_array(val)) return; if(!is_array(val)) return;
outputs[0].setValue(array_safe_get_fast(val, itr)); outputs[0].setValue(array_safe_get_fast(val, itr));
} #endregion }
} }

View file

@ -30,10 +30,13 @@ function Node_Noise_Aniso(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
newInput(9, nodeValue_Enum_Scroll("Render mode", self, 0, [ "Blend", "Waterfall" ] )) newInput(9, nodeValue_Enum_Scroll("Render mode", self, 0, [ "Blend", "Waterfall" ] ))
newInput(10, nodeValue_Float("Color Seed", self, seed_random(6)))
.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[2].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
input_display_list = [ input_display_list = [
["Output", false], 0, ["Output", false], 0,
["Noise", false], 2, 1, 6, 5, 7, 3, 4, 8, ["Noise", false], 2, 1, 6, 5, 7, 3, 4, 8,
["Render", false], 9, ["Render", false], 9, 10,
]; ];
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone)); newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
@ -47,27 +50,31 @@ function Node_Noise_Aniso(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
return _hov; return _hov;
} }
static step = function() { #region static step = function() {
inputs[1].mappableStep(); inputs[1].mappableStep();
inputs[4].mappableStep(); inputs[4].mappableStep();
inputs[5].mappableStep(); inputs[5].mappableStep();
} #endregion }
static processData = function(_outSurf, _data, _output_index, _array_index) { static processData = function(_outSurf, _data, _output_index, _array_index) {
var _dim = _data[0]; var _dim = _data[0];
var _pos = _data[3]; var _pos = _data[3];
var _mod = _data[9];
inputs[10].setVisible(_mod == 0);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_ani_noise); surface_set_shader(_outSurf, sh_ani_noise);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]); shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("seed", _data[2]); shader_set_f("seed", _data[2]);
shader_set_f("colrSeed", _data[10]);
shader_set_f_map("noiseX", _data[1], _data[6], inputs[1]); shader_set_f_map("noiseX", _data[1], _data[6], inputs[1]);
shader_set_f_map("noiseY", _data[5], _data[7], inputs[5]); shader_set_f_map("noiseY", _data[5], _data[7], inputs[5]);
shader_set_f_map("angle", _data[4], _data[8], inputs[4]); shader_set_f_map("angle", _data[4], _data[8], inputs[4]);
shader_set_i("mode", _data[9]); shader_set_i("mode", _mod);
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]); draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
surface_reset_shader(); surface_reset_shader();

View file

@ -65,9 +65,12 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
static getDimension = function(arr = 0) { static getDimension = function(arr = 0) {
if(dimension_index == -1) return [ 1, 1 ]; if(dimension_index == -1) return [ 1, 1 ];
var _ip = array_safe_get(inputs, dimension_index, noone);
if(_ip == noone) return [ 1, 1 ];
var _in = getSingleValue(dimension_index, arr); var _in = getSingleValue(dimension_index, arr);
if(inputs[dimension_index].type == VALUE_TYPE.surface && is_surface(_in)) { if(_ip.type == VALUE_TYPE.surface && is_surface(_in)) {
var ww = surface_get_width_safe(_in); var ww = surface_get_width_safe(_in);
var hh = surface_get_height_safe(_in); var hh = surface_get_height_safe(_in);
return [ww, hh]; return [ww, hh];

View file

@ -18,6 +18,7 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
show_in_global = true; show_in_global = true;
is_patreon_extra = false; is_patreon_extra = false;
testable = true;
_fn = registerFunctionLite("New node", _name, function(_node) { PANEL_GRAPH.createNodeHotkey(_node); }, [ _node ]); _fn = registerFunctionLite("New node", _name, function(_node) { PANEL_GRAPH.createNodeHotkey(_node); }, [ _node ]);
_fn.spr = _spr; _fn.spr = _spr;
@ -72,10 +73,13 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
if(IS_CMD) return self; if(IS_CMD) return self;
show_in_recent = false; show_in_recent = false;
testable = false;
variable_struct_remove(FUNCTIONS, _fn.fnName); variable_struct_remove(FUNCTIONS, _fn.fnName);
return self; return self;
} }
static notTest = function() { testable = false; return self; }
static hideGlobal = function() { static hideGlobal = function() {
INLINE INLINE
if(IS_CMD) return self; if(IS_CMD) return self;
@ -539,7 +543,7 @@ function __initNodes() {
addNodeObject(input, "Websocket Receiver", s_node_websocket_receive, "Node_Websocket_Receiver", [1, Node_Websocket_Receiver],, "Create websocket server to receive data from the network.").setVersion(1145); addNodeObject(input, "Websocket Receiver", s_node_websocket_receive, "Node_Websocket_Receiver", [1, Node_Websocket_Receiver],, "Create websocket server to receive data from the network.").setVersion(1145);
addNodeObject(input, "Websocket Sender", s_node_websocket_send, "Node_Websocket_Sender", [1, Node_Websocket_Sender],, "Create websocket server to send data to the network.").setVersion(1145); addNodeObject(input, "Websocket Sender", s_node_websocket_send, "Node_Websocket_Sender", [1, Node_Websocket_Sender],, "Create websocket server to send data to the network.").setVersion(1145);
addNodeObject(input, "Spout Sender", s_node_spout, "Node_Spout_Send", [1, Node_Spout_Send],, "Send surface through Spout.").setVersion(11600); addNodeObject(input, "Spout Sender", s_node_spout, "Node_Spout_Send", [1, Node_Spout_Send],, "Send surface through Spout.").setVersion(11600);
addNodeObject(input, "MIDI In", s_node_midi, "Node_MIDI_In", [1, Node_MIDI_In],, "Receive MIDI message.").setVersion(11630); addNodeObject(input, "MIDI In", s_node_midi, "Node_MIDI_In", [1, Node_MIDI_In],, "Receive MIDI message.").setVersion(11630).notTest();
addNodeObject(input, "HTTP", s_node_http, "Node_HTTP_request", [1, Node_HTTP_request],, "Request data from the internet.").setVersion(11780); addNodeObject(input, "HTTP", s_node_http, "Node_HTTP_request", [1, Node_HTTP_request],, "Request data from the internet.").setVersion(11780);
#endregion #endregion
@ -1082,9 +1086,9 @@ function __initNodes() {
addNodeObject(node, "Argument", s_node_argument, "Node_Argument", [1, Node_Argument]).setVersion(11660); addNodeObject(node, "Argument", s_node_argument, "Node_Argument", [1, Node_Argument]).setVersion(11660);
addNodeObject(node, "Terminal trigger", s_node_terminal_trigger, "Node_Terminal_Trigger", [1, Node_Terminal_Trigger]).setVersion(11660); addNodeObject(node, "Terminal trigger", s_node_terminal_trigger, "Node_Terminal_Trigger", [1, Node_Terminal_Trigger]).setVersion(11660);
addNodeObject(node, "Execute Shell", s_node_shell_excecute, "Node_Shell", [1, Node_Shell], ["terminal", "execute", "run"], "Execute shell script.").setVersion(11530); addNodeObject(node, "Execute Shell", s_node_shell_excecute, "Node_Shell", [1, Node_Shell], ["terminal", "execute", "run"], "Execute shell script.").setVersion(11530);
addNodeObject(node, "Monitor Capture", s_node_monitor_capture, "Node_Monitor_Capture", [1, Node_Monitor_Capture]); addNodeObject(node, "Monitor Capture", s_node_monitor_capture, "Node_Monitor_Capture", [1, Node_Monitor_Capture]).notTest();
addNodeObject(node, "GUI In", s_node_gui_in, "Node_Application_In", [1, Node_Application_In]); addNodeObject(node, "GUI In", s_node_gui_in, "Node_Application_In", [1, Node_Application_In]).notTest();
addNodeObject(node, "GUI Out", s_node_gui_out, "Node_Application_Out", [1, Node_Application_Out]); addNodeObject(node, "GUI Out", s_node_gui_out, "Node_Application_Out", [1, Node_Application_Out]).notTest();
// addNodeObject(node, "DLL", s_node_gui_out, "Node_DLL", [1, Node_DLL]).setVersion(11750); // addNodeObject(node, "DLL", s_node_gui_out, "Node_DLL", [1, Node_DLL]).setVersion(11750);
#endregion #endregion

View file

@ -2384,7 +2384,6 @@ function drawJuncConnection(from, to, params) {
to.draw_line_shift_hover = false; to.draw_line_shift_hover = false;
var downDirection = to.type == VALUE_TYPE.action || from.type == VALUE_TYPE.action; var downDirection = to.type == VALUE_TYPE.action || from.type == VALUE_TYPE.action;
// if(downDirection) print($"{to} : {from}");
#endregion #endregion
#region +++++ CHECK HOVER +++++ #region +++++ CHECK HOVER +++++

View file

@ -297,7 +297,7 @@ function Panel_Collection() : PanelContent() constructor {
} }
if(_node.path == updated_path && updated_prog > 0) if(_node.path == updated_path && updated_prog > 0)
draw_sprite_stretched_ext(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size, COLORS._main_value_positive, updated_prog); draw_sprite_stretched_ext(THEME.node_bg, 1, _boxx, yy, grid_size, grid_size, COLORS._main_value_positive, updated_prog * 2);
if(variable_struct_exists(_node, "getSpr")) _node.getSpr(); if(variable_struct_exists(_node, "getSpr")) _node.getSpr();

View file

@ -238,8 +238,12 @@ function Render(partial = false, runAction = false) { #region
var nextNodes = rendering.getNextNodes(); var nextNodes = rendering.getNextNodes();
for( var i = 0, n = array_length(nextNodes); i < n; i++ ) { for( var i = 0, n = array_length(nextNodes); i < n; i++ ) {
if(nextNodes[i].isRenderable()) var nextNode = nextNodes[i];
RENDER_QUEUE.enqueue(nextNodes[i]);
if(!is_instanceof(nextNode, __Node_Base)) continue;
if(!nextNode.isRenderable()) continue;
RENDER_QUEUE.enqueue(nextNode);
} }
if(runAction && rendering.hasInspector1Update()) if(runAction && rendering.hasInspector1Update())

View file

@ -133,7 +133,12 @@ function __test_load_all_nodes() {
if(index > inded) break; if(index > inded) break;
if(index > indst) { if(index > indst) {
var node = ALL_NODES[? k]; var node = ALL_NODES[? k];
k = ds_map_find_next(ALL_NODES, k);
if(!node.testable) continue;
print($"==== Building {node.node} ===="); print($"==== Building {node.node} ====");
var b = node.build(xx, yy); var b = node.build(xx, yy);
if(++ind > col) { if(++ind > col) {
@ -153,7 +158,6 @@ function __test_load_all_nodes() {
} }
index++; index++;
k = ds_map_find_next(ALL_NODES, k);
} }
LOADING = false; LOADING = false;
} }

View file

@ -410,8 +410,11 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
clipboard_set_text(string_copy(_input_text, minc + 1, maxc - minc)); clipboard_set_text(string_copy(_input_text, minc + 1, maxc - minc));
} }
} else { } else {
if(key_mod_press(CTRL) && keyboard_check_pressed(ord("V"))) if(key_mod_press(CTRL) && keyboard_check_pressed(ord("V"))) {
KEYBOARD_STRING = clipboard_get_text(); var _ctxt = clipboard_get_text();
_ctxt = string_replace_all(_ctxt, "\t", " ");
KEYBOARD_STRING = _ctxt;
}
if(keyboard_check_pressed(vk_escape)) { if(keyboard_check_pressed(vk_escape)) {
} else if(keyboard_check_pressed(vk_tab)) { } else if(keyboard_check_pressed(vk_tab)) {

View file

@ -207,7 +207,9 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
} }
} else { } else {
if(key_mod_press(CTRL) && keyboard_check_pressed(ord("V"))) { if(key_mod_press(CTRL) && keyboard_check_pressed(ord("V"))) {
KEYBOARD_STRING = clipboard_get_text(); var _ctxt = clipboard_get_text();
_ctxt = string_replace_all(_ctxt, "\t", " ");
KEYBOARD_STRING = _ctxt;
edited = true; edited = true;
} }

View file

@ -2,6 +2,7 @@ varying vec2 v_vTexcoord;
varying vec4 v_vColour; varying vec4 v_vColour;
uniform float seed; uniform float seed;
uniform float colrSeed;
uniform vec2 position; uniform vec2 position;
uniform int mode; uniform int mode;
@ -17,9 +18,9 @@ uniform vec2 angle;
uniform int angleUseSurf; uniform int angleUseSurf;
uniform sampler2D angleSurf; uniform sampler2D angleSurf;
float random1D (in vec2 st, float _seed) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233)) * mod(_seed + 453.456, 32.156) * 12.588) * 43758.5453123); } float random1D (in vec2 st, float _seed) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233)) * mod(_seed + 453.456, 100.) * 12.588) * 43758.5453123); }
float random (in vec2 st) { return mix(random1D(st, floor(seed)), random1D(st, floor(seed) + 1.), fract(seed)); } float random (in vec2 st, float _seed) { return mix(random1D(st, floor(_seed)), random1D(st, floor(_seed) + 1.), fract(_seed)); }
void main() { void main() {
#region params #region params
@ -46,17 +47,18 @@ void main() {
vec2 pos = (v_vTexcoord - position) * mat2(cos(ang), - sin(ang), sin(ang), cos(ang)); vec2 pos = (v_vTexcoord - position) * mat2(cos(ang), - sin(ang), sin(ang), cos(ang));
float yy = floor(pos.y * nsy); float yy = floor(pos.y * nsy);
float xx = (pos.x + random1D(vec2(yy), floor(seed))) * nsx; float xx = (pos.x + random(vec2(1., yy), seed)) * nsx;
float x0 = floor(xx); float x0 = floor(xx);
float x1 = floor(xx) + 1.; float x1 = floor(xx) + 1.;
float prog = xx - x0; float prog = xx - x0;
if(mode == 0) { if(mode == 0) {
float noise0 = random(vec2(x0, yy)); // point before float noise0 = random(vec2(x0, yy), colrSeed); // point before
float noise1 = random(vec2(x1, yy)); // point after float noise1 = random(vec2(x1, yy), colrSeed); // point after
gl_FragColor = vec4(vec3(mix(noise0, noise1, prog)), 1.); gl_FragColor = vec4(vec3(mix(noise0, noise1, prog)), 1.);
} else if(mode == 1) { } else if(mode == 1) {
gl_FragColor = vec4(vec3(prog), 1.); gl_FragColor = vec4(vec3(prog), 1.);
} }