[Posterize] Add option to use global color range for faster processing.

This commit is contained in:
Tanasart 2025-02-09 07:55:52 +07:00
parent 93545927a1
commit 5e26484472
47 changed files with 115 additions and 162 deletions

Binary file not shown.

View file

@ -1,5 +1,6 @@
function Node_3D_Material(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor { function Node_3D_Material(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor {
name = "3D Material"; name = "3D Material";
is_3D = NODE_3D.none;
solid_surf = noone; solid_surf = noone;
newInput(0, nodeValue_Surface("Texture", self)) newInput(0, nodeValue_Surface("Texture", self))
@ -71,24 +72,6 @@ function Node_3D_Material(_x, _y, _group = noone) : Node_3D(_x, _y, _group) cons
return _mat; return _mat;
} }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { static getPreviewValues = function() /*=>*/ {return inputs[0].getValue()};
if(!previewable) return; static getGraphPreviewSurface = function() /*=>*/ {return getSingleValue(0)};
var bbox = drawGetBbox(xx, yy, _s);
var _mat = outputs[0].getValue();
if(_mat == noone) return;
if(is_array(_mat)) {
if(array_empty(_mat)) return;
_mat = _mat[0];
}
if(is_instanceof(_mat, __d3dMaterial) && is_surface(_mat.surface)) {
var aa = 0.5 + 0.5 * renderActive;
if(!isHighlightingInGraph()) aa *= 0.25;
draw_surface_bbox(_mat.surface, bbox,, aa);
}
}
} }

View file

