Pixel-Composer/scripts/node_shape_map/node_shape_map.gml

75 lines
2.1 KiB
Text
Raw Normal View History

2024-02-15 14:23:26 +01:00
function Node_Shape_Map(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Shape Map";
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Surface("Surface in", self));
2024-02-15 14:23:26 +01:00
2024-08-18 06:16:20 +02:00
newInput(1, nodeValue_Bool("Active", self, true));
2024-02-15 14:23:26 +01:00
active_index = 1;
2024-08-20 10:15:53 +02:00
newInput(2, nodeValue_Enum_Scroll("Shape", self, 0, [ new scrollItem("Circle", s_node_shape_circle, 0),
new scrollItem("Polygon", s_node_shape_misc, 1), ]));
2024-02-15 14:23:26 +01:00
2024-08-18 06:16:20 +02:00
newInput(3, nodeValue_Vec2("Map Scale", self, [ 4, 1 ]));
2024-02-15 14:23:26 +01:00
2024-08-18 06:16:20 +02:00
newInput(4, nodeValue_Float("Radius", self, 0.5));
2024-02-15 14:23:26 +01:00
2024-08-18 06:16:20 +02:00
newInput(5, nodeValue_Int("Sides", self, 4));
2024-02-15 14:23:26 +01:00
2024-08-18 09:13:41 +02:00
newInput(6, nodeValue_Float("Scale", self, 1))
2024-02-15 14:23:26 +01:00
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] });
2024-08-18 06:16:20 +02:00
newInput(7, nodeValue_Rotation("Angle", self, 0));
2024-02-15 14:23:26 +01:00
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
2024-02-15 14:23:26 +01:00
input_display_list = [ 1,
["Surfaces", true], 0,
2024-03-17 14:24:24 +01:00
["Shape", false], 2, 5, 6, 7,
2024-02-15 14:23:26 +01:00
["Mapping", false], 3,
];
attribute_surface_depth();
attribute_oversample();
attribute_interpolation();
static step = function() { #region
var _shape = getInputData(2);
2024-08-08 06:57:51 +02:00
inputs[5].setVisible(_shape == 1);
2024-02-15 14:23:26 +01:00
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
var _shape = _data[2];
var _scale = _data[3];
var _radius = _data[4];
var _sides = _data[5];
var _sca = _data[6];
var _rot = _data[7];
var _dim = surface_get_dimension(_data[0]);
if(_shape == 0) {
surface_set_shader(_outSurf, sh_shape_map_circle);
shader_set_interpolation(_data[0]);
2024-06-24 13:49:54 +02:00
shader_set_2("scale", _scale);
2024-02-15 14:23:26 +01:00
shader_set_f("txScale", _sca);
shader_set_f("angle", _rot);
draw_surface_safe(_data[0]);
surface_reset_shader();
} else if(_shape == 1) {
surface_set_shader(_outSurf, sh_shape_map_polygon);
shader_set_interpolation(_data[0]);
shader_set_f("sides", _sides);
2024-06-24 13:49:54 +02:00
shader_set_2("scale", _scale);
2024-02-15 14:23:26 +01:00
shader_set_f("txScale", _sca);
shader_set_f("angle", _rot);
draw_surface_safe(_data[0]);
surface_reset_shader();
}
return _outSurf;
} #endregion
}