From c1b18c3471854f07ff2b1044afdcab4e13b098e9 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sun, 25 Aug 2024 15:18:22 +0700 Subject: [PATCH] vec4 --- PixelComposer.resource_order | 1 + PixelComposer.yyp | 1 + .../Obj_FirebaseFirestore_Document_Set.yy | 4 +- .../o_dialog_file_name_action.yy | 4 +- objects/o_dialog_menubox/o_dialog_menubox.yy | 8 +- objects/o_main/o_main.yy | 38 +++---- scripts/angle_functions/angle_functions.gml | 25 +++-- .../node_3d_transform/node_3d_transform.gml | 4 +- .../node_3d_transform_image.gml | 16 ++- scripts/node_mk_subpixel/node_mk_subpixel.gml | 30 +++++- scripts/node_region_fill/node_region_fill.gml | 8 +- scripts/node_registry/node_registry.gml | 1 + scripts/node_scatter/node_scatter.gml | 76 +++++++------ scripts/node_shape/node_shape.gml | 78 ++++++++------ scripts/node_smear/node_smear.gml | 4 + scripts/node_value/node_value.gml | 1 - scripts/node_warp/node_warp.gml | 33 +++--- .../node_wrap_perspective.gml | 61 +++++------ shaders/sh_color_remove/sh_color_remove.fsh | 3 +- shaders/sh_color_replace/sh_color_replace.fsh | 3 +- .../sh_colours_replace/sh_colours_replace.fsh | 5 +- .../sh_d3d_3d_transform.fsh | 9 ++ .../sh_d3d_3d_transform.vsh | 19 ++++ .../sh_d3d_3d_transform.yy | 12 +++ shaders/sh_dither/sh_dither.fsh | 4 +- .../sh_mk_subpixel_chevron.fsh | 28 ++++- .../sh_mk_subpixel_diagonal.fsh | 28 ++++- .../sh_mk_subpixel_hex_disc.fsh | 31 +++++- .../sh_mk_subpixel_linear.fsh | 28 ++++- .../sh_mk_subpixel_linear_block.fsh | 28 ++++- .../sh_mk_subpixel_linear_block_offset.fsh | 28 ++++- .../sh_mk_subpixel_square.fsh | 28 ++++- .../sh_mk_subpixel_square_non.fsh | 28 ++++- .../sh_palette_replace/sh_palette_replace.fsh | 5 +- shaders/sh_palette_shift/sh_palette_shift.fsh | 3 +- .../sh_region_fill_color.fsh | 3 +- shaders/sh_shape/sh_shape.fsh | 65 ++++++----- shaders/sh_smear/sh_smear.fsh | 4 +- shaders/sh_warp_4points/sh_warp_4points.fsh | 3 + .../sh_warp_4points_pers.fsh | 102 ++++++++---------- 40 files changed, 575 insertions(+), 285 deletions(-) create mode 100644 shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.fsh create mode 100644 shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.vsh create mode 100644 shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index d015b78ce..f3d3e4d3f 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -1472,6 +1472,7 @@ {"name":"sh_cross_section","order":25,"path":"shaders/sh_cross_section/sh_cross_section.yy",}, {"name":"sh_curve_hsv","order":54,"path":"shaders/sh_curve_hsv/sh_curve_hsv.yy",}, {"name":"sh_curve","order":3,"path":"shaders/sh_curve/sh_curve.yy",}, + {"name":"sh_d3d_3d_transform","order":15,"path":"shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy",}, {"name":"sh_d3d_background","order":8,"path":"shaders/sh_d3d_background/sh_d3d_background.yy",}, {"name":"sh_d3d_extrude_extends","order":11,"path":"shaders/sh_d3d_extrude_extends/sh_d3d_extrude_extends.yy",}, {"name":"sh_d3d_geometry","order":9,"path":"shaders/sh_d3d_geometry/sh_d3d_geometry.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 13a62e900..2a91bdda2 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -2128,6 +2128,7 @@ {"id":{"name":"sh_cross_section","path":"shaders/sh_cross_section/sh_cross_section.yy",},}, {"id":{"name":"sh_curve_hsv","path":"shaders/sh_curve_hsv/sh_curve_hsv.yy",},}, {"id":{"name":"sh_curve","path":"shaders/sh_curve/sh_curve.yy",},}, + {"id":{"name":"sh_d3d_3d_transform","path":"shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy",},}, {"id":{"name":"sh_d3d_background","path":"shaders/sh_d3d_background/sh_d3d_background.yy",},}, {"id":{"name":"sh_d3d_default","path":"shaders/sh_d3d_default/sh_d3d_default.yy",},}, {"id":{"name":"sh_d3d_extrude_extends","path":"shaders/sh_d3d_extrude_extends/sh_d3d_extrude_extends.yy",},}, diff --git a/objects/Obj_FirebaseFirestore_Document_Set/Obj_FirebaseFirestore_Document_Set.yy b/objects/Obj_FirebaseFirestore_Document_Set/Obj_FirebaseFirestore_Document_Set.yy index 914de4527..3b0824cb6 100644 --- a/objects/Obj_FirebaseFirestore_Document_Set/Obj_FirebaseFirestore_Document_Set.yy +++ b/objects/Obj_FirebaseFirestore_Document_Set/Obj_FirebaseFirestore_Document_Set.yy @@ -2,8 +2,8 @@ "$GMObject":"", "%Name":"Obj_FirebaseFirestore_Document_Set", "eventList":[ - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":7,"eventType":6,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":7,"eventType":6,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"Obj_FirebaseFirestore_Document_Set", diff --git a/objects/o_dialog_file_name_action/o_dialog_file_name_action.yy b/objects/o_dialog_file_name_action/o_dialog_file_name_action.yy index 7d5836c8e..3706c1e9c 100644 --- a/objects/o_dialog_file_name_action/o_dialog_file_name_action.yy +++ b/objects/o_dialog_file_name_action/o_dialog_file_name_action.yy @@ -2,8 +2,8 @@ "$GMObject":"", "%Name":"o_dialog_file_name_action", "eventList":[ - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"o_dialog_file_name_action", diff --git a/objects/o_dialog_menubox/o_dialog_menubox.yy b/objects/o_dialog_menubox/o_dialog_menubox.yy index 783b8bf8b..49a445f6a 100644 --- a/objects/o_dialog_menubox/o_dialog_menubox.yy +++ b/objects/o_dialog_menubox/o_dialog_menubox.yy @@ -2,10 +2,10 @@ "$GMObject":"", "%Name":"o_dialog_menubox", "eventList":[ - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"o_dialog_menubox", diff --git a/objects/o_main/o_main.yy b/objects/o_main/o_main.yy index fa6e466ef..c26819bb9 100644 --- a/objects/o_main/o_main.yy +++ b/objects/o_main/o_main.yy @@ -2,25 +2,25 @@ "$GMObject":"", "%Name":"o_main", "eventList":[ - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":5,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":2,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":3,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":4,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":20,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":60,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":62,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":68,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":69,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":70,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":10,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":5,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":2,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":3,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":4,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":20,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":60,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":62,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":68,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":69,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":70,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":10,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"o_main", diff --git a/scripts/angle_functions/angle_functions.gml b/scripts/angle_functions/angle_functions.gml index c24bc94b6..9e945ef10 100644 --- a/scripts/angle_functions/angle_functions.gml +++ b/scripts/angle_functions/angle_functions.gml @@ -1,8 +1,6 @@ -function angle_random_eval(range, seed = undefined) { +function angle_random_eval(range, seed = random_get_seed()) { if(is_real(range)) return range; - if(seed != undefined) random_set_seed(seed); - if(array_empty(range)) return 0; var _l = array_length(range); @@ -10,26 +8,27 @@ function angle_random_eval(range, seed = undefined) { return range[0] else if(_l == 2) - return irandom_range(range[0], range[1]); + return random_range_seed(range[0], range[1], seed); else if(_l > 2) { switch(range[0]) { - case 0 : return irandom_range(range[1], range[2]); - case 1 : return irandom_range(range[1] - range[2], range[1] + range[2]); - case 2 : return choose(irandom_range(range[1], range[2]), irandom_range(range[3], range[4])); - case 3 : return choose(irandom_range(range[1] - range[3], range[1] + range[3]), irandom_range(range[2] - range[3], range[2] + range[3])); + case 0 : return random_range_seed(range[1], range[2], seed); + case 1 : return random_range_seed(range[1] - range[2], range[1] + range[2], seed); + case 2 : return choose(random_range_seed(range[1], range[2], seed), random_range_seed(range[3], range[4], seed)); + case 3 : return choose(random_range_seed(range[1] - range[3], range[1] + range[3], seed), random_range_seed(range[2] - range[3], range[2] + range[3], seed)); } } return array_safe_get_fast(range, 0); } -function angle_random_eval_fast(range) { +function angle_random_eval_fast(range, seed = random_get_seed()) { + switch(range[0]) { - case 0 : return irandom_range(range[1], range[2]); - case 1 : return irandom_range(range[1] - range[2], range[1] + range[2]); - case 2 : return choose(irandom_range(range[1], range[2]), irandom_range(range[3], range[4])); - case 3 : return choose(irandom_range(range[1] - range[3], range[1] + range[3]), irandom_range(range[2] - range[3], range[2] + range[3])); + case 0 : return random_range_seed(range[1], range[2], seed); + case 1 : return random_range_seed(range[1] - range[2], range[1] + range[2], seed); + case 2 : return choose(random_range_seed(range[1], range[2], seed), random_range_seed(range[3], range[4], seed)); + case 3 : return choose(random_range_seed(range[1] - range[3], range[1] + range[3], seed), random_range_seed(range[2] - range[3], range[2] + range[3], seed)); } return 0; } \ No newline at end of file diff --git a/scripts/node_3d_transform/node_3d_transform.gml b/scripts/node_3d_transform/node_3d_transform.gml index 52b000919..afa72b95c 100644 --- a/scripts/node_3d_transform/node_3d_transform.gml +++ b/scripts/node_3d_transform/node_3d_transform.gml @@ -10,7 +10,7 @@ function Node_3D_Transform(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _gro ["Transform", false], 0, 1, 2, ]; - static processData = function(_output, _data, _output_index, _array_index = 0) { #region + static processData = function(_output, _data, _output_index, _array_index = 0) { var _mesh = _data[in_d3d + 0]; var _scene = new __3dGroup(); @@ -20,5 +20,5 @@ function Node_3D_Transform(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _gro _scene.addObject(_mesh); return _scene; - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_3d_transform_image/node_3d_transform_image.gml b/scripts/node_3d_transform_image/node_3d_transform_image.gml index d0c996d01..bbd25bdab 100644 --- a/scripts/node_3d_transform_image/node_3d_transform_image.gml +++ b/scripts/node_3d_transform_image/node_3d_transform_image.gml @@ -20,8 +20,10 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, newInput(in_mesh + 2, nodeValue_Float("FOV", self, 45)); + newInput(in_mesh + 3, nodeValue_Vec2("Texture Tiling", self, [ 1, 1 ])); + input_display_list = [ - ["Material", false], in_mesh + 0, + ["Material", false], in_mesh + 0, in_mesh + 3, __d3d_input_list_transform, ["Camera", false], in_mesh + 1, in_mesh + 2, ] @@ -31,6 +33,8 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, output_display_list = [ 1 ] + attribute_interpolation(); + static onDrawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { var _outSurf = outputs[1].getValue(); if(is_array(_outSurf)) _outSurf = array_safe_get_fast(_outSurf, preview_index); @@ -57,6 +61,7 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, var _surf = _data[in_mesh + 0]; var _proj = _data[in_mesh + 1]; var _fov = _data[in_mesh + 2]; + var _tile = _data[in_mesh + 3]; if(!is_surface(_surf)) return 0; if(_output_index == 0) { @@ -78,11 +83,13 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, 1, 0, 0); _output = surface_verify(_output, _dim[0], _dim[1]); - surface_set_target(_output); - DRAW_CLEAR + surface_set_shader(_output, sh_d3d_3d_transform); + shader_set_2("tiling", _tile); + camera_set_view_mat(camera, viewMat); camera_set_proj_mat(camera, projMat); camera_apply(camera); + gpu_set_texfilter(attributes.interpolate); object.transform.submitMatrix(); matrix_set(matrix_world, matrix_stack_top()); @@ -93,7 +100,8 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, matrix_set(matrix_world, matrix_build_identity()); camera_apply(0); - surface_reset_target(); + gpu_set_texfilter(false); + surface_reset_shader(); return _output; } diff --git a/scripts/node_mk_subpixel/node_mk_subpixel.gml b/scripts/node_mk_subpixel/node_mk_subpixel.gml index d98e2275c..56f473450 100644 --- a/scripts/node_mk_subpixel/node_mk_subpixel.gml +++ b/scripts/node_mk_subpixel/node_mk_subpixel.gml @@ -32,11 +32,22 @@ function Node_MK_Subpixel(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou newInput(12, nodeValue_Float("Scene Scale", self, 1)); + newInput(13, nodeValue_Bool("Flicker", self, false)); + + newInput(14, nodeValue_Float("Flicker Intensity", self, .2)) + .setDisplay(VALUE_DISPLAY.slider); + + newInput(15, nodeValue_Float("Flicker Frequency", self, 4)) + + newInput(16, nodeValue_Float("Flicker Cut", self, .5)) + .setDisplay(VALUE_DISPLAY.slider); + input_display_list = [ new Inspector_Sprite(s_MKFX), 7, - ["Subpixel", false], 1, 2, 12, - ["Effect", false], 3, 4, 8, - ["Render", false], 6, 5, - ["Ridge", false, 11], 9, 10, + ["Subpixel", false], 1, 2, 12, + ["Effect", false], 3, 4, 8, + ["Ridge", false, 11], 9, 10, + ["Render", false], 6, 5, + ["Flicker", false, 13], 14, 15, 16, ]; outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone); @@ -54,6 +65,12 @@ function Node_MK_Subpixel(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou var _rgin = _data[10]; var _ruse = _data[11]; var _scns = _data[12]; + var _flku = _data[13]; + var _flki = _data[14]; + var _flkf = _data[15]; + var _flkc = _data[16]; + + update_on_frame = _flku; var _dim = surface_get_dimension(_surf); var sh = sh_mk_subpixel_hex_disc; @@ -84,6 +101,11 @@ function Node_MK_Subpixel(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou shader_set_f("ridgeCount", _rgcn); shader_set_f("ridgeIntens", _rgin); + shader_set_i("flickerUse", _flku); + shader_set_f("flickerIntens", _flki); + shader_set_f("flickerCut", _flkc); + shader_set_f("flickerTime", (CURRENT_FRAME / TOTAL_FRAMES) * pi * _flkf); + var _cx = _dim[0] / 2; var _cy = _dim[1] / 2; var _px = _cx - _dim[0] * _scns / 2; diff --git a/scripts/node_region_fill/node_region_fill.gml b/scripts/node_region_fill/node_region_fill.gml index 55f8d9a95..1e0f71c1c 100644 --- a/scripts/node_region_fill/node_region_fill.gml +++ b/scripts/node_region_fill/node_region_fill.gml @@ -167,14 +167,10 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou switch(_filt) { case 0 : // Random colors - var _pal = []; - for( var i = 0, n = array_length(_colr); i < n; i++ ) - array_append(_pal, colToVec4(_colr[i])); - + shader_set(sh_region_fill_color); - shader_set_f("colors", _pal); + shader_set_palette(_colr, "color", "colorAmount"); shader_set_f("seed", _seed); - shader_set_f("colorAmount", array_length(_colr)); draw_surface_safe(cmap); shader_reset(); diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 9c92c164b..a7750e285 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -554,6 +554,7 @@ function __initNodes() { addNodeObject(transform, "Crop Content", s_node_crop_content, "Node_Crop_Content", [1, Node_Crop_Content],, "Crop out empty pixel from the image."); addNodeObject(transform, "Bend", s_node_bend, "Node_Bend", [1, Node_Bend], ["wrap"], "Warp an image into a predefined shape.").setVersion(11650); addNodeObject(transform, "Warp", s_node_warp, "Node_Warp", [1, Node_Warp], ["warp corner"], "Warp image by freely moving the corners."); + // addNodeObject(transform, "Perspective Warp",s_node_warp, "Node_Warp_Perspective",[1, Node_Warp_Perspective], ["warp perspective"], "Warp image by modifying perspective."); addNodeObject(transform, "Skew", s_node_skew, "Node_Skew", [1, Node_Skew], ["shear"], "Skew image horizontally, or vertically."); addNodeObject(transform, "Mesh Warp", s_node_warp_mesh, "Node_Mesh_Warp", [1, Node_Mesh_Warp], ["mesh wrap"], "Wrap image by converting it to mesh, and using control points."); addNodeObject(transform, "Polar", s_node_polar, "Node_Polar", [1, Node_Polar],, "Convert image to polar coordinate."); diff --git a/scripts/node_scatter/node_scatter.gml b/scripts/node_scatter/node_scatter.gml index 5e7411fd5..568b81341 100644 --- a/scripts/node_scatter/node_scatter.gml +++ b/scripts/node_scatter/node_scatter.gml @@ -80,13 +80,13 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c newInput(27, nodeValue_Enum_Scroll("Animated array end", self, 0, [ "Loop", "Ping Pong" ])); - ////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// newInput(28, nodeValueMap("Gradient map", self)); newInput(29, nodeValueGradientRange("Gradient map range", self, inputs[11])); - ////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// newInput(30, nodeValue_Vec2("Uniform amount", self, [ 4, 4 ])); @@ -106,6 +106,10 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c newInput(38, nodeValue_Enum_Button("Spacing", self, 0, [ "After", "Between", "Around" ])); + newInput(39, nodeValue_Range("Shift radial", self, [ 0, 0 ])); + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone); outputs[1] = nodeValue_Output("Atlas data", self, VALUE_TYPE.surface, []) @@ -116,7 +120,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c ["Surfaces", true], 0, 1, 15, 24, 25, 26, 27, ["Scatter", false], 6, 5, 13, 14, 17, 9, 31, 2, 30, 35, ["Path", false], 19, 38, 20, 21, 22, - ["Position", false], 33, 36, 37, + ["Position", false], 33, 36, 37, 39, ["Rotation", false], 7, 4, 32, ["Scale", false], 3, 8, 34, ["Render", false], 18, 11, 28, 12, 16, 23, @@ -134,7 +138,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c scatter_maps = 0; scatter_mapp = []; - static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { PROCESSOR_OVERLAY_CHECK var _distType = current_data[6]; @@ -144,18 +148,18 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c var hv = inputs[29].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, current_data[1]); active &= !hv; _hov |= hv; return _hov; - } #endregion + } - static onValueUpdate = function(index) { #region + static onValueUpdate = function(index) { if(index == 15) { var _arr = getInputData(15); inputs[0].array_depth = _arr; update(); } - } #endregion + } - static step = function() { #region + static step = function() { var _are = getInputData(5); var _dis = getInputData(6); var _sct = getInputData(9); @@ -210,11 +214,11 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c } inputs[11].mappableStep(); - } #endregion + } ////=========== PROCESS =========== - static processData = function(_outSurf, _data, _output_index, _array_index) { #region + static processData = function(_outSurf, _data, _output_index, _array_index) { if(_output_index == 1) return scatter_data; var _inSurf = _data[0]; @@ -266,6 +270,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c var posShf = _data[36]; var posExt = _data[37]; var pthSpac = _data[38]; + var shfRad = _data[39]; var _in_w, _in_h; @@ -359,11 +364,14 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c DRAW_CLEAR switch(blend) { case 0 : - if(mulpA) BLEND_ALPHA_MULP; - else BLEND_ALPHA; + if(mulpA) BLEND_ALPHA_MULP + else BLEND_ALPHA + break; + + case 1 : + BLEND_ADD; break; - case 1 : BLEND_ADD; break; case 2 : BLEND_ALPHA_MULP gpu_set_blendequation(bm_eq_max); @@ -377,8 +385,8 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c var sp = noone, _x = 0, _y = 0; var _v = noone; - var _scx = _scaUniX? _scale[0] : random_range(_scale[0], _scale[1]); - var _scy = _scaUniY? _scale[2] : random_range(_scale[2], _scale[3]); + var _scx = _scaUniX? _scale[0] : random_range_seed(_scale[0], _scale[1], _sed++); + var _scy = _scaUniY? _scale[2] : random_range_seed(_scale[2], _scale[3], _sed++); switch(_dist) { #region position case NODE_SCATTER_DIST.area : @@ -463,13 +471,13 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c } } else { - _pathProgress = random(1); + _pathProgress = random_seed(1, _sed++); _pathProgress = frac(_pathProgress + pathShf); } var pp = path.getPointRatio(_pathProgress, path_line_index); - _x = pp.x + random_range(-pathDis, pathDis); - _y = pp.y + random_range(-pathDis, pathDis); + _x = pp.x + random_range_seed(-pathDis, pathDis, _sed++); + _y = pp.y + random_range_seed(-pathDis, pathDis, _sed++); break; case NODE_SCATTER_DIST.tile : @@ -481,19 +489,25 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c _y = uniAmo[1] == 1? _dim[1] / 2 : (_arow + 0.5) * _dim[1] / ( uniAmo[1] ); } else if(_scat == 1) { - _x = random_range(0, _dim[0]); - _y = random_range(0, _dim[1]); + _x = random_range_seed(0, _dim[0], _sed++); + _y = random_range_seed(0, _dim[1], _sed++); } break; } #endregion - if(_wigX) _x += random_range(posWig[0], posWig[1]); - if(_wigY) _y += random_range(posWig[2], posWig[3]); + if(_wigX) _x += random_range_seed(posWig[0], posWig[1], _sed++); + if(_wigY) _y += random_range_seed(posWig[2], posWig[3], _sed++); _x += posShf[0] * i; _y += posShf[1] * i; + var shrRad = random_range_seed(shfRad[0], shfRad[1], _sed++); + var shrAng = point_direction(_x, _y, _area[0], _area[1]); + + _x -= lengthdir_x(shrRad, shrAng); + _y -= lengthdir_y(shrRad, shrAng); + if(_unis) { _scy = max(_scx, _scy); _scx = _scy; @@ -504,7 +518,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c _scy *= _v; } - var _r = (_pint? point_direction(_area[0], _area[1], _x, _y) : 0) + angle_random_eval_fast(_rota); + var _r = (_pint? point_direction(_area[0], _area[1], _x, _y) : 0) + angle_random_eval_fast(_rota, _sed++); if(vRot && _v != noone) _r *= _v; @@ -523,7 +537,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c var surf = _inSurf; var ind = 0; - if(surfArray) { #region + if(surfArray) { switch(_arr) { case 1 : ind = safe_mod(i, _arrLen); break; case 2 : ind = irandom(_arrLen - 1); break; @@ -549,7 +563,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c } surf = array_safe_get_fast(_inSurf, ind, 0); - } #endregion + } if(surf == 0 || !surface_valid_map[? surf]) continue; @@ -566,17 +580,17 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c _y = _p[1]; } - var grSamp = random(1); + var grSamp = random_seed(1, _sed++); if(vCol && _v != noone) grSamp *= _v; var clr = _clrUni? _clrSin : evaluate_gradient_map(grSamp, color, clr_map, clr_rng, inputs[11], true); - var alp = _alpUni? alpha[0] : random_range(alpha[0], alpha[1]); + var alp = _alpUni? alpha[0] : random_range_seed(alpha[0], alpha[1], _sed++); var _atl = _sct_len >= _datLen? noone : scatter_data[_sct_len]; - if(posExt) { - _x = round(_x); - _y = round(_y); + if(posExt) { + _x = round(_x); + _y = round(_y); } if(_useAtl) { @@ -646,5 +660,5 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c scatter_data = _sct; return _outSurf; - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_shape/node_shape.gml b/scripts/node_shape/node_shape.gml index 7916e4bb0..caa2b5f51 100644 --- a/scripts/node_shape/node_shape.gml +++ b/scripts/node_shape/node_shape.gml @@ -1,32 +1,29 @@ -#region create - global.node_shape_keys = [ - "rectangle", "ellipse", "regular polygon", "star", "arc", "teardrop", "cross", "leaf", "crescent", "donut", - "square", "circle", "triangle", "pentagon", "hexagon", "ring", "diamond", "trapezoid", "parallelogram", "heart", - "arrow", "gear", - ]; +global.node_shape_keys = [ + "rectangle", "ellipse", "regular polygon", "star", "arc", "teardrop", "cross", "leaf", "crescent", "donut", + "square", "circle", "triangle", "pentagon", "hexagon", "ring", "diamond", "trapezoid", "parallelogram", "heart", + "arrow", "gear", +]; + +function Node_create_Shape(_x, _y, _group = noone, _param = {}) { + var query = struct_try_get(_param, "query", ""); + var node = new Node_Shape(_x, _y, _group).skipDefault(); + var ind = -1; - function Node_create_Shape(_x, _y, _group = noone, _param = {}) { - var query = struct_try_get(_param, "query", ""); - var node = new Node_Shape(_x, _y, _group).skipDefault(); - var ind = -1; + switch(query) { + case "square" : ind = array_find_string(node.shape_types, "rectangle"); break; + case "circle" : ind = array_find_string(node.shape_types, "ellipse"); break; + case "ring" : ind = array_find_string(node.shape_types, "donut"); break; + case "triangle" : ind = array_find_string(node.shape_types, "regular polygon"); node.inputs[4].setValue(3); break; + case "pentagon" : ind = array_find_string(node.shape_types, "regular polygon"); node.inputs[4].setValue(5); break; + case "hexagon" : ind = array_find_string(node.shape_types, "regular polygon"); node.inputs[4].setValue(6); break; - switch(query) { - case "square" : ind = array_find_string(node.shape_types, "rectangle"); break; - case "circle" : ind = array_find_string(node.shape_types, "ellipse"); break; - case "ring" : ind = array_find_string(node.shape_types, "donut"); break; - case "triangle" : ind = array_find_string(node.shape_types, "regular polygon"); node.inputs[4].setValue(3); break; - case "pentagon" : ind = array_find_string(node.shape_types, "regular polygon"); node.inputs[4].setValue(5); break; - case "hexagon" : ind = array_find_string(node.shape_types, "regular polygon"); node.inputs[4].setValue(6); break; - - default : ind = array_find_string(node.shape_types, query); - } - - if(ind >= 0) node.inputs[2].setValue(ind); - - return node; + default : ind = array_find_string(node.shape_types, query); } -#endregion + if(ind >= 0) node.inputs[2].setValue(ind); + + return node; +} function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "Draw Shape"; @@ -116,14 +113,19 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con newInput(26, nodeValue_Vec2("Teeth Size", self, [ 0.2, 0.2 ] , { slideSpeed : 0.01 })); newInput(27, nodeValue_Rotation("Teeth Rotation", self, 0)); - + + newInput(28, nodeValue_Float("Shape Scale", self, 1)) + .setDisplay(VALUE_DISPLAY.slider); + + newInput(29, nodeValue_Slider_Range("Curve", self, [ 0, 1 ])); + outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone); input_display_list = [ ["Output", false], 0, 6, - ["Transform", false], 15, 3, 16, 17, 19, + ["Transform", false], 15, 3, 16, 17, 19, 28, ["Shape", false], 14, 2, 9, 4, 13, 5, 7, 8, 21, 22, 23, 24, 25, 26, 27, - ["Render", true], 10, 12, 20, 18, + ["Render", true], 10, 12, 20, 29, 18, ["Background", true, 1], 11, ]; @@ -239,6 +241,8 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con var _tile = _data[18]; var _rotat = _data[19]; var _level = _data[20]; + var _levelO = _data[29]; + var _shpSca = _data[28]; var _center = [ 0, 0 ]; var _scale = [ 0, 0 ]; @@ -250,6 +254,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con _center = [ _area[0] / _dim[0], _area[1] / _dim[1] ]; _scale = [ abs(_area[2] / _dim[0]), abs(_area[3] / _dim[1]) ]; break; + case 1 : var _posit = _data[16]; var _scal = _data[17]; @@ -257,12 +262,18 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con _center = [ _posit[0] / _dim[0], _posit[1] / _dim[1] ]; _scale = [ abs(_scal[0] / _dim[0]), abs(_scal[1] / _dim[1]) ]; break; + case 2 : _center = [ 0.5, 0.5 ]; _scale = [ 0.5, 0.5 ]; break; } + _scale[0] *= _shpSca; + _scale[1] *= _shpSca; + + _level = [ _level[0] / _shpSca, _level[1] / _shpSca]; + inputs[ 3].setVisible(_posTyp == 0); inputs[16].setVisible(_posTyp == 1); inputs[17].setVisible(_posTyp == 1); @@ -329,8 +340,12 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con } surface_set_shader(_outSurf, sh_shape); - if(_bg) draw_clear_alpha(0, 1); - else DRAW_CLEAR + if(_bg) { + draw_clear_alpha(0, 1); + } else { + DRAW_CLEAR + BLEND_OVERRIDE + } inputs[ 4].setVisible(false); inputs[ 5].setVisible(false); @@ -538,13 +553,16 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con shader_set_f("dimension", _dim); shader_set_f("bgColor", _bgcol); shader_set_i("aa", _aa); + shader_set_i("drawBG", _bg); shader_set_i("drawDF", _df); shader_set_2("dfLevel", _level); + shader_set_2("dfLevelOut", _levelO); shader_set_i("tile", _tile); shader_set_f("corner", _corner); shader_set_2("center", _center); shader_set_2("scale", _scale ); + shader_set_f("shapeScale",_shpSca); shader_set_f("rotation", degtorad(_rotat)); draw_sprite_stretched_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], _color, _color_get_alpha(_color)); diff --git a/scripts/node_smear/node_smear.gml b/scripts/node_smear/node_smear.gml index 2cc9d0000..b13fc36a5 100644 --- a/scripts/node_smear/node_smear.gml +++ b/scripts/node_smear/node_smear.gml @@ -39,9 +39,12 @@ function Node_Smear(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con newInput(14, nodeValue_Bool("Invert", self, false)); + newInput(15, nodeValue_Enum_Scroll("Blend Mode", self, 0, [ "Maximum", "Additive" ])); + input_display_list = [ 5, 6, ["Surfaces", true], 0, 3, 4, 7, 8, ["Smear", false], 11, 14, 1, 9, 2, 10, 13, 12, + ["Render", false], 15, ] outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone); @@ -84,6 +87,7 @@ function Node_Smear(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con shader_set_i("sampleMode", struct_try_get(attributes, "oversample")); shader_set_i("alpha", _data[11]); shader_set_i("inv", _data[14]); + shader_set_i("blend", _data[15]); shader_set_i("modulateStr", _data[12]); shader_set_f("spread", _data[13]); diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 6776169f0..67016eb31 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -639,7 +639,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru editWidget = new vectorRangeBox(array_length(val), _txt, function(val, index) { return setValueInspector(val, index); }, unit ); - if(!struct_has(display_data, "linked")) display_data.linked = false; if(!struct_has(display_data, "ranged")) display_data.ranged = false; diff --git a/scripts/node_warp/node_warp.gml b/scripts/node_warp/node_warp.gml index e79226f2e..374f3f0bb 100644 --- a/scripts/node_warp/node_warp.gml +++ b/scripts/node_warp/node_warp.gml @@ -22,10 +22,12 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons newInput(7, nodeValue_Dimension(self)); + newInput(8, nodeValue_Bool("Tile", self, false)); + outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone); input_display_list = [ 5, - ["Surfaces", false], 0, 6, 7, + ["Surfaces", false], 0, 6, 7, 8, ["Wrap", false], 1, 2, 3, 4 ] @@ -242,19 +244,22 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons #endregion } - static warpSurface = function(surf, warp, sw, sh, tl, tr, bl, br, filt = false) { + static warpSurface = function(surf, warp, sw, sh, tl, tr, bl, br, tile = false) { var teq = round(tl[1]) == round(tr[1]); var beq = round(bl[1]) == round(br[1]); var leq = round(tl[0]) == round(bl[0]); var req = round(tr[0]) == round(br[0]); - if(teq && beq && leq && req) { + var _wdim = surface_get_dimension(warp); + + if(teq && beq && leq && req) { // rectangle surface_set_shader(surf) shader_set_interpolation(warp); - if(filt) gpu_set_tex_filter(true); - draw_surface_stretched_safe(warp, tl[0], tl[1], tr[0] - tl[0], bl[1] - tl[1]); - if(filt) gpu_set_tex_filter(false); + // if(filt) gpu_set_tex_filter(true); + if(tile) draw_surface_tiled_ext(warp, tl[0], tl[1], (tr[0] - tl[0]) / _wdim[0], (bl[1] - tl[1]) / _wdim[1], c_white, 1); + else draw_surface_stretched_safe(warp, tl[0], tl[1], tr[0] - tl[0], bl[1] - tl[1]); + // if(filt) gpu_set_tex_filter(false); surface_reset_shader(); } else { @@ -266,19 +271,21 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons shader_set_f("p1", tr[0] / sw, tr[1] / sh); shader_set_f("p2", tl[0] / sw, tl[1] / sh); shader_set_f("p3", bl[0] / sw, bl[1] / sh); + shader_set_i("tile", tile); - if(filt) gpu_set_tex_filter(true); + // if(filt) gpu_set_tex_filter(true); draw_surface_stretched(warp, 0, 0, sw, sh); - if(filt) gpu_set_tex_filter(false); + // if(filt) gpu_set_tex_filter(false); surface_reset_shader(); } } static processData = function(_outSurf, _data, _output_index, _array_index) { - var tl = _data[1]; - var tr = _data[2]; - var bl = _data[3]; - var br = _data[4]; + var tl = _data[1]; + var tr = _data[2]; + var bl = _data[3]; + var br = _data[4]; + var tile = _data[8]; var _useDim = _data[6]; var _dim = _data[7]; @@ -288,7 +295,7 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons var sw = _useDim? _dim[0] : surface_get_width_safe(_data[0]); var sh = _useDim? _dim[1] : surface_get_height_safe(_data[0]); - warpSurface(_outSurf, _data[0], sw, sh, tl, tr, bl, br); + warpSurface(_outSurf, _data[0], sw, sh, tl, tr, bl, br, tile); return _outSurf; } diff --git a/scripts/node_wrap_perspective/node_wrap_perspective.gml b/scripts/node_wrap_perspective/node_wrap_perspective.gml index 440700bb8..de4d0e5d0 100644 --- a/scripts/node_wrap_perspective/node_wrap_perspective.gml +++ b/scripts/node_wrap_perspective/node_wrap_perspective.gml @@ -7,34 +7,33 @@ function Node_Warp_Perspective(_x, _y, _group = noone) : Node_Processor(_x, _y, active_index = 1; newInput(2, nodeValue_Vec2("Top left", self, [ 0, 0 ] )) - .setUnitRef(function(index) { return getDimension(index); }); + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); - newInput(3, nodeValue_Vec2("Top right", self, [ DEF_SURF_W, 0 ] )) - .setUnitRef(function(index) { return getDimension(index); }); + newInput(3, nodeValue_Vec2("Top right", self, [ 1, 0 ] )) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); - newInput(4, nodeValue_Vec2("Bottom left", self, [ 0, DEF_SURF_H ] )) - .setUnitRef(function(index) { return getDimension(index); }); + newInput(4, nodeValue_Vec2("Bottom left", self, [ 0, 1 ] )) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); - newInput(5, nodeValue_Vec2("Bottom right", self, DEF_SURF )) - .setUnitRef(function(index) { return getDimension(index); }); + newInput(5, nodeValue_Vec2("Bottom right", self, [ 1, 1 ] )) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); newInput(6, nodeValue_Vec2("Top left", self, [ 0, 0 ] )) - .setUnitRef(function(index) { return getDimension(index); }); + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); - newInput(7, nodeValue_Vec2("Top right", self, [ DEF_SURF_W, 0 ] )) - .setUnitRef(function(index) { return getDimension(index); }); + newInput(7, nodeValue_Vec2("Top right", self, [ 1, 0 ] )) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); - newInput(8, nodeValue_Vec2("Bottom left", self, [ 0, DEF_SURF_H ] )) - .setUnitRef(function(index) { return getDimension(index); }); + newInput(8, nodeValue_Vec2("Bottom left", self, [ 0, 1 ] )) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); - newInput(9, nodeValue_Vec2("Bottom right", self, DEF_SURF )) - .setUnitRef(function(index) { return getDimension(index); }); + newInput(9, nodeValue_Vec2("Bottom right", self, [ 1, 1 ] )) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone); input_display_list = [ 1, ["Surfaces", false], 0, - ["Origin", false], 2, 3, 4, 5, ["Warp", false], 6, 7, 8, 9, ] @@ -42,9 +41,9 @@ function Node_Warp_Perspective(_x, _y, _group = noone) : Node_Processor(_x, _y, attribute_interpolation(); drag_side = -1; - drag_mx = 0; - drag_my = 0; - drag_s = [[0, 0], [0, 0]]; + drag_mx = 0; + drag_my = 0; + drag_s = [[0, 0], [0, 0]]; static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { PROCESSOR_OVERLAY_CHECK @@ -187,30 +186,20 @@ function Node_Warp_Perspective(_x, _y, _group = noone) : Node_Processor(_x, _y, } static processData = function(_outSurf, _data, _output_index, _array_index) { - var Ftl = _data[2]; - var Ftr = _data[3]; - var Fbl = _data[4]; - var Fbr = _data[5]; - - var Ttl = _data[6]; - var Ttr = _data[7]; - var Tbl = _data[8]; - var Tbr = _data[9]; + var tl = _data[6]; + var tr = _data[7]; + var bl = _data[8]; + var br = _data[9]; var sw = surface_get_width_safe(_data[0]); var sh = surface_get_height_safe(_data[0]); surface_set_shader(_outSurf, sh_warp_4points_pers); shader_set_interpolation(_data[0]); - shader_set_f("f1", Fbr[0] / sw, Fbr[1] / sh); - shader_set_f("f2", Ftr[0] / sw, Ftr[1] / sh); - shader_set_f("f3", Ftl[0] / sw, Ftl[1] / sh); - shader_set_f("f4", Fbl[0] / sw, Fbl[1] / sh); - - shader_set_f("t1", Tbr[0] / sw, Tbr[1] / sh); - shader_set_f("t2", Ttr[0] / sw, Ttr[1] / sh); - shader_set_f("t3", Ttl[0] / sw, Ttl[1] / sh); - shader_set_f("t4", Tbl[0] / sw, Tbl[1] / sh); + shader_set_f("t1", tl[0] / sw, tl[1] / sh); + shader_set_f("t2", tr[0] / sw, tr[1] / sh); + shader_set_f("t3", bl[0] / sw, bl[1] / sh); + shader_set_f("t4", br[0] / sw, br[1] / sh); draw_surface_safe(_data[0]); surface_reset_shader(); diff --git a/shaders/sh_color_remove/sh_color_remove.fsh b/shaders/sh_color_remove/sh_color_remove.fsh index e236e0933..1807d47a1 100644 --- a/shaders/sh_color_remove/sh_color_remove.fsh +++ b/shaders/sh_color_remove/sh_color_remove.fsh @@ -1,10 +1,11 @@ +#define PALETTE_LIMIT 1024 // // Simple passthrough fragment shader // varying vec2 v_vTexcoord; varying vec4 v_vColour; -uniform vec4 colorFrom[32]; +uniform vec4 colorFrom[PALETTE_LIMIT]; uniform int colorFrom_amo; uniform int invert; diff --git a/shaders/sh_color_replace/sh_color_replace.fsh b/shaders/sh_color_replace/sh_color_replace.fsh index e8c188e30..023131993 100644 --- a/shaders/sh_color_replace/sh_color_replace.fsh +++ b/shaders/sh_color_replace/sh_color_replace.fsh @@ -1,10 +1,11 @@ +#define PALETTE_LIMIT 1024 // // Simple passthrough fragment shader // varying vec2 v_vTexcoord; varying vec4 v_vColour; -uniform vec4 colorFrom[32]; +uniform vec4 colorFrom[PALETTE_LIMIT]; uniform int colorFrom_amo; uniform vec4 colorTo; uniform int inverted; diff --git a/shaders/sh_colours_replace/sh_colours_replace.fsh b/shaders/sh_colours_replace/sh_colours_replace.fsh index 3a9cb99f1..3c15228db 100644 --- a/shaders/sh_colours_replace/sh_colours_replace.fsh +++ b/shaders/sh_colours_replace/sh_colours_replace.fsh @@ -1,13 +1,14 @@ +#define PALETTE_LIMIT 1024 // // Simple passthrough fragment shader // varying vec2 v_vTexcoord; varying vec4 v_vColour; -uniform vec4 colorFrom[64]; +uniform vec4 colorFrom[PALETTE_LIMIT]; uniform int colorFromAmount; -uniform vec4 colorTo[64]; +uniform vec4 colorTo[PALETTE_LIMIT]; uniform int colorToAmount; uniform int useMask; diff --git a/shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.fsh b/shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.fsh new file mode 100644 index 000000000..59790fa1d --- /dev/null +++ b/shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.fsh @@ -0,0 +1,9 @@ +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec2 tiling; + +void main() { + vec2 px = fract(v_vTexcoord * tiling); + gl_FragColor = texture2D( gm_BaseTexture, px ); +} diff --git a/shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.vsh b/shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.vsh @@ -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; +} diff --git a/shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy b/shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy new file mode 100644 index 000000000..e455e01c1 --- /dev/null +++ b/shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy @@ -0,0 +1,12 @@ +{ + "$GMShader":"", + "%Name":"sh_d3d_3d_transform", + "name":"sh_d3d_3d_transform", + "parent":{ + "name":"3d", + "path":"folders/shader/3d.yy", + }, + "resourceType":"GMShader", + "resourceVersion":"2.0", + "type":1, +} \ No newline at end of file diff --git a/shaders/sh_dither/sh_dither.fsh b/shaders/sh_dither/sh_dither.fsh index 13bde3423..9a0f776c8 100644 --- a/shaders/sh_dither/sh_dither.fsh +++ b/shaders/sh_dither/sh_dither.fsh @@ -1,6 +1,8 @@ // // Simple passthrough fragment shader // +#define PALETTE_LIMIT 1024 + varying vec2 v_vTexcoord; varying vec4 v_vColour; @@ -15,7 +17,7 @@ uniform int useConMap; uniform float ditherSize; uniform float dither[64]; uniform vec2 dimension; -uniform vec4 palette[1024]; +uniform vec4 palette[PALETTE_LIMIT]; uniform int keys; uniform float seed; diff --git a/shaders/sh_mk_subpixel_chevron/sh_mk_subpixel_chevron.fsh b/shaders/sh_mk_subpixel_chevron/sh_mk_subpixel_chevron.fsh index e9b9f8fdd..8fd5ff030 100644 --- a/shaders/sh_mk_subpixel_chevron/sh_mk_subpixel_chevron.fsh +++ b/shaders/sh_mk_subpixel_chevron/sh_mk_subpixel_chevron.fsh @@ -1,3 +1,4 @@ +#define TAU 6.28318530718 varying vec2 v_vTexcoord; varying vec4 v_vColour; @@ -32,6 +33,26 @@ float fnoise(vec2 pos, float siz, float dist) { return lig; } +//////////////////////////////////////////////////////////////////////////////////////////////// + +uniform int flickerUse; +uniform float flickerIntens; +uniform float flickerCut; +uniform float flickerTime; + +float flick(vec2 id) { + if(flickerUse == 0) return 1.; + + float dl = flickerTime + random(id, seed) * TAU; + float ww = .8 * abs(sin(dl)) + + .2 * sin((dl + random(id, seed + 12.41)) * 2.) + + .1 * sin((dl + random(id, seed + 65.35)) * 3.); + ww = smoothstep(flickerCut, 1., ww); + return 1. - ww * flickerIntens; +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + void main() { vec2 scs = vec2(scale) * 2.; vec2 pos = v_vTexcoord - .5; @@ -70,10 +91,11 @@ void main() { lig = mix(lig, lig * ridge, 1.); } + float ints = intensity * flick(id); vec3 clr = vec3(0.); - if(indx == 0) clr.r = intensity; - else if(indx == 1) clr.g = intensity; - else if(indx == 2) clr.b = intensity; + if(indx == 0) clr.r = ints; + else if(indx == 1) clr.g = ints; + else if(indx == 2) clr.b = ints; clr *= lig; vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; diff --git a/shaders/sh_mk_subpixel_diagonal/sh_mk_subpixel_diagonal.fsh b/shaders/sh_mk_subpixel_diagonal/sh_mk_subpixel_diagonal.fsh index 0a7334562..1dffd88b8 100644 --- a/shaders/sh_mk_subpixel_diagonal/sh_mk_subpixel_diagonal.fsh +++ b/shaders/sh_mk_subpixel_diagonal/sh_mk_subpixel_diagonal.fsh @@ -1,3 +1,4 @@ +#define TAU 6.28318530718 #define s3 1. varying vec2 v_vTexcoord; @@ -53,6 +54,26 @@ float fnoise(vec2 pos, float siz, float dist) { return lig; } +//////////////////////////////////////////////////////////////////////////////////////////////// + +uniform int flickerUse; +uniform float flickerIntens; +uniform float flickerCut; +uniform float flickerTime; + +float flick(vec2 id) { + if(flickerUse == 0) return 1.; + + float dl = flickerTime + random(id, seed) * TAU; + float ww = .8 * abs(sin(dl)) + + .2 * sin((dl + random(id, seed + 12.41)) * 2.) + + .1 * sin((dl + random(id, seed + 65.35)) * 3.); + ww = smoothstep(flickerCut, 1., ww); + return 1. - ww * flickerIntens; +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + void main() { vec2 scs = scale * vec2(2.); vec2 pos = v_vTexcoord - .5; @@ -70,11 +91,12 @@ void main() { id = abs(dimension + id); if(md(id.y, s3) > s3 / 2.) ind += 2.; + float ints = intensity * flick(id); int indx = int(mod(ind, 3.)); vec3 clr = vec3(0.); - if(indx == 0) clr.r = intensity; - else if(indx == 1) clr.g = intensity; - else if(indx == 2) clr.b = intensity; + if(indx == 0) clr.r = ints; + else if(indx == 1) clr.g = ints; + else if(indx == 2) clr.b = ints; clr *= lig; vec2 uv = (hex / scs + .5) / vec2(dimension.x / dimension.y, 1.); diff --git a/shaders/sh_mk_subpixel_hex_disc/sh_mk_subpixel_hex_disc.fsh b/shaders/sh_mk_subpixel_hex_disc/sh_mk_subpixel_hex_disc.fsh index 6491a8e50..6df1a62ba 100644 --- a/shaders/sh_mk_subpixel_hex_disc/sh_mk_subpixel_hex_disc.fsh +++ b/shaders/sh_mk_subpixel_hex_disc/sh_mk_subpixel_hex_disc.fsh @@ -58,6 +58,26 @@ float fnoise(vec2 pos, float siz, float dist) { return lig; } +//////////////////////////////////////////////////////////////////////////////////////////////// + +uniform int flickerUse; +uniform float flickerIntens; +uniform float flickerCut; +uniform float flickerTime; + +float flick(vec2 id) { + if(flickerUse == 0) return 1.; + + float dl = flickerTime + random(id, seed) * TAU; + float ww = .8 * abs(sin(dl)) + + .2 * sin((dl + random(id, seed + 12.41)) * 2.) + + .1 * sin((dl + random(id, seed + 65.35)) * 3.); + ww = smoothstep(flickerCut, 1., ww); + return 1. - ww * flickerIntens; +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + void main() { vec2 scs = scale * vec2(3., s3 * 2.); vec2 pos = v_vTexcoord - .5; @@ -79,11 +99,12 @@ void main() { id = abs(dimension + id); if(md(id.y, s3) > s3 / 2.) ind += 1.; - int indx = int(mod(ind, 3.)); - vec3 clr = vec3(0.); - if(indx == 0) clr.r = intensity; - else if(indx == 1) clr.g = intensity; - else if(indx == 2) clr.b = intensity; + float ints = intensity * flick(id); + int indx = int(mod(ind, 3.)); + vec3 clr = vec3(0.); + if(indx == 0) clr.r = ints; + else if(indx == 1) clr.g = ints; + else if(indx == 2) clr.b = ints; clr *= lig; vec2 uv = (hex / scs + .5) / vec2(dimension.x / dimension.y, 1.); diff --git a/shaders/sh_mk_subpixel_linear/sh_mk_subpixel_linear.fsh b/shaders/sh_mk_subpixel_linear/sh_mk_subpixel_linear.fsh index d18871c4b..8340ec815 100644 --- a/shaders/sh_mk_subpixel_linear/sh_mk_subpixel_linear.fsh +++ b/shaders/sh_mk_subpixel_linear/sh_mk_subpixel_linear.fsh @@ -1,3 +1,4 @@ +#define TAU 6.28318530718 varying vec2 v_vTexcoord; varying vec4 v_vColour; @@ -32,6 +33,26 @@ float fnoise(vec2 pos, float siz, float dist) { return lig; } +//////////////////////////////////////////////////////////////////////////////////////////////// + +uniform int flickerUse; +uniform float flickerIntens; +uniform float flickerCut; +uniform float flickerTime; + +float flick(vec2 id) { + if(flickerUse == 0) return 1.; + + float dl = flickerTime + random(id, seed) * TAU; + float ww = .8 * abs(sin(dl)) + + .2 * sin((dl + random(id, seed + 12.41)) * 2.) + + .1 * sin((dl + random(id, seed + 65.35)) * 3.); + ww = smoothstep(flickerCut, 1., ww); + return 1. - ww * flickerIntens; +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + void main() { vec2 scs = vec2(scale) * 2.; vec2 pos = v_vTexcoord - .5; @@ -52,11 +73,12 @@ void main() { lig = mix(lig, lig * ridge, 1.); } + float ints = intensity * flick(id); int indx = int(mod(ind, 3.)); vec3 clr = vec3(0.); - if(indx == 0) clr.r = intensity; - else if(indx == 1) clr.g = intensity; - else if(indx == 2) clr.b = intensity; + if(indx == 0) clr.r = ints; + else if(indx == 1) clr.g = ints; + else if(indx == 2) clr.b = ints; clr *= lig; vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; diff --git a/shaders/sh_mk_subpixel_linear_block/sh_mk_subpixel_linear_block.fsh b/shaders/sh_mk_subpixel_linear_block/sh_mk_subpixel_linear_block.fsh index 60fd5c9a0..b2ae611ba 100644 --- a/shaders/sh_mk_subpixel_linear_block/sh_mk_subpixel_linear_block.fsh +++ b/shaders/sh_mk_subpixel_linear_block/sh_mk_subpixel_linear_block.fsh @@ -1,3 +1,4 @@ +#define TAU 6.28318530718 varying vec2 v_vTexcoord; varying vec4 v_vColour; @@ -32,6 +33,26 @@ float fnoise(vec2 pos, float siz, float dist) { return lig; } +//////////////////////////////////////////////////////////////////////////////////////////////// + +uniform int flickerUse; +uniform float flickerIntens; +uniform float flickerCut; +uniform float flickerTime; + +float flick(vec2 id) { + if(flickerUse == 0) return 1.; + + float dl = flickerTime + random(id, seed) * TAU; + float ww = .8 * abs(sin(dl)) + + .2 * sin((dl + random(id, seed + 12.41)) * 2.) + + .1 * sin((dl + random(id, seed + 65.35)) * 3.); + ww = smoothstep(flickerCut, 1., ww); + return 1. - ww * flickerIntens; +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + void main() { vec2 scs = vec2(scale) * 2.; vec2 pos = v_vTexcoord - .5; @@ -60,10 +81,11 @@ void main() { lig = mix(lig, lig * ridge, 1.); } + float ints = intensity * flick(id); vec3 clr = vec3(0.); - if(indx == 0) clr.r = intensity; - else if(indx == 1) clr.g = intensity; - else if(indx == 2) clr.b = intensity; + if(indx == 0) clr.r = ints; + else if(indx == 1) clr.g = ints; + else if(indx == 2) clr.b = ints; clr *= lig; vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; diff --git a/shaders/sh_mk_subpixel_linear_block_offset/sh_mk_subpixel_linear_block_offset.fsh b/shaders/sh_mk_subpixel_linear_block_offset/sh_mk_subpixel_linear_block_offset.fsh index f80943fdc..fa89c81e0 100644 --- a/shaders/sh_mk_subpixel_linear_block_offset/sh_mk_subpixel_linear_block_offset.fsh +++ b/shaders/sh_mk_subpixel_linear_block_offset/sh_mk_subpixel_linear_block_offset.fsh @@ -1,3 +1,4 @@ +#define TAU 6.28318530718 varying vec2 v_vTexcoord; varying vec4 v_vColour; @@ -32,6 +33,26 @@ float fnoise(vec2 pos, float siz, float dist) { return lig; } +//////////////////////////////////////////////////////////////////////////////////////////////// + +uniform int flickerUse; +uniform float flickerIntens; +uniform float flickerCut; +uniform float flickerTime; + +float flick(vec2 id) { + if(flickerUse == 0) return 1.; + + float dl = flickerTime + random(id, seed) * TAU; + float ww = .8 * abs(sin(dl)) + + .2 * sin((dl + random(id, seed + 12.41)) * 2.) + + .1 * sin((dl + random(id, seed + 65.35)) * 3.); + ww = smoothstep(flickerCut, 1., ww); + return 1. - ww * flickerIntens; +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + void main() { vec2 scs = vec2(scale) * 2.; vec2 pos = v_vTexcoord - .5; @@ -64,10 +85,11 @@ void main() { lig = mix(lig, lig * ridge, 1.); } + float ints = intensity * flick(id); vec3 clr = vec3(0.); - if(indx == 0) clr.r = intensity; - else if(indx == 1) clr.g = intensity; - else if(indx == 2) clr.b = intensity; + if(indx == 0) clr.r = ints; + else if(indx == 1) clr.g = ints; + else if(indx == 2) clr.b = ints; clr *= lig; vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; diff --git a/shaders/sh_mk_subpixel_square/sh_mk_subpixel_square.fsh b/shaders/sh_mk_subpixel_square/sh_mk_subpixel_square.fsh index 125bd9c97..16bb1fc97 100644 --- a/shaders/sh_mk_subpixel_square/sh_mk_subpixel_square.fsh +++ b/shaders/sh_mk_subpixel_square/sh_mk_subpixel_square.fsh @@ -1,3 +1,4 @@ +#define TAU 6.28318530718 varying vec2 v_vTexcoord; varying vec4 v_vColour; @@ -34,6 +35,26 @@ float fnoise(vec2 pos, float siz, float dist) { return lig; } +//////////////////////////////////////////////////////////////////////////////////////////////// + +uniform int flickerUse; +uniform float flickerIntens; +uniform float flickerCut; +uniform float flickerTime; + +float flick(vec2 id) { + if(flickerUse == 0) return 1.; + + float dl = flickerTime + random(id, seed) * TAU; + float ww = .8 * abs(sin(dl)) + + .2 * sin((dl + random(id, seed + 12.41)) * 2.) + + .1 * sin((dl + random(id, seed + 65.35)) * 3.); + ww = smoothstep(flickerCut, 1., ww); + return 1. - ww * flickerIntens; +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + void main() { vec2 scs = vec2(scale) * 2.; vec2 pos = v_vTexcoord - .5; @@ -61,10 +82,11 @@ void main() { lig = mix(lig, lig * ridge, 1.); } + float ints = intensity * flick(id); vec3 clr = vec3(0.); - if(indx == 0) clr.r = intensity; - else if(indx == 1) clr.g = intensity; - else if(indx == 2) clr.b = intensity; + if(indx == 0) clr.r = ints; + else if(indx == 1) clr.g = ints; + else if(indx == 2) clr.b = ints; clr *= lig; vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; diff --git a/shaders/sh_mk_subpixel_square_non/sh_mk_subpixel_square_non.fsh b/shaders/sh_mk_subpixel_square_non/sh_mk_subpixel_square_non.fsh index 9af925b0e..571541f02 100644 --- a/shaders/sh_mk_subpixel_square_non/sh_mk_subpixel_square_non.fsh +++ b/shaders/sh_mk_subpixel_square_non/sh_mk_subpixel_square_non.fsh @@ -1,3 +1,4 @@ +#define TAU 6.28318530718 varying vec2 v_vTexcoord; varying vec4 v_vColour; @@ -34,6 +35,26 @@ float fnoise(vec2 pos, float siz, float dist) { return lig; } +//////////////////////////////////////////////////////////////////////////////////////////////// + +uniform int flickerUse; +uniform float flickerIntens; +uniform float flickerCut; +uniform float flickerTime; + +float flick(vec2 id) { + if(flickerUse == 0) return 1.; + + float dl = flickerTime + random(id, seed) * TAU; + float ww = .8 * abs(sin(dl)) + + .2 * sin((dl + random(id, seed + 12.41)) * 2.) + + .1 * sin((dl + random(id, seed + 65.35)) * 3.); + ww = smoothstep(flickerCut, 1., ww); + return 1. - ww * flickerIntens; +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + void main() { vec2 scs = vec2(scale) * 2.; vec2 pos = v_vTexcoord - .5; @@ -63,10 +84,11 @@ void main() { lig = mix(lig, lig * ridge, 1.); } + float ints = intensity * flick(id); vec3 clr = vec3(0.); - if(indx == 0) clr.r = intensity; - else if(indx == 1) clr.g = intensity; - else if(indx == 2) clr.b = intensity; + if(indx == 0) clr.r = ints; + else if(indx == 1) clr.g = ints; + else if(indx == 2) clr.b = ints; clr *= lig; vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; diff --git a/shaders/sh_palette_replace/sh_palette_replace.fsh b/shaders/sh_palette_replace/sh_palette_replace.fsh index 8cfae4e1b..797c7d0a9 100644 --- a/shaders/sh_palette_replace/sh_palette_replace.fsh +++ b/shaders/sh_palette_replace/sh_palette_replace.fsh @@ -7,9 +7,10 @@ varying vec4 v_vColour; uniform int useMask; uniform sampler2D mask; -uniform vec4 colorFrom[32]; +#define PALETTE_LIMIT 1024 +uniform vec4 colorFrom[PALETTE_LIMIT]; uniform int colorFrom_amo; -uniform vec4 colorTo[32]; +uniform vec4 colorTo[PALETTE_LIMIT]; uniform int colorTo_amo; uniform float seed; diff --git a/shaders/sh_palette_shift/sh_palette_shift.fsh b/shaders/sh_palette_shift/sh_palette_shift.fsh index d6f7df0f9..9e834eedb 100644 --- a/shaders/sh_palette_shift/sh_palette_shift.fsh +++ b/shaders/sh_palette_shift/sh_palette_shift.fsh @@ -4,7 +4,8 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; -uniform vec4 palette[64]; +#define PALETTE_LIMIT 1024 +uniform vec4 palette[PALETTE_LIMIT]; uniform float paletteAmount; uniform float shift; diff --git a/shaders/sh_region_fill_color/sh_region_fill_color.fsh b/shaders/sh_region_fill_color/sh_region_fill_color.fsh index c40d4f82f..4b57c279e 100644 --- a/shaders/sh_region_fill_color/sh_region_fill_color.fsh +++ b/shaders/sh_region_fill_color/sh_region_fill_color.fsh @@ -4,7 +4,8 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; -uniform vec4 colors[32]; +#define PALETTE_LIMIT 1024 +uniform vec4 colors[PALETTE_LIMIT]; uniform float colorAmount; uniform float seed; diff --git a/shaders/sh_shape/sh_shape.fsh b/shaders/sh_shape/sh_shape.fsh index c77db38c7..e6e4e2993 100644 --- a/shaders/sh_shape/sh_shape.fsh +++ b/shaders/sh_shape/sh_shape.fsh @@ -9,8 +9,10 @@ uniform int aa; uniform int sides; uniform int tile; +uniform int drawBG; uniform int drawDF; uniform vec2 dfLevel; +uniform vec2 dfLevelOut; uniform float rotation; uniform float angle; @@ -24,10 +26,11 @@ uniform float parall; uniform vec2 angle_range; -uniform vec2 dimension; -uniform vec2 center; -uniform vec2 scale; -uniform vec2 trep; +uniform vec2 dimension; +uniform vec2 center; +uniform vec2 scale; +uniform vec2 trep; +uniform float shapeScale; uniform int teeth; uniform vec2 teethSize; @@ -296,7 +299,6 @@ float sdArrow( in vec2 p, float w1, float w2, float k ) { // The arrow goes from } void main() { - float color = 0.; vec2 coord = (v_vTexcoord - center) * mat2(cos(rotation), -sin(rotation), sin(rotation), cos(rotation)) / scale; vec2 ratio = dimension / dimension.y; float d; @@ -318,31 +320,40 @@ void main() { d = sdStar( coord, 0.9 - corner, sides, 2. + inner * (float(sides) - 2.), angle ); d -= corner; - } else if(shape == 4) d = sdArc( coord, vec2(sin(angle), cos(angle)), angle_range, 0.9 - inner, inner ); - else if(shape == 5) d = sdTearDrop( coord + vec2(0., 0.5), stRad, edRad, 1. ); - else if(shape == 6) d = sdCross( coord, vec2(1. + corner, outer), corner ); - else if(shape == 7) d = sdVesica( coord, inner, outer ); - else if(shape == 8) d = sdCrescent( coord, inner, outer, angle ); - else if(shape == 9) d = sdDonut( coord, inner ); - else if(shape == 10) d = sdRhombus( coord, vec2(1. - corner) ) - corner; - else if(shape == 11) d = sdTrapezoid( coord, trep.x - corner, trep.y - corner, 1. - corner ) - corner; - else if(shape == 12) d = sdParallelogram( coord, 1. - corner - parall, 1. - corner, parall) - corner; - else if(shape == 13) d = sdHeart( coord ); - else if(shape == 14) d = sdCutDisk( coord, 1., inner ); - else if(shape == 15) d = sdPie( coord, vec2(sin(angle), cos(angle)), 1. ); - else if(shape == 16) d = sdRoundedCross( coord, 1. - corner ) - corner; - else if(shape == 17) d = sdArrow( coord, arrow.x, arrow.y, arrow_head); - else if(shape == 18) d = sdGear( coord, inner, teeth, teethSize, teethAngle); + } else if(shape == 4) { d = sdArc( coord, vec2(sin(angle), cos(angle)), angle_range, 0.9 - inner, inner ); } + else if(shape == 5) { d = sdTearDrop( coord + vec2(0., 0.5), stRad, edRad, 1. ); } + else if(shape == 6) { d = sdCross( coord, vec2(1. + corner, outer), corner ); } + else if(shape == 7) { d = sdVesica( coord, inner, outer ); } + else if(shape == 8) { d = sdCrescent( coord, inner, outer, angle ); } + else if(shape == 9) { d = sdDonut( coord, inner ); } + else if(shape == 10) { d = sdRhombus( coord, vec2(1. - corner) ) - corner; } + else if(shape == 11) { d = sdTrapezoid( coord, trep.x - corner, trep.y - corner, 1. - corner ) - corner; } + else if(shape == 12) { d = sdParallelogram( coord, 1. - corner - parall, 1. - corner, parall) - corner; } + else if(shape == 13) { d = sdHeart( coord ); } + else if(shape == 14) { d = sdCutDisk( coord, 1., inner ); } + else if(shape == 15) { d = sdPie( coord, vec2(sin(angle), cos(angle)), 1. ); } + else if(shape == 16) { d = sdRoundedCross( coord, 1. - corner ) - corner; } + else if(shape == 17) { d = sdArrow( coord, arrow.x, arrow.y, arrow_head); } + else if(shape == 18) { d = sdGear( coord, inner, teeth, teethSize, teethAngle); } - if(drawDF == 1) { - color = -d; - color = (color - dfLevel.x) / (dfLevel.y - dfLevel.x); - } else if(aa == 0) - color = step(d, 0.0); + float cc, color = 0.; + + if(aa == 0) + cc = step(d, 0.0); else { float _aa = 1. / max(dimension.x, dimension.y); - color = smoothstep(_aa, -_aa, d); + cc = smoothstep(_aa, -_aa, d); } - gl_FragColor = mix(bgColor, v_vColour, color); + color = cc; + if(drawDF == 1) { + color = -d; + color = smoothstep(dfLevelOut[0], dfLevelOut[1], clamp((color - dfLevel.x) / (dfLevel.y - dfLevel.x), 0., 1.)); + color *= cc; + } + + if(drawBG == 0) + gl_FragColor = vec4(v_vColour.rgb, color); + else + gl_FragColor = mix(bgColor, v_vColour, color); } diff --git a/shaders/sh_smear/sh_smear.fsh b/shaders/sh_smear/sh_smear.fsh index 95315422c..84d6f96f8 100644 --- a/shaders/sh_smear/sh_smear.fsh +++ b/shaders/sh_smear/sh_smear.fsh @@ -17,6 +17,7 @@ uniform int sampleMode; uniform int alpha; uniform int modulateStr; uniform int inv; +uniform int blend; vec4 sampleTexture(vec2 pos) { #region if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.) @@ -113,7 +114,8 @@ void main() { vec2 dirr = vec2(sin(r), cos(r)) * str; vec4 smr = smear(dirr); - col = max(col, smr); + if(blend == 0) col = max(col, smr); + else if(blend == 1) col += smr; } gl_FragColor = col; diff --git a/shaders/sh_warp_4points/sh_warp_4points.fsh b/shaders/sh_warp_4points/sh_warp_4points.fsh index 107369ba2..820b51ee3 100644 --- a/shaders/sh_warp_4points/sh_warp_4points.fsh +++ b/shaders/sh_warp_4points/sh_warp_4points.fsh @@ -6,6 +6,7 @@ uniform vec2 p1; uniform vec2 p2; uniform vec2 p3; uniform vec2 dimension; +uniform int tile; #region /////////////// SAMPLING /////////////// @@ -123,6 +124,8 @@ void main() { } #endregion + if(tile == 1) uv = fract(1. + fract(uv)); + if(uv.x >= 0. && uv.y >= 0. && uv.x <= 1. && uv.y <= 1.) gl_FragColor = texture2Dintp( gm_BaseTexture, uv ); else diff --git a/shaders/sh_warp_4points_pers/sh_warp_4points_pers.fsh b/shaders/sh_warp_4points_pers/sh_warp_4points_pers.fsh index 2be718f75..50cebad29 100644 --- a/shaders/sh_warp_4points_pers/sh_warp_4points_pers.fsh +++ b/shaders/sh_warp_4points_pers/sh_warp_4points_pers.fsh @@ -4,10 +4,6 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; -uniform vec2 f1; -uniform vec2 f2; -uniform vec2 f3; -uniform vec2 f4; uniform vec2 t1; uniform vec2 t2; uniform vec2 t3; @@ -87,62 +83,58 @@ vec4 texture2Dintp( sampler2D texture, vec2 uv ) { /////////////// SAMPLING /////////////// mat3 m_inverse(mat3 m) { - float a11 = m[0][0], a12 = m[0][1], a13 = m[0][2]; - float a21 = m[1][0], a22 = m[1][1], a23 = m[1][2]; - float a31 = m[2][0], a32 = m[2][1], a33 = m[2][2]; + float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; + float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2]; + float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2]; - float b11 = a22 * a33 - a23 * a32; - float b12 = a13 * a32 - a12 * a33; - float b13 = a12 * a23 - a13 * a22; - float b21 = a23 * a31 - a21 * a33; - float b22 = a11 * a33 - a13 * a31; - float b23 = a13 * a21 - a11 * a23; - float b31 = a21 * a32 - a22 * a31; - float b32 = a12 * a31 - a11 * a32; - float b33 = a11 * a22 - a12 * a21; + float b01 = a22 * a11 - a12 * a21; + float b11 = -a22 * a10 + a12 * a20; + float b21 = a21 * a10 - a11 * a20; - float det = a11 * b11 + a12 * b21 + a13 * b31; + float det = a00 * b01 + a01 * b11 + a02 * b21; - mat3 inverse; - inverse[0][0] = b11 / det; - inverse[0][1] = b12 / det; - inverse[0][2] = b13 / det; - inverse[1][0] = b21 / det; - inverse[1][1] = b22 / det; - inverse[1][2] = b23 / det; - inverse[2][0] = b31 / det; - inverse[2][1] = b32 / det; - inverse[2][2] = b33 / det; + return mat3(b01, (-a22 * a01 + a02 * a21), ( a12 * a01 - a02 * a11), + b11, ( a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10), + b21, (-a21 * a00 + a01 * a20), ( a11 * a00 - a01 * a10)) / det; +} - return inverse; +mat3 computeHomography() { + float x0 = 0., y0 = 0.; + float x1 = 1., y1 = 0.; + float x2 = 0., y2 = 1.; + float x3 = 1., y3 = 1.; + + float u0 = t1.x, v0 = t1.y; + float u1 = t2.x, v1 = t2.y; + float u2 = t3.x, v2 = t3.y; + float u3 = t4.x, v3 = t4.y; + + mat3 A = mat3( + x0, y0, 1.0, + x1, y1, 1.0, + x2, y2, 1.0 + ); + + vec3 b1 = vec3(u0, u1, u2); + vec3 b2 = vec3(v0, v1, v2); + + vec3 h1 = m_inverse(A) * b1; + vec3 h2 = m_inverse(A) * b2; + + mat3 H = mat3( + h1.x, h1.y, h1.z, + h2.x, h2.y, h2.z, + 0.0, 0.0, 1.0 + ); + + return H; } void main() { - vec3 p1 = vec3(f1, 1.0); - vec3 p2 = vec3(f2, 1.0); - vec3 p3 = vec3(f3, 1.0); - vec3 p4 = vec3(f4, 1.0); - vec3 q1 = vec3(t1, 1.0); - vec3 q2 = vec3(t2, 1.0); - vec3 q3 = vec3(t3, 1.0); - vec3 q4 = vec3(t4, 1.0); - - mat3 A = mat3(p1, p2, p3); - vec3 b = p4; - vec3 x = m_inverse(A) * b; - vec3 h1 = x; - vec3 h2 = vec3(q2 - q1); - vec3 h3 = cross(h1, h2); - vec3 h4 = vec3(q3 - q1); - vec3 h5 = cross(h1, h4); - vec3 h6 = vec3(q4 - q1); - vec3 h7 = cross(h1, h6); - mat3 H = mat3(h2 / h3.x, h4 / h5.x, h6 / h7.x); - H[2][2] = 1.0 / h3.x; - - vec3 coord = vec3(v_vTexcoord, 1.0); - vec3 newCoord = H * coord; - vec2 texCoord = newCoord.xy / newCoord.z; - - gl_FragColor = texture2Dintp(gm_BaseTexture, texCoord); + mat3 H = computeHomography(); + + vec3 warpedCoord = H * vec3(v_vTexcoord, 1.0); + vec2 finalCoord = warpedCoord.xy / warpedCoord.z; + + gl_FragColor = texture2D(gm_BaseTexture, finalCoord); } \ No newline at end of file