mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-26 04:48:17 +01:00
- New Box Pattern node.
This commit is contained in:
parent
1f5cb6578e
commit
536aeb09d9
20 changed files with 462 additions and 1 deletions
|
@ -719,6 +719,7 @@
|
|||
{"name":"node_blur_zoom","order":10,"path":"scripts/node_blur_zoom/node_blur_zoom.yy",},
|
||||
{"name":"node_blur","order":2,"path":"scripts/node_blur/node_blur.yy",},
|
||||
{"name":"node_boolean","order":17,"path":"scripts/node_boolean/node_boolean.yy",},
|
||||
{"name":"node_box_pattern","order":11,"path":"scripts/node_box_pattern/node_box_pattern.yy",},
|
||||
{"name":"node_brush_linear","order":24,"path":"scripts/node_brush_linear/node_brush_linear.yy",},
|
||||
{"name":"node_byte_file_read","order":21,"path":"scripts/node_byte_file_read/node_byte_file_read.yy",},
|
||||
{"name":"node_byte_file_write","order":20,"path":"scripts/node_byte_file_write/node_byte_file_write.yy",},
|
||||
|
@ -1303,6 +1304,7 @@
|
|||
{"name":"sh_blend_sat","order":18,"path":"shaders/sh_blend_sat/sh_blend_sat.yy",},
|
||||
{"name":"sh_blend_screen","order":3,"path":"shaders/sh_blend_screen/sh_blend_screen.yy",},
|
||||
{"name":"sh_blend_subtract","order":5,"path":"shaders/sh_blend_subtract/sh_blend_subtract.yy",},
|
||||
{"name":"sh_blend_xor","order":53,"path":"shaders/sh_blend_xor/sh_blend_xor.yy",},
|
||||
{"name":"sh_blink_expand","order":2,"path":"shaders/sh_blink_expand/sh_blink_expand.yy",},
|
||||
{"name":"sh_blink_replace","order":1,"path":"shaders/sh_blink_replace/sh_blink_replace.yy",},
|
||||
{"name":"sh_blobify","order":1,"path":"shaders/sh_blobify/sh_blobify.yy",},
|
||||
|
@ -1319,6 +1321,7 @@
|
|||
{"name":"sh_blur_simple","order":10,"path":"shaders/sh_blur_simple/sh_blur_simple.yy",},
|
||||
{"name":"sh_blur_slope","order":11,"path":"shaders/sh_blur_slope/sh_blur_slope.yy",},
|
||||
{"name":"sh_blur_zoom","order":12,"path":"shaders/sh_blur_zoom/sh_blur_zoom.yy",},
|
||||
{"name":"sh_box_pattern","order":29,"path":"shaders/sh_box_pattern/sh_box_pattern.yy",},
|
||||
{"name":"sh_brush_linear","order":56,"path":"shaders/sh_brush_linear/sh_brush_linear.yy",},
|
||||
{"name":"sh_brush_outline","order":7,"path":"shaders/sh_brush_outline/sh_brush_outline.yy",},
|
||||
{"name":"sh_bw","order":3,"path":"shaders/sh_bw/sh_bw.yy",},
|
||||
|
@ -1711,6 +1714,7 @@
|
|||
{"name":"s_node_bokeh","order":6,"path":"sprites/s_node_bokeh/s_node_bokeh.yy",},
|
||||
{"name":"s_node_boolean","order":3,"path":"sprites/s_node_boolean/s_node_boolean.yy",},
|
||||
{"name":"s_node_border","order":8,"path":"sprites/s_node_border/s_node_border.yy",},
|
||||
{"name":"s_node_box_pattern","order":56,"path":"sprites/s_node_box_pattern/s_node_box_pattern.yy",},
|
||||
{"name":"s_node_brush_linear","order":65,"path":"sprites/s_node_brush_linear/s_node_brush_linear.yy",},
|
||||
{"name":"s_node_bubble_noise","order":45,"path":"sprites/s_node_bubble_noise/s_node_bubble_noise.yy",},
|
||||
{"name":"s_node_BW","order":9,"path":"sprites/s_node_BW/s_node_BW.yy",},
|
||||
|
|
|
@ -330,6 +330,7 @@
|
|||
],
|
||||
"IncludedFiles":[
|
||||
{"$GMIncludedFile":"","%Name":"Actions.zip","CopyToMask":-1,"filePath":"datafiles/data","name":"Actions.zip","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"icons.afdesign","CopyToMask":-1,"filePath":"datafiles/data/Actions","name":"icons.afdesign","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"icons.ai","CopyToMask":-1,"filePath":"datafiles/data/Actions","name":"icons.ai","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Armature Build.json","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes","name":"Armature Build.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Armature Build.png","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes","name":"Armature Build.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
|
@ -1110,6 +1111,7 @@
|
|||
{"id":{"name":"node_blur_zoom","path":"scripts/node_blur_zoom/node_blur_zoom.yy",},},
|
||||
{"id":{"name":"node_blur","path":"scripts/node_blur/node_blur.yy",},},
|
||||
{"id":{"name":"node_boolean","path":"scripts/node_boolean/node_boolean.yy",},},
|
||||
{"id":{"name":"node_box_pattern","path":"scripts/node_box_pattern/node_box_pattern.yy",},},
|
||||
{"id":{"name":"node_brush_linear","path":"scripts/node_brush_linear/node_brush_linear.yy",},},
|
||||
{"id":{"name":"node_bw","path":"scripts/node_bw/node_bw.yy",},},
|
||||
{"id":{"name":"node_byte_file_read","path":"scripts/node_byte_file_read/node_byte_file_read.yy",},},
|
||||
|
@ -1787,6 +1789,7 @@
|
|||
{"id":{"name":"sh_blend_sat","path":"shaders/sh_blend_sat/sh_blend_sat.yy",},},
|
||||
{"id":{"name":"sh_blend_screen","path":"shaders/sh_blend_screen/sh_blend_screen.yy",},},
|
||||
{"id":{"name":"sh_blend_subtract","path":"shaders/sh_blend_subtract/sh_blend_subtract.yy",},},
|
||||
{"id":{"name":"sh_blend_xor","path":"shaders/sh_blend_xor/sh_blend_xor.yy",},},
|
||||
{"id":{"name":"sh_blink_expand","path":"shaders/sh_blink_expand/sh_blink_expand.yy",},},
|
||||
{"id":{"name":"sh_blink_extract","path":"shaders/sh_blink_extract/sh_blink_extract.yy",},},
|
||||
{"id":{"name":"sh_blink_replace","path":"shaders/sh_blink_replace/sh_blink_replace.yy",},},
|
||||
|
@ -1804,6 +1807,7 @@
|
|||
{"id":{"name":"sh_blur_simple","path":"shaders/sh_blur_simple/sh_blur_simple.yy",},},
|
||||
{"id":{"name":"sh_blur_slope","path":"shaders/sh_blur_slope/sh_blur_slope.yy",},},
|
||||
{"id":{"name":"sh_blur_zoom","path":"shaders/sh_blur_zoom/sh_blur_zoom.yy",},},
|
||||
{"id":{"name":"sh_box_pattern","path":"shaders/sh_box_pattern/sh_box_pattern.yy",},},
|
||||
{"id":{"name":"sh_brush_linear","path":"shaders/sh_brush_linear/sh_brush_linear.yy",},},
|
||||
{"id":{"name":"sh_brush_outline","path":"shaders/sh_brush_outline/sh_brush_outline.yy",},},
|
||||
{"id":{"name":"sh_bw","path":"shaders/sh_bw/sh_bw.yy",},},
|
||||
|
@ -2260,6 +2264,7 @@
|
|||
{"id":{"name":"s_node_bokeh","path":"sprites/s_node_bokeh/s_node_bokeh.yy",},},
|
||||
{"id":{"name":"s_node_boolean","path":"sprites/s_node_boolean/s_node_boolean.yy",},},
|
||||
{"id":{"name":"s_node_border","path":"sprites/s_node_border/s_node_border.yy",},},
|
||||
{"id":{"name":"s_node_box_pattern","path":"sprites/s_node_box_pattern/s_node_box_pattern.yy",},},
|
||||
{"id":{"name":"s_node_brush_linear","path":"sprites/s_node_brush_linear/s_node_brush_linear.yy",},},
|
||||
{"id":{"name":"s_node_bubble_noise","path":"sprites/s_node_bubble_noise/s_node_bubble_noise.yy",},},
|
||||
{"id":{"name":"s_node_BW","path":"sprites/s_node_BW/s_node_BW.yy",},},
|
||||
|
|
BIN
datafiles/data/Actions/icons.afdesign
Normal file
BIN
datafiles/data/Actions/icons.afdesign
Normal file
Binary file not shown.
|
@ -2,7 +2,7 @@ globalvar BLEND_TYPES;
|
|||
BLEND_TYPES = [
|
||||
"Normal", "Add", "Subtract", "Multiply", "Screen",
|
||||
"Overlay", "Hue", "Saturation", "Luminosity", "Maximum",
|
||||
"Minimum", "Replace", "Difference"
|
||||
"Minimum", "Replace", "Difference",
|
||||
];
|
||||
|
||||
function draw_surface_blend(background, foreground, blend = 0, alpha = 1, _pre_alp = true, _mask = 0, tile = 0) {
|
||||
|
@ -25,6 +25,8 @@ function draw_surface_blend(background, foreground, blend = 0, alpha = 1, _pre_a
|
|||
case "Minimum" : sh = sh_blend_min; break;
|
||||
case "Replace" : sh = sh_blend_replace; break;
|
||||
case "Difference" : sh = sh_blend_difference; break;
|
||||
|
||||
// case "XOR" : sh = sh_blend_xor; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
|
|
96
scripts/node_box_pattern/node_box_pattern.gml
Normal file
96
scripts/node_box_pattern/node_box_pattern.gml
Normal file
|
@ -0,0 +1,96 @@
|
|||
function Node_Box_Pattern(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "Box Pattern";
|
||||
|
||||
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
|
||||
.setDisplay(VALUE_DISPLAY.vector);
|
||||
|
||||
inputs[| 1] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 2)
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] })
|
||||
.setMappable(6);
|
||||
|
||||
inputs[| 2] = nodeValue("Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
||||
.setDisplay(VALUE_DISPLAY.rotation)
|
||||
.setMappable(7);
|
||||
|
||||
inputs[| 3] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [0, 0] )
|
||||
.setDisplay(VALUE_DISPLAY.vector)
|
||||
.setUnitRef(function(index) { return getDimension(index); });
|
||||
|
||||
inputs[| 4] = nodeValue("Color 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
|
||||
|
||||
inputs[| 5] = nodeValue("Color 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inputs[| 6] = nodeValueMap("Amount map", self);
|
||||
|
||||
inputs[| 7] = nodeValueMap("Angle map", self);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inputs[| 8] = nodeValue("Type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Solid", "Smooth", "AA" ]);
|
||||
|
||||
inputs[| 9] = nodeValue("Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.25)
|
||||
.setDisplay(VALUE_DISPLAY.slider)
|
||||
.setMappable(10);
|
||||
|
||||
inputs[| 10] = nodeValueMap("Width map", self);
|
||||
|
||||
inputs[| 11] = nodeValue("Pattern", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Cross", "Xor" ]);
|
||||
|
||||
inputs[| 12] = nodeValue("Iteration", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4)
|
||||
|
||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||
|
||||
input_display_list = [
|
||||
["Output", true], 0,
|
||||
["Pattern", false], 11, 1, 6, 2, 7, 3, 9, 10, 12,
|
||||
["Render", false], 8, 4, 5,
|
||||
];
|
||||
|
||||
attribute_surface_depth();
|
||||
|
||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||
var pos = getInputData(3);
|
||||
var px = _x + pos[0] * _s;
|
||||
var py = _y + pos[1] * _s;
|
||||
|
||||
inputs[| 3].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
inputs[| 2].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny);
|
||||
}
|
||||
|
||||
static step = function() { #region
|
||||
var _pat = getSingleValue(11);
|
||||
inputs[| 9].setVisible(_pat == 0);
|
||||
inputs[| 12].setVisible(_pat == 1);
|
||||
|
||||
inputs[| 1].mappableStep();
|
||||
inputs[| 2].mappableStep();
|
||||
} #endregion
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||
var _dim = _data[0];
|
||||
var _pos = _data[3];
|
||||
|
||||
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
|
||||
|
||||
surface_set_shader(_outSurf, sh_box_pattern);
|
||||
shader_set_f("dimension", surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf));
|
||||
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
|
||||
shader_set_f_map("amount", _data[1], _data[ 6], inputs[| 1]);
|
||||
shader_set_f_map("angle", _data[2], _data[ 7], inputs[| 2]);
|
||||
shader_set_f_map("width", _data[9], _data[10], inputs[| 9]);
|
||||
shader_set_color("col1", _data[4]);
|
||||
shader_set_color("col2", _data[5]);
|
||||
shader_set_i("blend", _data[8]);
|
||||
shader_set_i("pattern", _data[11]);
|
||||
shader_set_i("iteration", _data[12]);
|
||||
|
||||
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
|
||||
surface_reset_shader();
|
||||
|
||||
return _outSurf;
|
||||
}
|
||||
}
|
13
scripts/node_box_pattern/node_box_pattern.yy
Normal file
13
scripts/node_box_pattern/node_box_pattern.yy
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$GMScript":"",
|
||||
"%Name":"node_box_pattern",
|
||||
"isCompatibility":false,
|
||||
"isDnD":false,
|
||||
"name":"node_box_pattern",
|
||||
"parent":{
|
||||
"name":"pattern",
|
||||
"path":"folders/nodes/data/generator/pattern.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
}
|
12
scripts/node_box_pattern/node_stripe.yy
Normal file
12
scripts/node_box_pattern/node_stripe.yy
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"isDnD": false,
|
||||
"isCompatibility": false,
|
||||
"parent": {
|
||||
"name": "generator",
|
||||
"path": "folders/nodes/data/generator.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "node_stripe",
|
||||
"tags": [],
|
||||
"resourceType": "GMScript",
|
||||
}
|
|
@ -750,6 +750,7 @@ function __initNodes() {
|
|||
addNodeObject(generator, "Pytagorean Tile", s_node_pytagorean_tile, "Node_Pytagorean_Tile", [1, Node_Pytagorean_Tile],, "Generate Pytagorean tile pattern.").patreonExtra();
|
||||
addNodeObject(generator, "Herringbone Tile", s_node_herringbone_tile, "Node_Herringbone_Tile", [1, Node_Herringbone_Tile],, "Generate Herringbone tile pattern.").patreonExtra();
|
||||
addNodeObject(generator, "Random Tile", s_node_random_tile, "Node_Random_Tile", [1, Node_Random_Tile],, "Generate Random tile pattern.").patreonExtra();
|
||||
addNodeObject(generator, "Box Pattern", s_node_box_pattern, "Node_Box_Pattern", [1, Node_Box_Pattern]).setVersion(11750);
|
||||
addNodeObject(generator, "Quasicrystal", s_node_quasicircle, "Node_Quasicrystal", [1, Node_Quasicrystal]).setVersion(11660);
|
||||
addNodeObject(generator, "Pixel Sampler", s_node_pixel_sampler, "Node_Pixel_Sampler", [1, Node_Pixel_Sampler]).setVersion(11730);
|
||||
|
||||
|
|
11
shaders/sh_blend_xor/sh_blend_add_alpha_adj.yy
Normal file
11
shaders/sh_blend_xor/sh_blend_add_alpha_adj.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"type": 1,
|
||||
"parent": {
|
||||
"name": "blend",
|
||||
"path": "folders/shader/blend.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_blend_add_alpha_adj",
|
||||
"tags": [],
|
||||
"resourceType": "GMShader",
|
||||
}
|
11
shaders/sh_blend_xor/sh_blend_multiply.yy
Normal file
11
shaders/sh_blend_xor/sh_blend_multiply.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"type": 1,
|
||||
"parent": {
|
||||
"name": "shader",
|
||||
"path": "folders/shader.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_blend_multiply",
|
||||
"tags": [],
|
||||
"resourceType": "GMShader",
|
||||
}
|
11
shaders/sh_blend_xor/sh_blend_normal.yy
Normal file
11
shaders/sh_blend_xor/sh_blend_normal.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"type": 1,
|
||||
"parent": {
|
||||
"name": "blend",
|
||||
"path": "folders/shader/blend.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_blend_normal",
|
||||
"tags": [],
|
||||
"resourceType": "GMShader",
|
||||
}
|
37
shaders/sh_blend_xor/sh_blend_xor.fsh
Normal file
37
shaders/sh_blend_xor/sh_blend_xor.fsh
Normal file
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
uniform vec2 dimension;
|
||||
uniform int tile_type;
|
||||
|
||||
uniform int useMask;
|
||||
uniform int preserveAlpha;
|
||||
uniform sampler2D mask;
|
||||
uniform sampler2D fore;
|
||||
uniform float opacity;
|
||||
|
||||
float sampleMask() {
|
||||
if(useMask == 0) return 1.;
|
||||
vec4 m = texture2D( mask, v_vTexcoord );
|
||||
return (m.r + m.g + m.b) / 3. * m.a;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 _col0 = texture2D( gm_BaseTexture, v_vTexcoord );
|
||||
_col0.rgb *= _col0.a;
|
||||
|
||||
vec2 fore_tex = tile_type == 1? fract(v_vTexcoord * dimension) : v_vTexcoord;
|
||||
|
||||
vec4 _col1 = texture2D( fore, fore_tex );
|
||||
_col1.a *= opacity * sampleMask();
|
||||
_col1.rgb *= _col1.a;
|
||||
|
||||
float al = _col1.a + _col0.a * (1. - _col1.a);
|
||||
vec4 res = _col0 + _col1;
|
||||
res.rgb /= al;
|
||||
res.a = preserveAlpha == 1? _col0.a : res.a;
|
||||
gl_FragColor = res;
|
||||
}
|
19
shaders/sh_blend_xor/sh_blend_xor.vsh
Normal file
19
shaders/sh_blend_xor/sh_blend_xor.vsh
Normal file
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Simple passthrough vertex shader
|
||||
//
|
||||
attribute vec3 in_Position; // (x,y,z)
|
||||
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
|
||||
attribute vec4 in_Colour; // (r,g,b,a)
|
||||
attribute vec2 in_TextureCoord; // (u,v)
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
|
||||
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
|
||||
|
||||
v_vColour = in_Colour;
|
||||
v_vTexcoord = in_TextureCoord;
|
||||
}
|
12
shaders/sh_blend_xor/sh_blend_xor.yy
Normal file
12
shaders/sh_blend_xor/sh_blend_xor.yy
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"$GMShader":"",
|
||||
"%Name":"sh_blend_xor",
|
||||
"name":"sh_blend_xor",
|
||||
"parent":{
|
||||
"name":"blend",
|
||||
"path":"folders/shader/blend.yy",
|
||||
},
|
||||
"resourceType":"GMShader",
|
||||
"resourceVersion":"2.0",
|
||||
"type":1,
|
||||
}
|
106
shaders/sh_box_pattern/sh_box_pattern.fsh
Normal file
106
shaders/sh_box_pattern/sh_box_pattern.fsh
Normal file
|
@ -0,0 +1,106 @@
|
|||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define PI 3.14159265359
|
||||
|
||||
uniform vec2 dimension;
|
||||
uniform vec2 position;
|
||||
uniform int blend;
|
||||
uniform int pattern;
|
||||
uniform int iteration;
|
||||
|
||||
uniform vec2 amount;
|
||||
uniform int amountUseSurf;
|
||||
uniform sampler2D amountSurf;
|
||||
|
||||
uniform vec2 angle;
|
||||
uniform int angleUseSurf;
|
||||
uniform sampler2D angleSurf;
|
||||
|
||||
uniform vec2 width;
|
||||
uniform int widthUseSurf;
|
||||
uniform sampler2D widthSurf;
|
||||
|
||||
uniform vec4 col1;
|
||||
uniform vec4 col2;
|
||||
|
||||
float pat_cross(vec2 p, float w) {
|
||||
vec2 f = fract(abs(p));
|
||||
vec2 c = abs(f - 0.5);
|
||||
float sx, sy, m;
|
||||
|
||||
if(blend == 0) {
|
||||
sx = step(w / 2., c.x);
|
||||
sy = step(w / 2., c.y);
|
||||
|
||||
m = mod(sx + sy, 2.);
|
||||
return m;
|
||||
|
||||
} else if(blend == 1) {
|
||||
sx = abs(w / 2. - c.x);
|
||||
sy = abs(w / 2. - c.y);
|
||||
|
||||
m = mod(sx + sy, 2.);
|
||||
return m;
|
||||
|
||||
} else if(blend == 2) {
|
||||
float d = 1. / max(dimension.x, dimension.y);
|
||||
sx = smoothstep(w / 2. - d, w / 2. + d, c.x);
|
||||
sy = smoothstep(w / 2. - d, w / 2. + d, c.y);
|
||||
|
||||
m = mod(sx + sy, 2.);
|
||||
return m;
|
||||
}
|
||||
|
||||
return 0.;
|
||||
}
|
||||
|
||||
float pat_xor( vec2 p, int itr ) {
|
||||
float res = 0.0;
|
||||
|
||||
for( int i = 0; i < itr; i++ ) {
|
||||
res += mod( floor(p.x) + floor(p.y), 2.0 );
|
||||
p *= 0.5;
|
||||
res *= 0.5;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void main() {
|
||||
#region params
|
||||
float amo = amount.x;
|
||||
if(amountUseSurf == 1) {
|
||||
vec4 _vMap = texture2D( amountSurf, v_vTexcoord );
|
||||
amo = mix(amount.x, amount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
||||
}
|
||||
|
||||
float ang = angle.x;
|
||||
if(angleUseSurf == 1) {
|
||||
vec4 _vMap = texture2D( angleSurf, v_vTexcoord );
|
||||
ang = mix(angle.x, angle.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
||||
}
|
||||
ang = radians(ang);
|
||||
|
||||
float wid = width.x;
|
||||
if(widthUseSurf == 1) {
|
||||
vec4 _vMap = texture2D( widthSurf, v_vTexcoord );
|
||||
wid = mix(width.x, width.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
||||
}
|
||||
#endregion
|
||||
|
||||
vec2 a = dimension / dimension.y;
|
||||
vec2 c = (v_vTexcoord - position) * a;
|
||||
c *= mat2(cos(ang), -sin(ang), sin(ang), cos(ang));
|
||||
c *= amo;
|
||||
|
||||
if(pattern == 0) {
|
||||
float ch = pat_cross(c, wid);
|
||||
gl_FragColor = mix(col1, col2, ch);
|
||||
|
||||
} else if(pattern == 1) {
|
||||
float ch = pat_xor(c, iteration);
|
||||
gl_FragColor = mix(col1, col2, ch);
|
||||
|
||||
}
|
||||
}
|
19
shaders/sh_box_pattern/sh_box_pattern.vsh
Normal file
19
shaders/sh_box_pattern/sh_box_pattern.vsh
Normal file
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Simple passthrough vertex shader
|
||||
//
|
||||
attribute vec3 in_Position; // (x,y,z)
|
||||
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
|
||||
attribute vec4 in_Colour; // (r,g,b,a)
|
||||
attribute vec2 in_TextureCoord; // (u,v)
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
|
||||
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
|
||||
|
||||
v_vColour = in_Colour;
|
||||
v_vTexcoord = in_TextureCoord;
|
||||
}
|
12
shaders/sh_box_pattern/sh_box_pattern.yy
Normal file
12
shaders/sh_box_pattern/sh_box_pattern.yy
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"$GMShader":"",
|
||||
"%Name":"sh_box_pattern",
|
||||
"name":"sh_box_pattern",
|
||||
"parent":{
|
||||
"name":"generator",
|
||||
"path":"folders/shader/generator.yy",
|
||||
},
|
||||
"resourceType":"GMShader",
|
||||
"resourceVersion":"2.0",
|
||||
"type":1,
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 830 B |
Binary file not shown.
After Width: | Height: | Size: 830 B |
90
sprites/s_node_box_pattern/s_node_box_pattern.yy
Normal file
90
sprites/s_node_box_pattern/s_node_box_pattern.yy
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"$GMSprite":"",
|
||||
"%Name":"s_node_box_pattern",
|
||||
"bboxMode":0,
|
||||
"bbox_bottom":63,
|
||||
"bbox_left":0,
|
||||
"bbox_right":63,
|
||||
"bbox_top":0,
|
||||
"collisionKind":1,
|
||||
"collisionTolerance":0,
|
||||
"DynamicTexturePage":false,
|
||||
"edgeFiltering":false,
|
||||
"For3D":false,
|
||||
"frames":[
|
||||
{"$GMSpriteFrame":"","%Name":"5a53fa49-2f6a-4b11-8b0c-7fb764332185","name":"5a53fa49-2f6a-4b11-8b0c-7fb764332185","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
],
|
||||
"gridX":0,
|
||||
"gridY":0,
|
||||
"height":64,
|
||||
"HTile":false,
|
||||
"layers":[
|
||||
{"$GMImageLayer":"","%Name":"9b955ea6-a3ea-491f-a87c-fa88c64e54c2","blendMode":0,"displayName":"default","isLocked":false,"name":"9b955ea6-a3ea-491f-a87c-fa88c64e54c2","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
],
|
||||
"name":"s_node_box_pattern",
|
||||
"nineSlice":null,
|
||||
"origin":4,
|
||||
"parent":{
|
||||
"name":"generator",
|
||||
"path":"folders/nodes/icons/generator.yy",
|
||||
},
|
||||
"preMultiplyAlpha":false,
|
||||
"resourceType":"GMSprite",
|
||||
"resourceVersion":"2.0",
|
||||
"sequence":{
|
||||
"$GMSequence":"",
|
||||
"%Name":"s_node_box_pattern",
|
||||
"autoRecord":true,
|
||||
"backdropHeight":768,
|
||||
"backdropImageOpacity":0.5,
|
||||
"backdropImagePath":"",
|
||||
"backdropWidth":1366,
|
||||
"backdropXOffset":0.0,
|
||||
"backdropYOffset":0.0,
|
||||
"events":{
|
||||
"$KeyframeStore<MessageEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MessageEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"eventStubScript":null,
|
||||
"eventToFunction":{},
|
||||
"length":1.0,
|
||||
"lockOrigin":false,
|
||||
"moments":{
|
||||
"$KeyframeStore<MomentsEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"name":"s_node_box_pattern",
|
||||
"playback":1,
|
||||
"playbackSpeed":30.0,
|
||||
"playbackSpeedType":0,
|
||||
"resourceType":"GMSequence",
|
||||
"resourceVersion":"2.0",
|
||||
"showBackdrop":true,
|
||||
"showBackdropImage":false,
|
||||
"timeUnits":1,
|
||||
"tracks":[
|
||||
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"5a53fa49-2f6a-4b11-8b0c-7fb764332185","path":"sprites/s_node_box_pattern/s_node_box_pattern.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"e80e5eb8-6a7d-43d4-9330-9d4e06e3a051","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange":null,
|
||||
"volume":1.0,
|
||||
"xorigin":32,
|
||||
"yorigin":32,
|
||||
},
|
||||
"swatchColours":null,
|
||||
"swfPrecision":0.5,
|
||||
"textureGroupId":{
|
||||
"name":"Default",
|
||||
"path":"texturegroups/Default",
|
||||
},
|
||||
"type":0,
|
||||
"VTile":false,
|
||||
"width":64,
|
||||
}
|
Loading…
Reference in a new issue