@ -1,6 +1,6 @@
function Node_Argument(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Argument(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Argument"; name = "Argument";
setDimension(96, 32 + 24 * 1); setDimension(96, 48);
draw_padding = 8; draw_padding = 8;

View file

@ -1,6 +1,6 @@
function Node_Array_Add(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Add(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Add"; name = "Array Add";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Boolean_Opr(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Boolean_Opr(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Boolean Opr"; name = "Array Boolean Opr";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array 1", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array 1", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Composite(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Composite(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Composite"; name = "Array Composite";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Float("Array", self, [])) newInput(0, nodeValue_Float("Array", self, []))
.setArrayDepth(1) .setArrayDepth(1)

View file

@ -1,6 +1,6 @@
function Node_Array_Convolute(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Convolute(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Convolute"; name = "Array Convolute";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Float("Array", self, [])) newInput(0, nodeValue_Float("Array", self, []))
.setArrayDepth(1) .setArrayDepth(1)

View file

@ -1,6 +1,6 @@
function Node_Array_Copy(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Copy(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Copy"; name = "Array Copy";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setArrayDepth(1) .setArrayDepth(1)

View file

@ -1,6 +1,6 @@
function Node_Array_CSV_Parse(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_CSV_Parse(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "CSV Parse"; name = "CSV Parse";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Text("CSV string", self, 0)) newInput(0, nodeValue_Text("CSV string", self, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Find(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Find(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Find"; name = "Array Find";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Get(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Get(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Get"; name = "Array Get";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Insert(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Insert(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Insert"; name = "Array Insert";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Length(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Length(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Length"; name = "Array Length";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -127,7 +127,7 @@ function Node_Array_Rearrange(_x, _y, _group = noone) : Node(_x, _y, _group) con
if(type != _typ) { if(type != _typ) {
if(_typ == VALUE_TYPE.surface) setDimension(128, 128); if(_typ == VALUE_TYPE.surface) setDimension(128, 128);
else setDimension(96, 32 + 24); else setDimension(96, 48);
type = _typ; type = _typ;
} }

View file

@ -1,6 +1,6 @@
function Node_Array_Remove(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Remove(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Remove"; name = "Array Remove";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Reverse(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Reverse(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Reverse"; name = "Array Reverse";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Sample(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Sample(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Sample"; name = "Array Sample";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Set(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Set(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Set"; name = "Array Set";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Array_Shift(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Array_Shift(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Array Shift"; name = "Array Shift";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setArrayDepth(99) .setArrayDepth(99)

View file

@ -1,6 +1,6 @@
function Node_Array_Zip(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Zip(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Zip"; name = "Array Zip";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Assert(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Assert(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Assert"; name = "Assert";
setDimension(96, 32 + 24 * 1); setDimension(96, 48);
draw_padding = 8; draw_padding = 8;

View file

@ -1,6 +1,6 @@
function Node_Cache_Value_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Cache_Value_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Cache Value Array"; name = "Cache Value Array";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Value", self, CONNECT_TYPE.input, VALUE_TYPE.any, noone)) newInput(0, nodeValue("Value", self, CONNECT_TYPE.input, VALUE_TYPE.any, noone))
.setVisible(true, true); .setVisible(true, true);

View file

@ -2293,7 +2293,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
return noone; return noone;
var val = outputs[preview_channel].getValue(); var val = outputs[preview_channel].getValue();
if(is_struct(val) && is_instanceof(val, dynaSurf)) if(is_struct(val) && is(val, dynaSurf))
val = array_safe_get_fast(val.surfaces, 0, noone); val = array_safe_get_fast(val.surfaces, 0, noone);
return val; return val;

View file

@ -1,6 +1,6 @@
function Node_DLL(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_DLL(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "DLL"; name = "DLL";
setDimension(96, 32 + 24 * 1); setDimension(96, 48);
newInput(0, nodeValue_Path("DLL File", self, "")) newInput(0, nodeValue_Path("DLL File", self, ""))
.setDisplay(VALUE_DISPLAY.path_load, { filter: "Dynamic-link library (.dll)|*.dll" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "Dynamic-link library (.dll)|*.dll" })

View file

@ -2,7 +2,7 @@ function Node_Feedback_Input(_x, _y, _group = noone) : Node_Group_Input(_x, _y,
name = "Feedback Input"; name = "Feedback Input";
color = COLORS.node_blend_feedback; color = COLORS.node_blend_feedback;
is_group_io = true; is_group_io = true;
setDimension(96, 32 + 24 * 2); setDimension(96, 48);
feedbackOut = noone; feedbackOut = noone;

View file

@ -2,7 +2,7 @@ function Node_Feedback_Output(_x, _y, _group = noone) : Node_Group_Output(_x, _y
name = "Feedback Output"; name = "Feedback Output";
color = COLORS.node_blend_feedback; color = COLORS.node_blend_feedback;
is_group_io = true; is_group_io = true;
setDimension(96, 32 + 24 * 2); setDimension(96, 48);
newInput(1, nodeValue("Feedback loop", self, CONNECT_TYPE.input, VALUE_TYPE.node, -1)) newInput(1, nodeValue("Feedback loop", self, CONNECT_TYPE.input, VALUE_TYPE.node, -1))
.setVisible(true, true); .setVisible(true, true);

View file

@ -76,7 +76,7 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
destroy_when_upgroup = true; destroy_when_upgroup = true;
skipDefault(); skipDefault();
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Enum_Scroll("Display type", self, 0, { data: GROUP_IO_DISPLAY[11], update_hover: false })); newInput(0, nodeValue_Enum_Scroll("Display type", self, 0, { data: GROUP_IO_DISPLAY[11], update_hover: false }));

View file

@ -5,7 +5,7 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr
destroy_when_upgroup = true; destroy_when_upgroup = true;
skipDefault(); skipDefault();
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue("Value", self, CONNECT_TYPE.input, VALUE_TYPE.any, -1)) newInput(0, nodeValue("Value", self, CONNECT_TYPE.input, VALUE_TYPE.any, -1))
.uncache() .uncache()

View file

@ -1,7 +1,7 @@
function Node_Matrix(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Matrix(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Matrix"; name = "Matrix";
color = COLORS.node_blend_number; color = COLORS.node_blend_number;
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_IVec2("Size", self, [ 3, 3 ])); newInput(0, nodeValue_IVec2("Size", self, [ 3, 3 ]));

View file

@ -1,7 +1,7 @@
function Node_Matrix_Det(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Matrix_Det(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Matrix Det"; name = "Matrix Det";
color = COLORS.node_blend_number; color = COLORS.node_blend_number;
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3))) newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3)))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,7 +1,7 @@
function Node_Matrix_Invert(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Matrix_Invert(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Matrix Invert"; name = "Matrix Invert";
color = COLORS.node_blend_number; color = COLORS.node_blend_number;
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3))) newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3)))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,7 +1,7 @@
function Node_Matrix_Math(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Matrix_Math(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Matrix Math"; name = "Matrix Math";
color = COLORS.node_blend_number; color = COLORS.node_blend_number;
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Matrix("Matrix 1", self, new Matrix(3))) newInput(0, nodeValue_Matrix("Matrix 1", self, new Matrix(3)))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,7 +1,7 @@
function Node_Matrix_Multiply_Vector(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Matrix_Multiply_Vector(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Multiply Vector"; name = "Multiply Vector";
color = COLORS.node_blend_number; color = COLORS.node_blend_number;
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3))) newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3)))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,7 +1,7 @@
function Node_Matrix_Set(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Matrix_Set(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Matrix Set"; name = "Matrix Set";
color = COLORS.node_blend_number; color = COLORS.node_blend_number;
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3))) newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3)))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,7 +1,7 @@
function Node_Matrix_To_Array(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Matrix_To_Array(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Matrix to Array"; name = "Matrix to Array";
color = COLORS.node_blend_number; color = COLORS.node_blend_number;
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3))) newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3)))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,7 +1,7 @@
function Node_Matrix_Transpose(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Matrix_Transpose(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Matrix Transpose"; name = "Matrix Transpose";
color = COLORS.node_blend_number; color = COLORS.node_blend_number;
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3))) newInput(0, nodeValue_Matrix("Matrix", self, new Matrix(3)))
.setVisible(true, true); .setVisible(true, true);

View file

@ -2,7 +2,7 @@ function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
name = "Number"; name = "Number";
color = COLORS.node_blend_number; color = COLORS.node_blend_number;
setDimension(96, 32 + 24 * 1); setDimension(96, 48);
// wd_slider = slider(0, 1, 0.01, function(val) { inputs[0].setValue(val); } ); // wd_slider = slider(0, 1, 0.01, function(val) { inputs[0].setValue(val); } );
@ -157,7 +157,7 @@ function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var disp = getInputData(2); var disp = getInputData(2);
var styl = getInputData(6); var styl = getInputData(6);
var _ww = 96, _hh = 56; var _ww = 96, _hh = 48;
inputs[3].setVisible(disp > 0); inputs[3].setVisible(disp > 0);
inputs[4].setVisible(disp > 0); inputs[4].setVisible(disp > 0);
@ -166,28 +166,18 @@ function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
inputs[7].setVisible(disp == 2); inputs[7].setVisible(disp == 2);
switch(disp) { switch(disp) {
case 0 :
break;
case 1 : case 1 :
_ww = 160; _ww = 160;
if(styl == 0) _hh = 96; if(styl == 0) _hh = 96;
else if(styl == 1) _hh = 64; else if(styl == 1) _hh = 64;
break; break;
case 2 : case 2 : _ww = 128; _hh = 128; break;
_ww = 128; _hh = 128; case 3 : _ww = 160; _hh = 64; break;
break;
case 3 :
_ww = 160; _hh = 64;
break;
} }
setDimension(_ww, _hh); setDimension(_ww, _hh);
inputs[0].setType( int? VALUE_TYPE.integer : VALUE_TYPE.float);
inputs[0].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float);
outputs[0].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float); outputs[0].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float);
} }

View file

@ -34,8 +34,10 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
newInput(8, nodeValue_Enum_Button("Space", self, 0, [ "RGB", "LAB" ])); newInput(8, nodeValue_Enum_Button("Space", self, 0, [ "RGB", "LAB" ]));
newInput(9, nodeValue_Bool("Use Global Range", self, true));
input_display_list = [ 5, 0, input_display_list = [ 5, 0,
["Palette", false, 2], 1, 3, 4, 7, 8, ["Palette", false, 2], 1, 9, 3, 4, 7, 8,
["Alpha", false], 6, ["Alpha", false], 6,
]; ];
@ -48,11 +50,13 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
static step = function() { static step = function() {
var _use_pal = getInputData(2); var _use_pal = getInputData(2);
inputs[1].setVisible(_use_pal); inputs[1].setVisible( _use_pal);
inputs[3].setVisible(!_use_pal); inputs[3].setVisible(!_use_pal);
inputs[4].setVisible(!_use_pal); inputs[4].setVisible(!_use_pal);
inputs[4].mappableStep(); inputs[4].mappableStep();
inputs[8].setVisible(_use_pal);
inputs[8].setVisible( _use_pal);
inputs[9].setVisible(!_use_pal);
} }
static processData = function(_outSurf, _data, _output_index, _array_index) { static processData = function(_outSurf, _data, _output_index, _array_index) {
@ -61,6 +65,7 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _use_pal = _data[2]; var _use_pal = _data[2];
var _alp = _data[6]; var _alp = _data[6];
var _spce = _data[8]; var _spce = _data[8];
var _glob = _data[9];
if(_use_pal) { if(_use_pal) {
surface_set_shader(_outSurf, sh_posterize_palette); surface_set_shader(_outSurf, sh_posterize_palette);
@ -72,7 +77,11 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
surface_reset_shader(); surface_reset_shader();
} else { } else {
#region get range
var _max = [ 0, 0, 0 ];
var _min = [ 1, 1, 1 ];
if(!_glob) { // get range
var _sw = surface_get_width(_surf); var _sw = surface_get_width(_surf);
var _sh = surface_get_height(_surf); var _sh = surface_get_height(_surf);
var _itr = ceil(logn(4, _sw * _sh / 1024)); var _itr = ceil(logn(4, _sw * _sh / 1024));
@ -120,8 +129,6 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _sMin = temp_surface[(!_ind) * 2 + 1]; var _sMin = temp_surface[(!_ind) * 2 + 1];
var _ssw = surface_get_width(_sMax); var _ssw = surface_get_width(_sMax);
var _ssh = surface_get_height(_sMax); var _ssh = surface_get_height(_sMax);
var _max = [ 0, 0, 0 ];
var _min = [ 1, 1, 1 ];
var _bMax = buffer_from_surface(_sMax, false); var _bMax = buffer_from_surface(_sMax, false);
var _bMin = buffer_from_surface(_sMin, false); var _bMin = buffer_from_surface(_sMin, false);
@ -144,7 +151,7 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
buffer_delete(_bMax); buffer_delete(_bMax);
buffer_delete(_bMin); buffer_delete(_bMin);
#endregion }
surface_set_shader(_outSurf, sh_posterize); surface_set_shader(_outSurf, sh_posterize);
shader_set_f("cMax", _max); shader_set_f("cMax", _max);

View file

@ -1,6 +1,6 @@
function Node_Print(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Print(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Print"; name = "Print";
setDimension(96, 32 + 24 * 1); setDimension(96, 48);
draw_padding = 8; draw_padding = 8;

View file

@ -17,25 +17,6 @@ function Node_Random_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
temp_surface = [ noone ]; temp_surface = [ noone ];
function surfaceContentRatio(_surf) {
var s = 0;
var _sw = surface_get_width_safe(_surf);
var _sh = surface_get_height_safe(_surf);
var total = _sw * _sh;
var _buff = buffer_create(_sw * _sh * 4, buffer_fixed, 4);
buffer_get_surface(_buff, _surf, 0);
buffer_seek(_buff, buffer_seek_start, 0);
repeat(total) {
var b = buffer_read(_buff, buffer_u32);
if(b) s++;
}
buffer_delete(_buff);
return s / total;
}
function generateShape(_dim, _aa = 1) { function generateShape(_dim, _aa = 1) {
var _sw = _dim[0] * _aa; var _sw = _dim[0] * _aa;
var _sh = _dim[1] * _aa; var _sh = _dim[1] * _aa;
@ -49,7 +30,7 @@ function Node_Random_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
repeat(_amou) { repeat(_amou) {
var _side = min(_dim[0], _dim[1]); var _side = min(_dim[0], _dim[1]);
var _size = irandom_range(_side * 0.25, _side * 0.75); var _size = irandom_range(_side * 0.25, _side * 0.5);
var _shape = surface_create(_size * _aa, _size * _aa); var _shape = surface_create(_size * _aa, _size * _aa);
surface_set_target(_shape); surface_set_target(_shape);
@ -58,10 +39,10 @@ function Node_Random_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
var _x1 = _size * _aa; var _x1 = _size * _aa;
var _y1 = _size * _aa; var _y1 = _size * _aa;
var _r = irandom(4) * 2 * _aa;
switch(irandom(2)) { switch(irandom(2)) {
case 0 : draw_roundrect_ext(0, 0, _x1, _y1, _r, _r, false); break; case 0 : var _r = irandom(4) * 2 * _aa;
draw_roundrect_ext(0, 0, _x1, _y1, _r, _r, false); break;
case 1 : draw_ellipse(0, 0, _x1, _y1, false); break; case 1 : draw_ellipse(0, 0, _x1, _y1, false); break;
case 2 : draw_triangle(_x1 / 2, 0, 0, _y1, _x1, _y1, false); break; case 2 : draw_triangle(_x1 / 2, 0, 0, _y1, _x1, _y1, false); break;
} }
@ -102,7 +83,7 @@ function Node_Random_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
if(random(1) < 0.5) { if(random(1) < 0.5) {
_prog = surface_create(_adim[0], _adim[1]); _prog = surface_create(_adim[0], _adim[1]);
var _size = [ _dim[0] * .75, _dim[1] * 0.75 ]; var _size = [ _dim[0] * .6, _dim[1] * .6 ];
var _subs = generateShape(_size, _aa); var _subs = generateShape(_size, _aa);
var _sx = _adim[0] / 2; var _sx = _adim[0] / 2;
var _sy = _adim[1] / 2; var _sy = _adim[1] / 2;
@ -122,32 +103,36 @@ function Node_Random_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
} else } else
draw_surface_safe(_surf); draw_surface_safe(_surf);
if(is_surface(_subs)) {
BLEND_SUBTRACT BLEND_SUBTRACT
draw_surface_safe(_subs, _sx, _sy); draw_surface_ext(_subs, _sx, _sy, 1, 1, 0, c_white, 1);
var _mir = irandom(3);
if(_mir & 0b01) draw_surface_ext(_subs, _dim[0] - _sx, _sy, -1, 1, 0, c_white, 1);
if(_mir & 0b10) draw_surface_ext(_subs, _sx, _dim[1] - _sy, 1, -1, 0, c_white, 1);
if(_mir == 0b11) draw_surface_ext(_subs, _dim[0] - _sx, _dim[1] - _sy, -1, -1, 0, c_white, 1);
BLEND_NORMAL BLEND_NORMAL
}
surface_reset_target(); surface_reset_target();
surface_free(_subs); surface_free(_subs);
surface_free(_surf); surface_free(_surf);
} }
// if(surfaceContentRatio(_prog) < 0.2) {
// surface_free(_prog);
// _prog = generateShape(_adim);
// }
var _corn = surface_create(_dim[0], _dim[1]); var _corn = surface_create(_dim[0], _dim[1]);
temp_surface[0] = surface_verify(temp_surface[0], _adim[0], _adim[1]); temp_surface[0] = surface_verify(temp_surface[0], _adim[0], _adim[1]);
var _cPassAA = temp_surface[0]; var _cPassAA = temp_surface[0];
surface_set_shader(_cPassAA, sh_rsh_corner, true, BLEND.add); surface_set_shader(_cPassAA, sh_rsh_corner, true, BLEND.add);
shader_set_f("dimension", _adim[0], _adim[1]); shader_set_2("dimension", _adim);
shader_set_i("type", choose(0, 0, 1, 1, 1)); shader_set_i("type", choose(0, 0, 1, 1, 1));
draw_surface_safe(_prog); draw_surface_safe(_prog);
if(_side == 1) draw_surface_ext_safe(_prog, 0, _adim[1], 1, -1, 0, c_white, 1); switch(_side) {
if(_side == 2) draw_surface_ext_safe(_prog, _adim[0], 0, -1, 1, 0, c_white, 1); case 1 : draw_surface_ext_safe(_prog, 0, _adim[1], 1, -1, 0, c_white, 1); break;
case 2 : draw_surface_ext_safe(_prog, _adim[0], 0, -1, 1, 0, c_white, 1); break;
}
surface_reset_shader(); surface_reset_shader();
surface_free(_prog); surface_free(_prog);

View file

@ -1,6 +1,6 @@
function Node_Shell(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Shell(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Execute Shell"; name = "Execute Shell";
setDimension(96, 32 + 24 * 1); setDimension(96, 48);
newInput(0, nodeValue_Path("Path", self, "")); newInput(0, nodeValue_Path("Path", self, ""));

View file

@ -1,6 +1,6 @@
function Node_Struct_JSON_Parse(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Struct_JSON_Parse(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "JSON Parse"; name = "JSON Parse";
setDimension(96, 32 + 24); setDimension(96, 48);
newInput(0, nodeValue_Text("JSON string", self, "")) newInput(0, nodeValue_Text("JSON string", self, ""))
.setVisible(true, true); .setVisible(true, true);

View file

@ -1,6 +1,6 @@
function Node_Terminal_Trigger(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Terminal_Trigger(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Terminal Trigger"; name = "Terminal Trigger";
setDimension(96, 32 + 24 * 1); setDimension(96, 48);
draw_padding = 8; draw_padding = 8;

View file

@ -1,7 +1,7 @@
function Node_Trigger_Bool(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Trigger_Bool(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Boolean Trigger"; name = "Boolean Trigger";
update_on_frame = true; update_on_frame = true;
setDimension(96, 32 + 24 * 1); setDimension(96, 48);
newInput(0, nodeValue_Bool("Boolean", self, false)); newInput(0, nodeValue_Bool("Boolean", self, false));

View file

@ -64,7 +64,7 @@ float random (in vec2 st, float seed) { return fract(sin(dot(st.xy, vec2(1892.98
} #endregion } #endregion
#endregion #endregion
void main() { #region void main() {
vec4 _col = texture2D( gm_BaseTexture, v_vTexcoord ); vec4 _col = texture2D( gm_BaseTexture, v_vTexcoord );
bool exactColor = false; bool exactColor = false;
@ -110,6 +110,7 @@ void main() { #region
if(exactColor) { if(exactColor) {
gl_FragColor = _col; gl_FragColor = _col;
} else { } else {
float d1 = colorDifferent(_col, col1); float d1 = colorDifferent(_col, col1);
float d2 = colorDifferent(_col, col2); float d2 = colorDifferent(_col, col2);
@ -156,4 +157,4 @@ void main() { #region
} }
gl_FragColor.a *= _col.a; gl_FragColor.a *= _col.a;
} #endregion }

View file

@ -10,7 +10,7 @@ uniform int gammaUseSurf;
uniform sampler2D gammaSurf; uniform sampler2D gammaSurf;
#region =========================================== COLORS SPACES =========================================== #region =========================================== COLORS SPACES ===========================================
vec3 rgb2hsv(vec3 c) { #region vec3 rgb2hsv(vec3 c) {
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); 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 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)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
@ -18,15 +18,15 @@ uniform sampler2D gammaSurf;
float d = q.x - min(q.w, q.y); float d = q.x - min(q.w, q.y);
float e = 0.0000000001; float e = 0.0000000001;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
} #endregion }
vec3 hsv2rgb(vec3 c) { #region vec3 hsv2rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); 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); 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); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
} #endregion }
float hue2rgb( in float m1, in float m2, in float hue) { #region float hue2rgb( in float m1, in float m2, in float hue) {
if (hue < 0.0) if (hue < 0.0)
hue += 1.0; hue += 1.0;
else if (hue > 1.0) else if (hue > 1.0)
@ -40,9 +40,9 @@ uniform sampler2D gammaSurf;
return m1 + (m2 - m1) * ((2.0 / 3.0) - hue) * 6.0; return m1 + (m2 - m1) * ((2.0 / 3.0) - hue) * 6.0;
else else
return m1; return m1;
} #endregion }
vec3 hsl2rgb( in vec3 hsl ) { #region vec3 hsl2rgb( in vec3 hsl ) {
float r, g, b; float r, g, b;
if(hsl.y == 0.) { if(hsl.y == 0.) {
r = hsl.z; r = hsl.z;
@ -62,9 +62,9 @@ uniform sampler2D gammaSurf;
} }
return vec3( r, g, b ); return vec3( r, g, b );
} #endregion }
vec3 rgb2hsl( in vec3 c ) { #region vec3 rgb2hsl( in vec3 c ) {
float h = 0.0; float h = 0.0;
float s = 0.0; float s = 0.0;
float l = 0.0; float l = 0.0;
@ -92,7 +92,7 @@ uniform sampler2D gammaSurf;
h = h / 6.0; h = h / 6.0;
} }
return vec3( h, s, l ); return vec3( h, s, l );
} #endregion }
#endregion =========================================== COLORS SPACES =========================================== #endregion =========================================== COLORS SPACES ===========================================
float round(float a) { return fract(a) >= 0.5? ceil(a) : floor(a); } float round(float a) { return fract(a) >= 0.5? ceil(a) : floor(a); }
@ -113,7 +113,6 @@ void main() {
_col.rgb = clamp((_col.rgb - cMin) / cRan, 0., 1.); _col.rgb = clamp((_col.rgb - cMin) / cRan, 0., 1.);
vec3 c = _col.rgb; vec3 c = _col.rgb;
c = pow(c, vec3(gam)); c = pow(c, vec3(gam));
c = floor(c * colors) / (colors - 1.); c = floor(c * colors) / (colors - 1.);
c = pow(c, vec3(1.0 / gam)); c = pow(c, vec3(1.0 / gam));

View file

@ -40,32 +40,20 @@ void main() {
// 6 7 8 // 6 7 8
if(a.a == 0.) { if(a.a == 0.) {
/**/ if(a0 && a1 && a2 && a3 && !a5 && a6 && !a7 && !a8) /**/ if( a0 && a1 && a2 && a3 && !a5 && a6 && !a7 && !a8) gl_FragColor = vec4(1.);
gl_FragColor = vec4(1.); else if( a0 && a1 && a2 && !a3 && a5 && !a6 && !a7 && a8) gl_FragColor = vec4(1.);
else if(a0 && a1 && a2 && !a3 && a5 && !a6 && !a7 && a8) else if( a0 && !a1 && !a2 && a3 && !a5 && a6 && a7 && a8) gl_FragColor = vec4(1.);
gl_FragColor = vec4(1.); else if(!a0 && !a1 && a2 && !a3 && a5 && a6 && a7 && a8) gl_FragColor = vec4(1.);
else if(a0 && !a1 && !a2 && a3 && !a5 && a6 && a7 && a8)
gl_FragColor = vec4(1.);
else if(!a0 && !a1 && a2 && !a3 && a5 && a6 && a7 && a8)
gl_FragColor = vec4(1.);
else if(a3 && a5) else if(a3 && a5) gl_FragColor = vec4(1.);
gl_FragColor = vec4(1.); else if(a1 && a7) gl_FragColor = vec4(1.);
else if(a1 && a7)
gl_FragColor = vec4(1.);
} else { } else {
/**/ if(a0 && a1 && !a2 && a3 && !a5 && !a6 && !a7 && !a8) /**/ if( a0 && a1 && !a2 && a3 && !a5 && !a6 && !a7 && !a8) gl_FragColor = vec4(0.);
gl_FragColor = vec4(0.); else if(!a0 && a1 && a2 && !a3 && a5 && !a6 && !a7 && !a8) gl_FragColor = vec4(0.);
else if(!a0 && a1 && a2 && !a3 && a5 && !a6 && !a7 && !a8) else if(!a0 && !a1 && !a2 && a3 && !a5 && a6 && a7 && !a8) gl_FragColor = vec4(0.);
gl_FragColor = vec4(0.); else if(!a0 && !a1 && !a2 && !a3 && a5 && !a6 && a7 && a8) gl_FragColor = vec4(0.);
else if(!a0 && !a1 && !a2 && a3 && !a5 && a6 && a7 && !a8)
gl_FragColor = vec4(0.);
else if(!a0 && !a1 && !a2 && !a3 && a5 && !a6 && a7 && a8)
gl_FragColor = vec4(0.);
else if(!a3 && !a5) else if(!a3 && !a5) gl_FragColor = vec4(0.);
gl_FragColor = vec4(0.); else if(!a1 && !a7) gl_FragColor = vec4(0.);
else if(!a1 && !a7)
gl_FragColor = vec4(0.);
} }
} }