- New Grain nose.

This commit is contained in:
Tanasart 2024-07-10 18:13:51 +07:00
parent 39421f398c
commit cda5f42f7f
17 changed files with 641 additions and 173 deletions

View file

@ -833,6 +833,7 @@
{"name":"node_gradient_points","order":1,"path":"scripts/node_gradient_points/node_gradient_points.yy",},
{"name":"node_gradient_replace_color","order":12,"path":"scripts/node_gradient_replace_color/node_gradient_replace_color.yy",},
{"name":"node_gradient_shift","order":10,"path":"scripts/node_gradient_shift/node_gradient_shift.yy",},
{"name":"node_grain","order":19,"path":"scripts/node_grain/node_grain.yy",},
{"name":"node_graph_preview","order":22,"path":"scripts/node_graph_preview/node_graph_preview.yy",},
{"name":"node_grey_alpha","order":4,"path":"scripts/node_grey_alpha/node_grey_alpha.yy",},
{"name":"node_greyscale","order":5,"path":"scripts/node_greyscale/node_greyscale.yy",},
@ -1469,6 +1470,7 @@
{"name":"sh_gradient_display","order":7,"path":"shaders/sh_gradient_display/sh_gradient_display.yy",},
{"name":"sh_gradient_points","order":8,"path":"shaders/sh_gradient_points/sh_gradient_points.yy",},
{"name":"sh_gradient","order":6,"path":"shaders/sh_gradient/sh_gradient.yy",},
{"name":"sh_grain","order":24,"path":"shaders/sh_grain/sh_grain.yy",},
{"name":"sh_grey_alpha","order":12,"path":"shaders/sh_grey_alpha/sh_grey_alpha.yy",},
{"name":"sh_greyscale","order":13,"path":"shaders/sh_greyscale/sh_greyscale.yy",},
{"name":"sh_grid_hex","order":1,"path":"shaders/sh_grid_hex/sh_grid_hex.yy",},
@ -1832,6 +1834,7 @@
{"name":"s_node_gradient_shift","order":13,"path":"sprites/s_node_gradient_shift/s_node_gradient_shift.yy",},
{"name":"s_node_gradient_type","order":8,"path":"sprites/s_node_gradient_type/s_node_gradient_type.yy",},
{"name":"s_node_gradient","order":1,"path":"sprites/s_node_gradient/s_node_gradient.yy",},
{"name":"s_node_grain","order":69,"path":"sprites/s_node_grain/s_node_grain.yy",},
{"name":"s_node_grey_alpha","order":25,"path":"sprites/s_node_grey_alpha/s_node_grey_alpha.yy",},
{"name":"s_node_greyscale","order":26,"path":"sprites/s_node_greyscale/s_node_greyscale.yy",},
{"name":"s_node_grid_hex_noise","order":21,"path":"sprites/s_node_grid_hex_noise/s_node_grid_hex_noise.yy",},

View file

@ -1218,6 +1218,7 @@
{"id":{"name":"node_gradient_replace_color","path":"scripts/node_gradient_replace_color/node_gradient_replace_color.yy",},},
{"id":{"name":"node_gradient_shift","path":"scripts/node_gradient_shift/node_gradient_shift.yy",},},
{"id":{"name":"node_gradient","path":"scripts/node_gradient/node_gradient.yy",},},
{"id":{"name":"node_grain","path":"scripts/node_grain/node_grain.yy",},},
{"id":{"name":"node_graph_preview","path":"scripts/node_graph_preview/node_graph_preview.yy",},},
{"id":{"name":"node_grey_alpha","path":"scripts/node_grey_alpha/node_grey_alpha.yy",},},
{"id":{"name":"node_greyscale","path":"scripts/node_greyscale/node_greyscale.yy",},},
@ -1952,6 +1953,7 @@
{"id":{"name":"sh_gradient_display","path":"shaders/sh_gradient_display/sh_gradient_display.yy",},},
{"id":{"name":"sh_gradient_points","path":"shaders/sh_gradient_points/sh_gradient_points.yy",},},
{"id":{"name":"sh_gradient","path":"shaders/sh_gradient/sh_gradient.yy",},},
{"id":{"name":"sh_grain","path":"shaders/sh_grain/sh_grain.yy",},},
{"id":{"name":"sh_grey_alpha","path":"shaders/sh_grey_alpha/sh_grey_alpha.yy",},},
{"id":{"name":"sh_greyscale","path":"shaders/sh_greyscale/sh_greyscale.yy",},},
{"id":{"name":"sh_grid_hex","path":"shaders/sh_grid_hex/sh_grid_hex.yy",},},
@ -2372,6 +2374,7 @@
{"id":{"name":"s_node_gradient_shift","path":"sprites/s_node_gradient_shift/s_node_gradient_shift.yy",},},
{"id":{"name":"s_node_gradient_type","path":"sprites/s_node_gradient_type/s_node_gradient_type.yy",},},
{"id":{"name":"s_node_gradient","path":"sprites/s_node_gradient/s_node_gradient.yy",},},
{"id":{"name":"s_node_grain","path":"sprites/s_node_grain/s_node_grain.yy",},},
{"id":{"name":"s_node_grey_alpha","path":"sprites/s_node_grey_alpha/s_node_grey_alpha.yy",},},
{"id":{"name":"s_node_greyscale","path":"sprites/s_node_greyscale/s_node_greyscale.yy",},},
{"id":{"name":"s_node_grid_hex_noise","path":"sprites/s_node_grid_hex_noise/s_node_grid_hex_noise.yy",},},

View file

