Pixel-Composer/scripts/node_attributes/node_attributes.gml

113 lines
4.3 KiB
Plaintext
Raw Normal View History

2023-07-21 12:40:20 +02:00
#region attribute
global.SURFACE_INTERPOLATION = [
new scrollItem("Group").setTooltip("Inherit from parent group.").setActive(false),
new scrollItem("Pixel"),
new scrollItem("Bilinear"),
new scrollItem("Bicubic"),
2024-10-24 12:40:14 +02:00
new scrollItem("Lanczos3"),
2023-07-21 12:40:20 +02:00
];
global.SURFACE_OVERSAMPLE = [
new scrollItem("Group").setTooltip("Inherit from parent group.").setActive(false),
new scrollItem("Empty"),
new scrollItem("Clamp"),
new scrollItem("Repeat"),
new scrollItem("Black"),
2023-07-21 12:40:20 +02:00
];
function __initSurfaceFormat() {
var surface_format = [
-1,
-2,
2023-07-21 12:40:20 +02:00
surface_rgba4unorm,
surface_rgba8unorm,
surface_rgba16float,
surface_rgba32float,
surface_r8unorm,
surface_r16float,
2024-11-04 06:08:06 +01:00
surface_r32float,
2023-07-21 12:40:20 +02:00
];
var surface_format_name = [
new scrollItem("Input" ).setTooltip("Inherit from input surface.").setActive(false),
new scrollItem("Group" ).setTooltip("Inherit from parent group.").setActive(false),
new scrollItem("4 bit RGBA" ).setTooltip("Normalized 4 bit, 4 channels RGBA"),
new scrollItem("8 bit RGBA" ).setTooltip("Normalized 8 bit, 4 channels RGBA"),
new scrollItem("16 bit RGBA" ).setTooltip("16 bit float, 4 channels RGBA"),
new scrollItem("32 bit RGBA" ).setTooltip("32 bit float, 4 channels RGBA"),
new scrollItem("8 bit Greyscale" ).setTooltip("Normalized 8 bit, single channel"),
new scrollItem("16 bit Greyscale").setTooltip("16 bit float, single channel"),
new scrollItem("32 bit Greyscale").setTooltip("32 bit float, single channel"),
2023-07-21 12:40:20 +02:00
];
global.SURFACE_FORMAT = [];
global.SURFACE_FORMAT_NAME = [];
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(surface_format); i < n; i++ ) {
var _form = surface_format[i];
var _supp = _form < 0 || surface_format_is_supported(_form);
2023-07-21 12:40:20 +02:00
array_push(global.SURFACE_FORMAT, _form);
array_push(global.SURFACE_FORMAT_NAME, surface_format_name[i]);
if(!_supp) {
log_message("WARNING", $"Surface format [{surface_format_name[i].name}] not supported in this device.");
surface_format_name[i].setActive(false);
}
2023-07-21 12:40:20 +02:00
}
}
function __attribute_set(node, key, value) {
node.attributes[$ key] = value;
node.triggerRender();
}
function attribute_set(key, value) {
if(PANEL_INSPECTOR == noone) return;
if(PANEL_INSPECTOR.inspecting)
__attribute_set(PANEL_INSPECTOR.inspecting, key, value);
2023-07-21 12:40:20 +02:00
if(PANEL_INSPECTOR.inspectGroup == 1)
for( var i = 0, n = array_length(PANEL_INSPECTOR.inspectings); i < n; i++ )
__attribute_set(PANEL_INSPECTOR.inspectings[i], key, value);
2023-07-21 12:40:20 +02:00
}
function attribute_surface_depth(label = true) {
attr_depth_array = variable_clone(global.SURFACE_FORMAT_NAME);
attr_depth_array[0].setActive(!array_empty(inputs) && inputs[0].type == VALUE_TYPE.surface);
attributes.color_depth = 3;
2023-07-21 12:40:20 +02:00
if(label) array_push(attributeEditors, "Surface");
array_push(attributeEditors, ["Color depth", function() /*=>*/ {return attributes.color_depth},
new scrollBox(attr_depth_array, function(val) /*=>*/ { attribute_set("color_depth", val); }, false), "color_depth"]);
2023-07-21 12:40:20 +02:00
}
function attribute_interpolation(label = false) {
attr_interpolate_array = variable_clone(global.SURFACE_INTERPOLATION);
attributes.interpolate = 1;
attributes.oversample = 1;
2023-07-21 12:40:20 +02:00
if(label) array_push(attributeEditors, "Surface");
array_push(attributeEditors, ["Texture interpolation", function() /*=>*/ {return attributes.interpolate},
2024-10-18 04:47:55 +02:00
new scrollBox(attr_interpolate_array, function(val) /*=>*/ { attribute_set("interpolate", val); }, false), "interpolate"]);
2023-07-21 12:40:20 +02:00
}
function attribute_oversample(label = false) {
attr_oversample_array = variable_clone(global.SURFACE_OVERSAMPLE);
attributes.interpolate = 1;
attributes.oversample = 1;
2023-07-21 12:40:20 +02:00
if(label) array_push(attributeEditors, "Surface");
array_push(attributeEditors, ["Oversample", function() /*=>*/ {return attributes.oversample},
2024-10-18 04:47:55 +02:00
new scrollBox(attr_oversample_array, function(val) /*=>*/ { attribute_set("oversample", val); }, false), "oversample"]);
2023-07-21 12:40:20 +02:00
}
function attribute_auto_execute(label = false) {
attributes.auto_exe = false;
2023-07-21 12:40:20 +02:00
if(label) array_push(attributeEditors, "Node");
array_push(attributeEditors, ["Auto execute", function() /*=>*/ {return attributes.auto_exe},
new checkBox(function() /*=>*/ { attribute_set("auto_exe", !attributes.auto_exe); })]);
2023-07-21 12:40:20 +02:00
}
#endregion