@ -361,15 +361,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
return self;
} #endregion
static getFullName = function() { #region
INLINE
return renamed? "[" + name + "] " + display_name : name;
} #endregion
static getDisplayName = function() { #region
INLINE
return renamed? display_name : name;
} #endregion
static getFullName = function() { return renamed? $"[{name}] " + display_name : name; }
static getDisplayName = function() { return renamed? display_name : name; }
/////========== DYNAMIC IO ==========
@ -378,7 +371,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
dyna_input_check_shift = 0;
static createNewInput = -1;
static setDynamicInput = function(_data_length = 1, _auto_input = true, _dummy_type = VALUE_TYPE.any, _dynamic_input_cond = DYNA_INPUT_COND.connection) { #region
static setDynamicInput = function(_data_length = 1, _auto_input = true, _dummy_type = VALUE_TYPE.any, _dynamic_input_cond = DYNA_INPUT_COND.connection) {
is_dynamic_input = true;
auto_input = _auto_input;
dummy_type = _dummy_type;
@ -397,9 +390,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
attributes.size = 0;
} #endregion
}
static refreshDynamicInput = function() { #region
static refreshDynamicInput = function() {
var _in = ds_list_create();
for( var i = 0; i < input_fix_len; i++ )
@ -446,7 +439,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
ds_list_destroy(inputs);
inputs = _in;
} #endregion
}
static getInputAmount = function() { return (ds_list_size(inputs) - input_fix_len) / data_length; }
@ -553,7 +546,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static doStepBegin = function() {}
static triggerCheck = function() { #region
static triggerCheck = function() {
var i = 0;
repeat( input_button_length ) {
@ -574,7 +567,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
onInspector2Update();
inspectInput2.setValue(false);
}
} #endregion
}
static step = function() {}
static focusStep = function() {}
@ -582,7 +575,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
/////========== JUNCTIONS ==========
static getInputJunctionIndex = function(index) { #region
static getInputJunctionIndex = function(index) {
INLINE
if(input_display_list == -1 || !use_display_list)
@ -593,13 +586,13 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(is_struct(jun_list_arr)) return noone;
return jun_list_arr;
} #endregion
}
static getOutputJunctionIndex = function(index) { #region
static getOutputJunctionIndex = function(index) {
if(output_display_list == -1)
return index;
return output_display_list[index];
} #endregion
}
static updateIO = function() {
for( var i = 0, n = ds_list_size(inputs); i < n; i++ )
@ -694,7 +687,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(auto_input && dummy_input) array_push(inputDisplayList, dummy_input);
}#endregion
static onValidate = function() { #region
static onValidate = function() {
value_validation[VALIDATION.pass] = 0;
value_validation[VALIDATION.warning] = 0;
value_validation[VALIDATION.error] = 0;
@ -704,16 +697,16 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(jun.value_validation)
value_validation[jun.value_validation]++;
}
} #endregion
}
static getJunctionTos = function() { #region
static getJunctionTos = function() {
var _vto = array_create(ds_list_size(outputs));
for (var j = 0, m = ds_list_size(outputs); j < m; j++)
_vto[j] = array_clone(outputs[| j].value_to);
return _vto;
} #endregion
}
static checkConnectGroup = function(_io) { #region
static checkConnectGroup = function(_io) {
var _y = y;
var _n = noone;
@ -749,7 +742,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
_io.outputs[$ _ind ] = [ _to ];
}
}
} #endregion
}
/////============ INPUTS ============
@ -769,29 +762,29 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
doUpdate();
} if(!APPENDING && !LOADING) run_in(1, method(self, resetDefault));
static addInput = function(junctionFrom, shift = input_fix_len) { #region
static addInput = function(junctionFrom, shift = input_fix_len) {
var targ = getInput(y, junctionFrom, shift);
if(targ == noone) return;
targ.setFrom(junctionFrom);
} #endregion
}
static getInputData = function(index, def = 0) { #region
static getInputData = function(index, def = 0) {
INLINE
var _dat = array_safe_get_fast(inputs_data, index, def);
return _dat;
} #endregion
}
static setInputData = function(index, value) { #region
static setInputData = function(index, value) {
INLINE
var _inp = inputs[| index];
inputs_data[index] = value;
if(is_struct(_inp)) input_value_map[$ _inp.internalName] = value;
} #endregion
}
static getInputs = function(frame = CURRENT_FRAME) { #region
static getInputs = function(frame = CURRENT_FRAME) {
inputs_data = array_verify(inputs_data, ds_list_size(inputs));
for(var i = 0; i < ds_list_size(inputs); i++) {
@ -801,18 +794,18 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var val = _inp.getValue(frame);
setInputData(i, val);
}
} #endregion
}
/////============ UPDATE ============
static forceUpdate = function() { #region
static forceUpdate = function() {
input_hash = "";
doUpdate();
} #endregion
}
static postUpdate = function(frame = CURRENT_FRAME) {}
static doUpdate = function(frame = CURRENT_FRAME) { #region
static doUpdate = function(frame = CURRENT_FRAME) {
if(PROJECT.safeMode) return;
if(NODE_EXTRACT) return;
@ -864,17 +857,17 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
refreshNodeDisplay();
LOG_BLOCK_END();
} #endregion
}
static valueUpdate = function(index) { #region
static valueUpdate = function(index) {
onValueUpdate(index);
if(is_dynamic_input) will_setHeight = true;
cacheCheck();
} #endregion
}
static valueFromUpdate = function(index) { #region
static valueFromUpdate = function(index) {
onValueFromUpdate(index);
if(auto_input && !LOADING && !APPENDING)
@ -884,14 +877,14 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
will_setHeight = true;
cacheCheck();
} #endregion
}
static onValueUpdate = function(index = 0) {}
static onValueFromUpdate = function(index) {}
/////============ RENDER ============
static isActiveDynamic = function(frame = CURRENT_FRAME) { #region
static isActiveDynamic = function(frame = CURRENT_FRAME) {
if(update_on_frame) return true;
if(!rendered) return true;
@ -900,9 +893,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(inputs[| i].isActiveDynamic(frame)) return true;
return false;
} #endregion
}
static triggerRender = function() { #region
static triggerRender = function() {
LOG_BLOCK_START();
LOG_IF(global.FLAG.render == 1, $"Trigger render for {self}");
@ -919,11 +912,11 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
LOG_BLOCK_END();
} #endregion
}
static clearTopoSorted = function() { INLINE topoSorted = false; }
static forwardPassiveDynamic = function() { #region
static forwardPassiveDynamic = function() {
rendered = false;
for( var i = 0, n = ds_list_size(outputs); i < n; i++ ) {
@ -938,14 +931,14 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
_to.node.rendered = false;
}
}
} #endregion
}
static resetRender = function(_clearCache = false) { #region
static resetRender = function(_clearCache = false) {
setRenderStatus(false);
if(_clearCache) clearInputCache();
} #endregion
}
static isLeaf = function() { #region
static isLeaf = function() {
INLINE
for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) {
@ -954,9 +947,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
return true;
} #endregion
}
static isLeafList = function(list = noone) { #region
static isLeafList = function(list = noone) {
INLINE
if(list == noone) return isLeaf();
@ -970,7 +963,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
return true;
} #endregion
}
static isRenderActive = function() { return renderActive || (PREFERENCES.render_all_export && IS_RENDERING); }
@ -984,16 +977,16 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
return true;
}
static setRenderStatus = function(result) { #region
static setRenderStatus = function(result) {
INLINE
if(rendered == result) return;
LOG_LINE_IF(global.FLAG.render == 1, $"Set render status for {self} : {result}");
rendered = result;
} #endregion
}
static getPreviousNodes = function() { #region
static getPreviousNodes = function() {
var prev = [];
if(attributes.show_update_trigger && updatedInTrigger.value_from)
@ -1018,11 +1011,11 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
onGetPreviousNodes(prev);
return prev;
} #endregion
}
static onGetPreviousNodes = function(arr) {}
static getNextNodes = function() { #region
static getNextNodes = function() {
var nodes = [];
var nodeNames = [];
@ -1058,9 +1051,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
LOG_BLOCK_END();
return nodes;
} #endregion
}
static getNextNodesRaw = function() { #region
static getNextNodesRaw = function() {
var nodes = [];
for(var i = 0; i < ds_list_size(outputs); i++) {
@ -1082,20 +1075,20 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
return nodes;
} #endregion
}
/////============= DRAW =============
static onInspect = function() {}
static pointIn = function(_x, _y, _mx, _my, _s) { #region
static pointIn = function(_x, _y, _mx, _my, _s) {
var xx = x * _s + _x;
var yy = y * _s + _y;
return point_in_rectangle(_mx, _my, xx, yy, xx + w * _s, yy + h * _s);
} #endregion
}
static cullCheck = function(_x, _y, _s, minx, miny, maxx, maxy) { #region
static cullCheck = function(_x, _y, _s, minx, miny, maxx, maxy) {
var x0 = x * _s + _x;
var y0 = y * _s + _y;
var x1 = (x + w) * _s + _x;
@ -1107,18 +1100,18 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
draw_boundary[3] = maxy;
draw_graph_culled = !rectangle_in_rectangle(minx, miny, maxx, maxy, x0, y0, x1, y1);
} #endregion
}
static refreshNodeDisplay = function() { #region
static refreshNodeDisplay = function() {
if(IS_PLAYING) return;
INLINE
updateIO();
setHeight();
getJunctionList();
} run_in(1, function() { refreshNodeDisplay(); }); #endregion
} run_in(1, function() { refreshNodeDisplay(); });
static preDraw = function(_x, _y, _s) { #region
static preDraw = function(_x, _y, _s) {
var xx = x * _s + _x;
var yy = y * _s + _y;
var jun;
@ -1181,15 +1174,15 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(show_parameter) h = h_param;
onPreDraw(_x, _y, _s, _iny, _outy);
} #endregion
}
static onPreDraw = function(_x, _y, _s, _iny, _outy) {}
static isHighlightingInGraph = function() { #region
static isHighlightingInGraph = function() {
var high = display_parameter.highlight;
var _selc = active_draw_index == 0 || branch_drawing;
return !high || _selc;
} #endregion
}
static getColor = function() { INLINE return attributes.color == -1? color : attributes.color; }
@ -1198,7 +1191,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static drawNodeOverlay = function(xx, yy, _mx, _my, _s) {}
__draw_bbox = BBOX();
static drawGetBbox = function(xx, yy, _s) { #region
static drawGetBbox = function(xx, yy, _s) {
var pad_label = draw_name && display_parameter.avoid_label;
var _w = w;
@ -1222,7 +1215,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var y1 = _yc + _h / 2;
return __draw_bbox.fromPoints(x0, y0, x1, y1);
} #endregion
}
static drawNodeName = function(xx, yy, _s) {
var _name = renamed? display_name : name;
@ -1263,7 +1256,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
draw_set_alpha(1);
}
static drawJunctionWidget = function(_x, _y, _mx, _my, _s, _hover, _focus) { #region
static drawJunctionWidget = function(_x, _y, _mx, _my, _s, _hover, _focus) {
var hover = noone;
@ -1335,7 +1328,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
h = fix_h + extY;
h_param = h;
} #endregion
}
static drawJunctions = function(_x, _y, _mx, _my, _s) {
if(!active) return;
@ -1411,7 +1404,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static onDrawJunctions = function(_x, _y, _mx, _my, _s) {}
static drawJunctionNames = function(_x, _y, _mx, _my, _s) { #region
static drawJunctionNames = function(_x, _y, _mx, _my, _s) {
if(draw_graph_culled) return;
if(!active) return;
@ -1469,10 +1462,10 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
inspectInput2.drawNameBG(_s);
inspectInput2.drawName(_s, _mx, _my);
}
} #endregion
}
__draw_inputs = []
static drawConnections = function(params = {}) { #region
static drawConnections = function(params = {}) {
if(!active) return;
var hovering = noone;
@ -1546,9 +1539,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
return hovering;
} #endregion
}
static getGraphPreviewSurface = function() { #region
static getGraphPreviewSurface = function() {
var _node = outputs[| preview_channel];
if(!is_instanceof(_node, NodeValue)) return noone;
@ -1560,18 +1553,18 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
return noone;
} #endregion
}
__preview_surf = false;
__preview_sw = noone;
__preview_sh = noone;
static setPreview = function(_surf) { #region
static setPreview = function(_surf) {
preview_surface = _surf;
__preview_surf = is_surface(_surf);
} #endregion
}
static drawPreview = function(xx, yy, _s) { #region
static drawPreview = function(xx, yy, _s) {
var surf = getGraphPreviewSurface();
if(surf == noone) return;
@ -1609,9 +1602,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
_ps = array_safe_get_fast(_ps.surfaces, 0, noone);
draw_surface_ext_safe(_ps, bbox.xc - _sw * _ss / 2, bbox.yc - _sh * _ss / 2, _ss, _ss);
} #endregion
}
static getNodeDimension = function(showFormat = true) { #region
static getNodeDimension = function(showFormat = true) {
if(!__preview_surf) return preview_array;
var pw = surface_get_width_safe(preview_surface);
@ -1634,9 +1627,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
txt += "]";
return txt;
} #endregion
}
static drawDimension = function(xx, yy, _s) { #region
static drawDimension = function(xx, yy, _s) {
if(draw_graph_culled) return;
if(!active) return;
if(_s * w < 64) return;
@ -1679,7 +1672,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
draw_text(round(tx), round(ty), $"{rt} {unit}");
}
} #endregion
}
static groupCheck = function(_x, _y, _s, _mx, _my) {}
@ -1691,7 +1684,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
return false;
}
static drawNode = function(_x, _y, _mx, _my, _s, display_parameter = noone) { #region
static drawNode = function(_x, _y, _mx, _my, _s, display_parameter = noone) {
if(draw_graph_culled) return;
if(!active) return;
@ -1756,9 +1749,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(!previewable) return drawJunctions_fast(xx, yy, _mx, _my, _s);
return _s > 0.5? drawJunctions(xx, yy, _mx, _my, _s) : drawJunctions_fast(xx, yy, _mx, _my, _s);
} #endregion
}
static drawNodeBehind = function(_x, _y, _mx, _my, _s) { #region
static drawNodeBehind = function(_x, _y, _mx, _my, _s) {
if(draw_graph_culled) return;
if(!active) return;
@ -1766,7 +1759,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var yy = y * _s + _y;
onDrawNodeBehind(_x, _y, _mx, _my, _s);
} #endregion
}
static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) {}
@ -1776,7 +1769,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static drawPreviewBackground = function(_x, _y, _mx, _my, _s) { return false; }
static drawBadge = function(_x, _y, _s) { #region
static drawBadge = function(_x, _y, _s) {
if(!active) return;
var xx = x * _s + _x + w * _s;
var yy = y * _s + _y;
@ -1801,9 +1794,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
inspecting = false;
previewing = 0;
} #endregion
}
static drawBranch = function(_depth = 0) { #region
static drawBranch = function(_depth = 0) {
if(branch_drawing) return;
branch_drawing = true;
@ -1813,12 +1806,12 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(inputs[| i].value_from == noone) continue;
inputs[| i].value_from.node.drawBranch(_depth + 1);
}
} #endregion
}
static drawActive = function(_x, _y, _s, ind = 0) { #region
static drawActive = function(_x, _y, _s, ind = 0) {
active_draw_index = ind;
if(display_parameter.highlight) drawBranch();
} #endregion
}
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {}
@ -1828,7 +1821,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
/////============ PREVIEW ============
static getPreviewValues = function() { #region
static getPreviewValues = function() {
if(preview_channel >= ds_list_size(outputs)) return noone;
var _type = outputs[| preview_channel].type;
@ -1840,39 +1833,39 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
val = array_safe_get_fast(val.surfaces, 0, noone);
return val;
} #endregion
}
static getPreviewBoundingBox = function() { #region
static getPreviewBoundingBox = function() {
var _surf = getPreviewValues();
if(is_array(_surf))
_surf = array_safe_get_fast(_surf, preview_index, noone);
if(!is_surface(_surf)) return noone;
return BBOX().fromWH(preview_x, preview_y, surface_get_width_safe(_surf), surface_get_height_safe(_surf));
} #endregion
}
/////============= CACHE =============
static cacheCheck = function() { #region
static cacheCheck = function() {
INLINE
if(cache_group) cache_group.enableNodeGroup();
if(group != noone) group.cacheCheck();
} #endregion
}
static getAnimationCacheExist = function(frame) { return cacheExist(frame); }
static clearInputCache = function() { #region
static clearInputCache = function() {
for( var i = 0; i < ds_list_size(inputs); i++ )
inputs[| i].cache_value[0] = false;
} #endregion
}
static cacheArrayCheck = function() { #region
static cacheArrayCheck = function() {
cached_output = array_verify(cached_output, TOTAL_FRAMES);
cache_result = array_verify(cache_result, TOTAL_FRAMES);
} #endregion
}
static cacheCurrentFrame = function(_frame) { #region
static cacheCurrentFrame = function(_frame) {
cacheArrayCheck();
if(CURRENT_FRAME < 0) return;
if(CURRENT_FRAME >= array_length(cached_output)) return;
@ -1883,9 +1876,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
array_safe_set(cache_result, CURRENT_FRAME, true);
return cached_output[CURRENT_FRAME];
} #endregion
}
static cacheExist = function(frame = CURRENT_FRAME) { #region
static cacheExist = function(frame = CURRENT_FRAME) {
if(frame < 0) return false;
if(frame >= array_length(cached_output)) return false;
@ -1894,26 +1887,26 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var s = array_safe_get_fast(cached_output, frame);
return is_array(s) || surface_exists(s);
} #endregion
}
static getCacheFrame = function(frame = CURRENT_FRAME) { #region
static getCacheFrame = function(frame = CURRENT_FRAME) {
if(frame < 0) return false;
if(!cacheExist(frame)) return noone;
var surf = array_safe_get_fast(cached_output, frame);
return surf;
} #endregion
}
static recoverCache = function(frame = CURRENT_FRAME) { #region
static recoverCache = function(frame = CURRENT_FRAME) {
if(!cacheExist(frame)) return false;
var _s = cached_output[CURRENT_FRAME];
outputs[| 0].setValue(_s);
return true;
} #endregion
}
static clearCache = function(_force = false) { #region
static clearCache = function(_force = false) {
clearInputCache();
if(!_force) {
@ -1931,22 +1924,22 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
cached_output[i] = 0;
cache_result[i] = false;
}
} #endregion
}
static clearCacheForward = function() { #region
static clearCacheForward = function() {
_clearCacheForward();
} #endregion
}
static _clearCacheForward = function() { #region
static _clearCacheForward = function() {
if(!isRenderActive()) return;
clearCache();
var arr = getNextNodesRaw();
for( var i = 0, n = array_length(arr); i < n; i++ )
arr[i]._clearCacheForward();
} #endregion
}
static cachedPropagate = function(_group = group) { #region
static cachedPropagate = function(_group = group) {
if(group != _group) return;
setRenderStatus(true);
@ -1956,18 +1949,18 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
_input.value_from.node.cachedPropagate(_group);
}
} #endregion
}
static clearInputCache = function() { #region
static clearInputCache = function() {
for( var i = 0; i < ds_list_size(inputs); i++ ) {
if(!is_instanceof(inputs[| i], NodeValue)) continue;
inputs[| i].resetCache();
}
} #endregion
}
/////============= TOOLS =============
static isUsingTool = function(index = undefined, subtool = noone) { #region
static isUsingTool = function(index = undefined, subtool = noone) {
if(tools == -1)
return false;
@ -1988,7 +1981,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
return true;
return _tool.selecting == subtool;
} #endregion
}
static isNotUsingTool = function() { return PANEL_PREVIEW.tool_current == noone; }
@ -1996,7 +1989,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static getToolSettings = function() { return tool_settings; }
static setTool = function(tool) { #region
static setTool = function(tool) {
if(!tool) {
isTool = false;
return;
@ -2006,13 +1999,13 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
group.nodes[i].isTool = false;
isTool = true;
} #endregion
}
static drawTools = noone;
/////=========== SERIALIZE ===========
static serialize = function(scale = false, preset = false) { #region
static serialize = function(scale = false, preset = false) {
if(!active) return;
var _map = {};
@ -2069,7 +2062,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
doSerialize(_map);
processSerialize(_map);
return _map;
} #endregion
}
static attributeSerialize = function() { return attributes; }
static doSerialize = function(_map) {}
@ -2077,7 +2070,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
/////========== DESERIALIZE ==========
static deserialize = function(_map, scale = false, preset = false) { #region
static deserialize = function(_map, scale = false, preset = false) {
load_map = _map;
load_scale = scale;
renamed = struct_try_get(load_map, "renamed", false);
@ -2134,9 +2127,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
if(anim_timeline && attributes.show_timeline) refreshTimeline();
} #endregion
}
static inputBalance = function() { #region //Cross version compatibility for dynamic input nodes
static inputBalance = function() { //Cross version compatibility for dynamic input nodes
if(!struct_has(load_map, "data_length"))
return;
@ -2167,25 +2160,25 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
repeat(_pad_fix)
array_insert(load_map.inputs, _input_fix_len, noone);
} #endregion
}
static inputGenerate = function() { #region //Generate input for dynamic input nodes
static inputGenerate = function() { //Generate input for dynamic input nodes
if(createNewInput == noone)
return;
var _dynamic_inputs = (array_length(load_map.inputs) - input_fix_len) / data_length;
repeat(_dynamic_inputs)
createNewInput();
} #endregion
}
static attributeDeserialize = function(attr) { #region
static attributeDeserialize = function(attr) {
struct_append(attributes, attr);
} #endregion
}
static processDeserialize = function() {}
static postDeserialize = function() {}
static applyDeserialize = function(preset = false) { #region
static applyDeserialize = function(preset = false) {
preApplyDeserialize();
var _inputs = load_map.inputs;
@ -2223,12 +2216,12 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
//print($"Applying deserialzie for {name} complete");
doApplyDeserialize();
} #endregion
}
static preApplyDeserialize = function() {}
static doApplyDeserialize = function() {}
static loadGroup = function(context = noone) { #region
static loadGroup = function(context = noone) {
if(load_group == noone) {
if(context != noone) context.add(self);
} else {
@ -2248,11 +2241,11 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
onLoadGroup();
} #endregion
}
static onLoadGroup = function() {}
static connect = function(log = false) { #region
static connect = function(log = false) {
var connected = true;
for(var i = 0; i < ds_list_size(inputs); i++)
connected &= inputs[| i].connect(log);
@ -2265,7 +2258,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
refreshTimeline();
return connected;
} #endregion
}
static preConnect = function() {}
static postConnect = function() {}
@ -2274,7 +2267,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
/////=========== CLEAN UP ===========
static cleanUp = function() { #region
static cleanUp = function() {
if(ds_exists(inputs, ds_type_list))
for( var i = 0; i < ds_list_size(inputs); i++ )
inputs[| i].cleanUp();
@ -2293,13 +2286,13 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
surface_free(temp_surface[i]);
onCleanUp();
} #endregion
}
static onCleanUp = function() {}
/////============ ACTION ============
static setDimension = function(_w = 128, _h = 128, _apply = true) { #region
static setDimension = function(_w = 128, _h = 128, _apply = true) {
INLINE
min_w = _w;
@ -2310,22 +2303,22 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
w = _w;
h = _h;
}
} #endregion
}
static move = function(_x, _y, _s) { #region
static move = function(_x, _y, _s) {
if(x == _x && y == _y) return;
x = _x;
y = _y;
if(!LOADING) PROJECT.modified = true;
} #endregion
}
static enable = function() { INLINE active = true; timeline_item.active = true; }
static disable = function() { INLINE active = false; timeline_item.active = false; }
static onDestroy = function() {}
static destroy = function(_merge = false, record = true) { #region
static destroy = function(_merge = false, record = true) {
if(!active) return;
disable();
@ -2371,11 +2364,11 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(record) recordAction(ACTION_TYPE.node_delete, self);
RENDER_ALL_REORDER
} #endregion
}
static onRestore = function() {}
static restore = function() { #region
static restore = function() {
if(active) return;
enable();
@ -2385,18 +2378,18 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(group) group.refreshNodes();
RENDER_ALL_REORDER
} #endregion
}
static droppable = function(dragObj) { #region
static droppable = function(dragObj) {
for( var i = 0; i < ds_list_size(inputs); i++ ) {
if(dragObj.type == inputs[| i].drop_key)
return true;
}
return false;
} #endregion
}
on_drop_file = noone;
static onDrop = function(dragObj) { #region
static onDrop = function(dragObj) {
if(dragObj.type == "Asset" && is_callable(on_drop_file)) {
on_drop_file(dragObj.data.path);
return;
@ -2408,11 +2401,11 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
return;
}
}
} #endregion
}
static dropPath = noone;
static clone = function(target = PANEL_GRAPH.getCurrentContext()) { #region
static clone = function(target = PANEL_GRAPH.getCurrentContext()) {
CLONING = true;
var _type = instanceof(self);
var _node = nodeBuild(_type, x, y, target);
@ -2437,28 +2430,28 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
onClone(_node, target);
return _node;
} #endregion
}
static onClone = function(_NewNode, target = PANEL_GRAPH.getCurrentContext()) {}
/////============= MISC =============
static isInLoop = function() { #region
static isInLoop = function() {
return array_exists(global.loop_nodes, instanceof(group));
} #endregion
}
static isTerminal = function() { #region
static isTerminal = function() {
for( var i = 0; i < ds_list_size(outputs); i++ ) {
var _to = outputs[| i].getJunctionTo();
if(array_length(_to)) return false;
}
return true;
} #endregion
}
static resetAnimation = function() {}
static attrDepth = function() { #region
static attrDepth = function() {
if(struct_has(attributes, "color_depth")) {
var form = attributes.color_depth;
if(inputs[| 0].type == VALUE_TYPE.surface)
@ -2472,7 +2465,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(!is_surface(_s))
return surface_rgba8unorm;
return surface_get_format(_s);
} #endregion
}
static toString = function() { return $"Node [{internalName}]: {node_id}"; }
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "filter",
"path": "folders/nodes/data/filter.yy",
},
"resourceVersion": "1.0",
"name": "node_color_adjustment",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "process",
"path": "folders/nodes/data/process.yy",
},
"resourceVersion": "1.0",
"name": "node_color_replacement",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -0,0 +1,107 @@
function Node_Grain(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Grain";
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 1] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 2] = nodeValue("Mix", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider);
inputs[| 3] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 3;
inputs[| 4] = nodeValue("Channel", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0b1111)
.setDisplay(VALUE_DISPLAY.toggle, { data: array_create(4, THEME.inspector_channel) });
__init_mask_modifier(1); // inputs 5, 6
inputs[| 7] = nodeValue("Brightness", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider)
.setMappable(8);
inputs[| 8] = nodeValueMap("Brightness map", self);
inputs[| 9] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, seed_random(6))
.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[| 9].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inputs[| 10] = nodeValue("Red", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider)
.setMappable(11);
inputs[| 11] = nodeValueMap("Red map", self);
inputs[| 12] = nodeValue("Green", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider)
.setMappable(13);
inputs[| 13] = nodeValueMap("Green map", self);
inputs[| 14] = nodeValue("Blue", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider)
.setMappable(15);
inputs[| 15] = nodeValueMap("Blue map", self);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inputs[| 16] = nodeValue("Hue", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider)
.setMappable(17);
inputs[| 17] = nodeValueMap("Hue map", self);
inputs[| 18] = nodeValue("Saturation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider)
.setMappable(19);
inputs[| 19] = nodeValueMap("Saturation map", self);
inputs[| 20] = nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider)
.setMappable(21);
inputs[| 21] = nodeValueMap("Value map", self);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
input_display_list = [ 3, 4, 9,
["Surfaces", true], 0, 1, 2, 5, 6,
["Grain", false], 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
]
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
attribute_surface_depth();
static step = function() {
__step_mask_modifier();
inputs[| 7].mappableStep();
}
static processData = function(_outSurf, _data, _output_index, _array_index) {
surface_set_shader(_outSurf, sh_grain);
shader_set_f("seed", _data[9]);
shader_set_f_map("brightness", _data[ 7], _data[ 8], inputs[| 7]);
shader_set_f_map("red", _data[10], _data[11], inputs[| 10]);
shader_set_f_map("green", _data[12], _data[13], inputs[| 12]);
shader_set_f_map("blue", _data[14], _data[15], inputs[| 14]);
shader_set_f_map("hue", _data[16], _data[17], inputs[| 16]);
shader_set_f_map("sat", _data[18], _data[19], inputs[| 18]);
shader_set_f_map("val", _data[20], _data[21], inputs[| 20]);
draw_surface_safe(_data[0]);
surface_reset_shader();
__process_mask_modifier(_data);
_outSurf = mask_apply(_data[0], _outSurf, _data[1], _data[2]);
_outSurf = channel_apply(_data[0], _outSurf, _data[4]);
return _outSurf;
}
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"",
"%Name":"node_grain",
"isCompatibility":false,
"isDnD":false,
"name":"node_grain",
"parent":{
"name":"colors",
"path":"folders/nodes/data/filter/colors.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "filter",
"path": "folders/nodes/data/filter.yy",
},
"resourceVersion": "1.0",
"name": "node_greyscale",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "process",
"path": "folders/nodes/data/process.yy",
},
"resourceVersion": "1.0",
"name": "node_outline",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -638,6 +638,7 @@ function __initNodes() {
addNodeObject(filter, "Alpha Cutoff", s_node_alpha_cut, "Node_Alpha_Cutoff", [1, Node_Alpha_Cutoff], ["remove alpha"], "Remove pixel with low alpha value.");
addNodeObject(filter, "Normalize", s_node_normalize, "Node_Normalize", [1, Node_Normalize]).setVersion(11710);
addNodeObject(filter, "Gamma Map", s_node_gamma_map, "Node_Gamma_Map", [1, Node_Gamma_Map]).setVersion(11660);
addNodeObject(filter, "Grain", s_node_grain, "Node_Grain", [1, Node_Grain]).setVersion(11770);
addNodeObject(filter, "ACE", s_node_ace, "Node_Tonemap_ACE", [1, Node_Tonemap_ACE],, "Apply ACE tonemapping.").setVersion(11710);
ds_list_add(filter, "Conversions");

View file

@ -0,0 +1,182 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float seed;
uniform vec2 brightness;
uniform int brightnessUseSurf;
uniform sampler2D brightnessSurf;
uniform vec2 red;
uniform int redUseSurf;
uniform sampler2D redSurf;
uniform vec2 green;
uniform int greenUseSurf;
uniform sampler2D greenSurf;
uniform vec2 blue;
uniform int blueUseSurf;
uniform sampler2D blueSurf;
uniform vec2 hue;
uniform int hueUseSurf;
uniform sampler2D hueSurf;
uniform vec2 sat;
uniform int satUseSurf;
uniform sampler2D satSurf;
uniform vec2 val;
uniform int valUseSurf;
uniform sampler2D valSurf;
float random (in vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); }
vec2 random2 (in vec2 st) { float a = random(st); return vec2(cos(a), sin(a)); }
#region =========================================== COLORS SPACES ===========================================
vec3 rgb2hsv(vec3 c) {
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 0.0000000001;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
float hue2rgb( in float m1, in float m2, in float hue) {
if (hue < 0.0)
hue += 1.0;
else if (hue > 1.0)
hue -= 1.0;
if ((6.0 * hue) < 1.0)
return m1 + (m2 - m1) * hue * 6.0;
else if ((2.0 * hue) < 1.0)
return m2;
else if ((3.0 * hue) < 2.0)
return m1 + (m2 - m1) * ((2.0 / 3.0) - hue) * 6.0;
else
return m1;
}
vec3 hsl2rgb( in vec3 hsl ) {
float r, g, b;
if(hsl.y == 0.) {
r = hsl.z;
g = hsl.z;
b = hsl.z;
} else {
float m1, m2;
if(hsl.z <= 0.5)
m2 = hsl.z * (1. + hsl.y);
else
m2 = hsl.z + hsl.y - hsl.z * hsl.y;
m1 = 2. * hsl.z - m2;
r = hue2rgb(m1, m2, hsl.x + 1. / 3.);
g = hue2rgb(m1, m2, hsl.x);
b = hue2rgb(m1, m2, hsl.x - 1. / 3.);
}
return vec3( r, g, b );
}
vec3 rgb2hsl( in vec3 c ) {
float h = 0.0;
float s = 0.0;
float l = 0.0;
float r = c.r;
float g = c.g;
float b = c.b;
float cMin = min( r, min( g, b ) );
float cMax = max( r, max( g, b ) );
l = ( cMax + cMin ) / 2.0;
if ( cMax > cMin ) {
float cDelta = cMax - cMin;
s = l < .5 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) );
if ( r == cMax )
h = ( g - b ) / cDelta;
else if ( g == cMax )
h = 2.0 + ( b - r ) / cDelta;
else
h = 4.0 + ( r - g ) / cDelta;
if ( h < 0.0)
h += 6.0;
h = h / 6.0;
}
return vec3( h, s, l );
}
#endregion =========================================== COLORS SPACES ===========================================
void main() {
vec4 c = texture2D( gm_BaseTexture, v_vTexcoord );
float bri = brightness.x;
if(brightnessUseSurf == 1) {
vec4 _vMap = texture2D( brightnessSurf, v_vTexcoord );
bri = mix(brightness.x, brightness.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float r = red.x;
if(redUseSurf == 1) {
vec4 _vMap = texture2D( redSurf, v_vTexcoord );
r = mix(red.x, red.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float g = green.x;
if(greenUseSurf == 1) {
vec4 _vMap = texture2D( greenSurf, v_vTexcoord );
g = mix(green.x, green.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float b = blue.x;
if(blueUseSurf == 1) {
vec4 _vMap = texture2D( blueSurf, v_vTexcoord );
b = mix(blue.x, blue.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float h = hue.x;
if(hueUseSurf == 1) {
vec4 _vMap = texture2D( hueSurf, v_vTexcoord );
h = mix(hue.x, hue.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float s = sat.x;
if(satUseSurf == 1) {
vec4 _vMap = texture2D( satSurf, v_vTexcoord );
s = mix(sat.x, sat.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float v = val.x;
if(valUseSurf == 1) {
vec4 _vMap = texture2D( valSurf, v_vTexcoord );
v = mix(val.x, val.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
c.rgb *= 1. + bri * bri * (random(v_vTexcoord + vec2(0.156 + seed / 1000., 0.6169)) * 2. - 1.);
c.r += r * r * (random(v_vTexcoord + vec2(0.985 + seed / 1000., 0.3642)) * 2. - 1.);
c.g += g * g * (random(v_vTexcoord + vec2(0.653 + seed / 1000., 0.4954)) * 2. - 1.);
c.b += b * b * (random(v_vTexcoord + vec2(0.382 + seed / 1000., 0.2967)) * 2. - 1.);
vec3 hsv = rgb2hsv(c.rgb);
hsv.r += h * h * (random(v_vTexcoord + vec2(0.685 + seed / 1000., 0.5672)) * 2. - 1.);
hsv.g += s * s * (random(v_vTexcoord + vec2(0.134 + seed / 1000., 0.8632)) * 2. - 1.);
hsv.b += v * v * (random(v_vTexcoord + vec2(0.268 + seed / 1000., 0.1264)) * 2. - 1.);
c.rgb = hsv2rgb(hsv);
gl_FragColor = c;
}

View file

@ -0,0 +1,19 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,12 @@
{
"$GMShader":"",
"%Name":"sh_grain",
"name":"sh_grain",
"parent":{
"name":"color",
"path":"folders/shader/filter/color.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

View file

@ -9,10 +9,7 @@ uniform int iteration;
///////////////////// PERLIN START /////////////////////
float random (in vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); }
vec2 random2 (in vec2 st) {
float a = random(st);
return vec2(cos(a), sin(a));
}
vec2 random2 (in vec2 st) { float a = random(st); return vec2(cos(a), sin(a)); }
float noise (in vec2 st) {
vec2 i = floor(st);

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

View file

@ -0,0 +1,90 @@
{
"$GMSprite":"",
"%Name":"s_node_grain",
"bboxMode":0,
"bbox_bottom":63,
"bbox_left":0,
"bbox_right":63,
"bbox_top":0,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"8bb718bb-5765-4431-ac84-f472f18a47cd","name":"8bb718bb-5765-4431-ac84-f472f18a47cd","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":64,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"5b3a48a1-a4bc-4435-ae2a-4de0c85f6119","blendMode":0,"displayName":"default","isLocked":false,"name":"5b3a48a1-a4bc-4435-ae2a-4de0c85f6119","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_node_grain",
"nineSlice":null,
"origin":4,
"parent":{
"name":"filter",
"path":"folders/nodes/icons/filter.yy",
},
"preMultiplyAlpha":false,
"resourceType":"GMSprite",
"resourceVersion":"2.0",
"sequence":{
"$GMSequence":"",
"%Name":"s_node_grain",
"autoRecord":true,
"backdropHeight":768,
"backdropImageOpacity":0.5,
"backdropImagePath":"",
"backdropWidth":1366,
"backdropXOffset":0.0,
"backdropYOffset":0.0,
"events":{
"$KeyframeStore<MessageEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MessageEventKeyframe>",
"resourceVersion":"2.0",
},
"eventStubScript":null,
"eventToFunction":{},
"length":1.0,
"lockOrigin":false,
"moments":{
"$KeyframeStore<MomentsEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
"resourceVersion":"2.0",
},
"name":"s_node_grain",
"playback":1,
"playbackSpeed":30.0,
"playbackSpeedType":0,
"resourceType":"GMSequence",
"resourceVersion":"2.0",
"showBackdrop":true,
"showBackdropImage":false,
"timeUnits":1,
"tracks":[
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"8bb718bb-5765-4431-ac84-f472f18a47cd","path":"sprites/s_node_grain/s_node_grain.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"3a55bf61-b29d-46ad-a496-89d183d81204","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
],
"visibleRange":null,
"volume":1.0,
"xorigin":32,
"yorigin":32,
},
"swatchColours":null,
"swfPrecision":0.5,
"textureGroupId":{
"name":"Default",
"path":"texturegroups/Default",
},
"type":0,
"VTile":false,
"width":64,
}