mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-12 07:16:49 +01:00
Collection updated, group IO naming bug.
This commit is contained in:
parent
5c1c92ce03
commit
c5a6bb3aee
17 changed files with 413 additions and 21 deletions
|
@ -323,6 +323,7 @@
|
|||
{"name":"s_node_particle_effector","order":13,"path":"sprites/s_node_particle_effector/s_node_particle_effector.yy",},
|
||||
{"name":"sh_blur_bokeh","order":8,"path":"shaders/sh_blur_bokeh/sh_blur_bokeh.yy",},
|
||||
{"name":"s_node_translate_point","order":14,"path":"sprites/s_node_translate_point/s_node_translate_point.yy",},
|
||||
{"name":"sh_voronoi_extra","order":13,"path":"shaders/sh_voronoi_extra/sh_voronoi_extra.yy",},
|
||||
{"name":"o_dialog_textbox_autocomplete","order":7,"path":"objects/o_dialog_textbox_autocomplete/o_dialog_textbox_autocomplete.yy",},
|
||||
{"name":"s_node_loop_input","order":14,"path":"sprites/s_node_loop_input/s_node_loop_input.yy",},
|
||||
{"name":"node_strand_length_adjust","order":11,"path":"scripts/node_strand_length_adjust/node_strand_length_adjust.yy",},
|
||||
|
@ -687,6 +688,7 @@
|
|||
{"name":"luaHighlight","order":1,"path":"scripts/luaHighlight/luaHighlight.yy",},
|
||||
{"name":"d3d_rot3","order":3,"path":"scripts/d3d_rot3/d3d_rot3.yy",},
|
||||
{"name":"sh_sample_points","order":26,"path":"shaders/sh_sample_points/sh_sample_points.yy",},
|
||||
{"name":"node_voronoi_extra","order":24,"path":"scripts/node_voronoi_extra/node_voronoi_extra.yy",},
|
||||
{"name":"node_combine_rgb","order":1,"path":"scripts/node_combine_rgb/node_combine_rgb.yy",},
|
||||
{"name":"fd_rectangle_draw_part","order":10,"path":"scripts/fd_rectangle_draw_part/fd_rectangle_draw_part.yy",},
|
||||
{"name":"checkbox","order":7,"path":"scripts/checkbox/checkbox.yy",},
|
||||
|
@ -1191,6 +1193,7 @@
|
|||
{"name":"draw_line_zigzag","order":20,"path":"scripts/draw_line_zigzag/draw_line_zigzag.yy",},
|
||||
{"name":"sh_alpha_grey","order":1,"path":"shaders/sh_alpha_grey/sh_alpha_grey.yy",},
|
||||
{"name":"sh_channel_R2B","order":12,"path":"shaders/sh_channel_R2B/sh_channel_R2B.yy",},
|
||||
{"name":"s_node_voronoi_extra","order":36,"path":"sprites/s_node_voronoi_extra/s_node_voronoi_extra.yy",},
|
||||
{"name":"s_node_smokeSim_domain","order":11,"path":"sprites/s_node_smokeSim_domain/s_node_smokeSim_domain.yy",},
|
||||
{"name":"s_node_rigidSim_activate","order":6,"path":"sprites/s_node_rigidSim_activate/s_node_rigidSim_activate.yy",},
|
||||
{"name":"s_transparent","order":1,"path":"sprites/s_transparent/s_transparent.yy",},
|
||||
|
|
|
@ -897,6 +897,7 @@
|
|||
{"id":{"name":"s_node_particle_effector","path":"sprites/s_node_particle_effector/s_node_particle_effector.yy",},},
|
||||
{"id":{"name":"sh_blur_bokeh","path":"shaders/sh_blur_bokeh/sh_blur_bokeh.yy",},},
|
||||
{"id":{"name":"s_node_translate_point","path":"sprites/s_node_translate_point/s_node_translate_point.yy",},},
|
||||
{"id":{"name":"sh_voronoi_extra","path":"shaders/sh_voronoi_extra/sh_voronoi_extra.yy",},},
|
||||
{"id":{"name":"o_dialog_textbox_autocomplete","path":"objects/o_dialog_textbox_autocomplete/o_dialog_textbox_autocomplete.yy",},},
|
||||
{"id":{"name":"s_node_loop_input","path":"sprites/s_node_loop_input/s_node_loop_input.yy",},},
|
||||
{"id":{"name":"node_strand_length_adjust","path":"scripts/node_strand_length_adjust/node_strand_length_adjust.yy",},},
|
||||
|
@ -1314,6 +1315,7 @@
|
|||
{"id":{"name":"luaHighlight","path":"scripts/luaHighlight/luaHighlight.yy",},},
|
||||
{"id":{"name":"d3d_rot3","path":"scripts/d3d_rot3/d3d_rot3.yy",},},
|
||||
{"id":{"name":"sh_sample_points","path":"shaders/sh_sample_points/sh_sample_points.yy",},},
|
||||
{"id":{"name":"node_voronoi_extra","path":"scripts/node_voronoi_extra/node_voronoi_extra.yy",},},
|
||||
{"id":{"name":"node_combine_rgb","path":"scripts/node_combine_rgb/node_combine_rgb.yy",},},
|
||||
{"id":{"name":"fd_rectangle_draw_part","path":"scripts/fd_rectangle_draw_part/fd_rectangle_draw_part.yy",},},
|
||||
{"id":{"name":"checkbox","path":"scripts/checkbox/checkbox.yy",},},
|
||||
|
@ -1884,6 +1886,7 @@
|
|||
{"id":{"name":"draw_line_zigzag","path":"scripts/draw_line_zigzag/draw_line_zigzag.yy",},},
|
||||
{"id":{"name":"sh_alpha_grey","path":"shaders/sh_alpha_grey/sh_alpha_grey.yy",},},
|
||||
{"id":{"name":"sh_channel_R2B","path":"shaders/sh_channel_R2B/sh_channel_R2B.yy",},},
|
||||
{"id":{"name":"s_node_voronoi_extra","path":"sprites/s_node_voronoi_extra/s_node_voronoi_extra.yy",},},
|
||||
{"id":{"name":"s_node_smokeSim_domain","path":"sprites/s_node_smokeSim_domain/s_node_smokeSim_domain.yy",},},
|
||||
{"id":{"name":"s_node_rigidSim_activate","path":"sprites/s_node_rigidSim_activate/s_node_rigidSim_activate.yy",},},
|
||||
{"id":{"name":"s_transparent","path":"sprites/s_transparent/s_transparent.yy",},},
|
||||
|
|
Binary file not shown.
|
@ -323,7 +323,7 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
|||
|
||||
var _to_list = outputs[| 0].value_to;
|
||||
onSetDisplayName = _onSetDisplayName;
|
||||
if(attributes.inherit_name && !ds_list_empty(_to_list)) {
|
||||
if(!renamed && attributes.inherit_name && !ds_list_empty(_to_list)) {
|
||||
for( var i = 0; i < ds_list_size(_to_list); i++ ) {
|
||||
if(_to_list[| i].value_from != outputs[| 0]) continue;
|
||||
if(display_name == _to_list[| i].name) break;
|
||||
|
|
|
@ -100,7 +100,7 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
|||
outParent.display_type = inputs[| 0].display_type;
|
||||
|
||||
onSetDisplayName = _onSetDisplayName;
|
||||
if(attributes.inherit_name && inputs[| 0].value_from != noone) {
|
||||
if(!renamed && attributes.inherit_name && inputs[| 0].value_from != noone) {
|
||||
if(display_name != inputs[| 0].value_from.name) {
|
||||
onSetDisplayName = noone;
|
||||
setDisplayName(inputs[| 0].value_from.name);
|
||||
|
|
|
@ -577,6 +577,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #regio
|
|||
addNodeObject(generator, "Cellular Noise", s_node_noise_cell, "Node_Cellular", [1, Node_Cellular], ["voronoi", "worley"], "Generate voronoi pattern.");
|
||||
addNodeObject(generator, "Anisotropic Noise", s_node_noise_aniso, "Node_Noise_Aniso", [1, Node_Noise_Aniso],, "Generate anisotropic noise.");
|
||||
addNodeObject(generator, "Extra Perlins", s_node_perlin_extra, "Node_Perlin_Extra", [1, Node_Perlin_Extra], ["noise"], "Random perlin noise made with different algorithms.").patreonExtra();
|
||||
addNodeObject(generator, "Extra Voronoi", s_node_voronoi_extra, "Node_Voronoi_Extra", [1, Node_Voronoi_Extra], ["noise"], "Random voronoi noise made with different algorithms.").patreonExtra();
|
||||
addNodeObject(generator, "Gabor Noise", s_node_gabor, "Node_Gabor_Noise", [1, Node_Gabor_Noise]).patreonExtra();
|
||||
addNodeObject(generator, "Shard Noise", s_node_shard, "Node_Shard_Noise", [1, Node_Shard_Noise]).patreonExtra();
|
||||
addNodeObject(generator, "Wavelet Noise", s_node_wavelet, "Node_Wavelet_Noise", [1, Node_Wavelet_Noise]).patreonExtra();
|
||||
|
|
12
scripts/node_voronoi_extra/node_gradient.yy
Normal file
12
scripts/node_voronoi_extra/node_gradient.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_gradient",
|
||||
"tags": [],
|
||||
"resourceType": "GMScript",
|
||||
}
|
32
scripts/node_voronoi_extra/node_voronoi_extra.gml
Normal file
32
scripts/node_voronoi_extra/node_voronoi_extra.gml
Normal file
|
@ -0,0 +1,32 @@
|
|||
function Node_Voronoi_Extra(_x, _y, _group = noone) : Node_Shader_Generator(_x, _y, _group) constructor {
|
||||
name = "Extra Voronoi";
|
||||
shader = sh_voronoi_extra;
|
||||
|
||||
inputs[| 1] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ])
|
||||
.setDisplay(VALUE_DISPLAY.vector)
|
||||
.setUnitRef(function(index) { return getDimension(index); });
|
||||
addShaderProp(SHADER_UNIFORM.float, "position");
|
||||
|
||||
inputs[| 2] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 4, 4 ])
|
||||
.setDisplay(VALUE_DISPLAY.vector);
|
||||
addShaderProp(SHADER_UNIFORM.float, "scale");
|
||||
|
||||
inputs[| 3] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, irandom(99999));
|
||||
addShaderProp(SHADER_UNIFORM.float, "seed");
|
||||
|
||||
inputs[| 4] = nodeValue("Progress", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
||||
addShaderProp(SHADER_UNIFORM.float, "progress");
|
||||
|
||||
inputs[| 5] = nodeValue("Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Block", "Triangle" ]);
|
||||
addShaderProp(SHADER_UNIFORM.integer, "mode");
|
||||
|
||||
inputs[| 6] = nodeValue("Parameter A", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] });
|
||||
addShaderProp(SHADER_UNIFORM.float, "paramA");
|
||||
|
||||
input_display_list = [
|
||||
["Output", true], 0,
|
||||
["Noise", false], 5, 1, 2, 4, 6,
|
||||
];
|
||||
}
|
11
scripts/node_voronoi_extra/node_voronoi_extra.yy
Normal file
11
scripts/node_voronoi_extra/node_voronoi_extra.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"resourceType": "GMScript",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "node_voronoi_extra",
|
||||
"isCompatibility": false,
|
||||
"isDnD": false,
|
||||
"parent": {
|
||||
"name": "generator",
|
||||
"path": "folders/nodes/data/generator.yy",
|
||||
},
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
function preview_overlay_vector(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _spr) {
|
||||
var _val = array_clone(getValue());
|
||||
var hover = -1;
|
||||
if(!is_array(_val) || array_empty(_val)) return hover;
|
||||
if(is_array(_val[0])) return hover;
|
||||
|
||||
var __ax = _val[0];
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
// Cellular noise
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
|
@ -27,36 +26,35 @@ void main() {
|
|||
|
||||
st *= scale;
|
||||
|
||||
float md = 1.;
|
||||
float md = 8.;
|
||||
vec2 mg, mr;
|
||||
|
||||
if(pattern == 0) {
|
||||
vec2 i_st = floor(st);
|
||||
vec2 f_st = fract(st);
|
||||
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
vec2 neighbor = vec2(float(x), float(y));
|
||||
vec2 point = random2(mod(i_st + neighbor, scale));
|
||||
point += 0.5 + 0.5 * sin(time + TAU * point);
|
||||
for (int y = -1; y <= 1; y++)
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
vec2 neighbor = vec2(float(x), float(y));
|
||||
vec2 point = random2(mod(i_st + neighbor, scale));
|
||||
point = 0.5 + 0.5 * sin(time + TAU * point);
|
||||
|
||||
vec2 _diff = neighbor + point - f_st;
|
||||
float dist = length(_diff);
|
||||
vec2 _diff = neighbor + point - f_st;
|
||||
float dist = length(_diff);
|
||||
|
||||
if(dist < md) {
|
||||
md = dist;
|
||||
mr = _diff;
|
||||
mg = neighbor;
|
||||
}
|
||||
}
|
||||
if(dist < md) {
|
||||
md = dist;
|
||||
mr = _diff;
|
||||
mg = neighbor;
|
||||
}
|
||||
}
|
||||
|
||||
md = 1.;
|
||||
md = 8.;
|
||||
for(int y = -2; y <= 2; y++)
|
||||
for(int x = -2; x <= 2; x++) {
|
||||
vec2 g = mg + vec2(float(x), float(y));
|
||||
vec2 point = random2(mod(i_st + g, scale));
|
||||
point += 0.5 + 0.5 * sin(time + TAU * point);
|
||||
point = 0.5 + 0.5 * sin(time + TAU * point);
|
||||
|
||||
vec2 r = g + point - f_st;
|
||||
if(dot(mr - r, mr - r) > .000001)
|
||||
|
|
228
shaders/sh_voronoi_extra/sh_voronoi_extra.fsh
Normal file
228
shaders/sh_voronoi_extra/sh_voronoi_extra.fsh
Normal file
|
@ -0,0 +1,228 @@
|
|||
// The MIT License
|
||||
// Copyright © 2013 Inigo Quilez
|
||||
// https://www.youtube.com/c/InigoQuilez
|
||||
// https://iquilezles.org/
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
uniform float seed;
|
||||
uniform float progress;
|
||||
uniform float paramA;
|
||||
uniform vec2 u_resolution;
|
||||
uniform vec2 position;
|
||||
uniform vec2 scale;
|
||||
uniform int mode;
|
||||
|
||||
float PI = 3.14159265359;
|
||||
float s3 = sin(PI / 3.);
|
||||
|
||||
vec2 hash2( vec2 p ) { return fract(sin(vec2(dot(p, vec2(127.1 + seed, 311.7)), dot(p, vec2(269.5, 183.3 + seed)))) * 43758.5453); }
|
||||
|
||||
vec3 voronoi( in vec2 x ) { #region // IQ classic voronoi - shadertoy.com/view/ldl3W8
|
||||
vec2 ip = floor(x);
|
||||
vec2 fp = fract(x);
|
||||
|
||||
//----------------------------------
|
||||
// first pass: regular voronoi
|
||||
//----------------------------------
|
||||
vec2 mg, mr;
|
||||
|
||||
float md = 8.0;
|
||||
for( int j = -1; j <= 1; j++ )
|
||||
for( int i = -1; i <= 1; i++ ) {
|
||||
vec2 g = vec2(float(i), float(j));
|
||||
vec2 o = hash2( ip + g );
|
||||
o = 0.5 + 0.5 * sin( progress + 6.2831 * o );
|
||||
vec2 r = g + o - fp;
|
||||
float d = dot(r, r);
|
||||
|
||||
if( d < md ) {
|
||||
md = d;
|
||||
mr = r;
|
||||
mg = g;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// second pass: distance to borders
|
||||
//----------------------------------
|
||||
md = 8.0;
|
||||
for( int j = -2; j <= 2; j++ )
|
||||
for( int i = -2; i <= 2; i++ ) {
|
||||
vec2 g = mg + vec2(float(i), float(j));
|
||||
vec2 o = hash2( ip + g );
|
||||
o = 0.5 + 0.5 * sin( progress + 6.2831 * o );
|
||||
vec2 r = g + o - fp;
|
||||
|
||||
if( dot(mr - r, mr - r) > 0.00001 )
|
||||
md = min( md, dot( 0.5 * (mr + r), normalize(r - mr) ) );
|
||||
}
|
||||
|
||||
return vec3( md, mr );
|
||||
} #endregion
|
||||
|
||||
vec3 squareVoronoi( in vec2 x ) { #region // IQ classic voronoi - shadertoy.com/view/ldl3W8
|
||||
vec2 ip = floor(x);
|
||||
vec2 fp = fract(x);
|
||||
|
||||
//----------------------------------
|
||||
// first pass: regular voronoi
|
||||
//----------------------------------
|
||||
vec2 mg, mr;
|
||||
|
||||
float md = 8.0;
|
||||
for( int j = -1; j <= 1; j++ )
|
||||
for( int i = -1; i <= 1; i++ ) {
|
||||
vec2 g = vec2(float(i), float(j));
|
||||
vec2 o = hash2( ip + g );
|
||||
|
||||
o = 0.5 + 0.5 * sin( progress + 6.2831 * o );
|
||||
vec2 r = g + o * paramA - fp;
|
||||
float d = dot(r, r);
|
||||
|
||||
if( d < md ) {
|
||||
md = d;
|
||||
mr = r;
|
||||
mg = g;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// second pass: distance to borders
|
||||
//----------------------------------
|
||||
md = 8.0;
|
||||
for( int j = -2; j <= 2; j++ )
|
||||
for( int i = -2; i <= 2; i++ ) {
|
||||
vec2 g = mg + vec2(float(i), float(j));
|
||||
vec2 o = hash2( ip + g );
|
||||
|
||||
o = 0.5 + 0.5 * sin( progress + 6.2831 * o );
|
||||
vec2 r = g + o * paramA - fp;
|
||||
|
||||
if( dot(mr - r, mr - r) > 0.00001 )
|
||||
md = min( md, dot( 0.5 * (mr + r), normalize(r - mr) ) );
|
||||
}
|
||||
|
||||
return vec3( md, mr );
|
||||
} #endregion
|
||||
|
||||
#region // Fast Minimal Animated Blocks by Shane - shadertoy.com/view/MlVXzd
|
||||
float blockVoronoiDistanceMetrix(vec2 p) {
|
||||
p = fract(p) - .5;
|
||||
return max(abs(p.x) * (.866 + paramA) + p.y * .5, -p.y);
|
||||
}
|
||||
|
||||
float blockVoronoi(vec2 p) {
|
||||
vec2 o = sin(vec2(1.93, 0) + progress) * .166;
|
||||
float a = blockVoronoiDistanceMetrix(p + vec2(o.x, 0));
|
||||
float b = blockVoronoiDistanceMetrix(p + vec2(0, .5 + o.y));
|
||||
|
||||
p = -mat2(.5, -.866, .866, .5) * (p + .5); // Rotate the layer (coordinates) by 120 degrees.
|
||||
float c = blockVoronoiDistanceMetrix(p + vec2(o.x, 0));
|
||||
float d = blockVoronoiDistanceMetrix(p + vec2(0, .5 + o.y));
|
||||
|
||||
return min(min(a, b), min(c, d)) * 2.;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region // Triangle Voronoi by tdhooper - shadertoy.com/view/Ns3fD7
|
||||
vec3 sdTriEdges(vec2 p) { return vec3(dot(p, vec2(0,-1)), dot(p, vec2(s3, .5)), dot(p, vec2(-s3, .5))); }
|
||||
|
||||
float sdTri(vec2 p) { vec3 t = sdTriEdges(p); return max(t.x, max(t.y, t.z)); }
|
||||
|
||||
vec3 triPrimaryAxis(vec3 p) { vec3 a = abs(p); return (1. - step(a.xyz, a.yzx)) * step(a.zxy, a.xyz) * sign(p); }
|
||||
|
||||
float triPickComponent(vec3 v, vec3 mask) { v *= mask; return v.x + v.y + v.z; }
|
||||
|
||||
float triangleBorder(vec2 a, vec2 b) {
|
||||
vec3 ta = sdTriEdges(a);
|
||||
vec3 tb = sdTriEdges(b);
|
||||
|
||||
vec3 tbRel = sdTriEdges(b - a);
|
||||
vec3 axis = triPrimaryAxis(tbRel);
|
||||
bool isEdge = axis.x + axis.y + axis.z < 0.;
|
||||
float d;
|
||||
|
||||
if (isEdge) {
|
||||
float i = triPickComponent(ta, axis);
|
||||
float j = triPickComponent(tb, axis.zxy);
|
||||
float k = triPickComponent(tb, axis.yzx);
|
||||
d = max(i - j, i - k);
|
||||
} else {
|
||||
float i = triPickComponent(tb, axis);
|
||||
float j = triPickComponent(ta, axis.zxy);
|
||||
float k = triPickComponent(ta, axis.yzx);
|
||||
d = min(i - j, i - k);
|
||||
}
|
||||
|
||||
d /= s3 * 2.;
|
||||
|
||||
return abs(d);
|
||||
}
|
||||
|
||||
vec3 triangleVoronoi( in vec2 x ) {
|
||||
vec2 n = floor(x);
|
||||
vec2 f = fract(x);
|
||||
|
||||
//----------------------------------
|
||||
// first pass: regular voronoi
|
||||
//----------------------------------
|
||||
vec2 closestCell, closestPoint;
|
||||
const int reach = 2;
|
||||
|
||||
float closestDist = 8.0;
|
||||
for( int j = -reach; j <= reach; j++ )
|
||||
for( int i = -reach; i <= reach; i++ ) {
|
||||
vec2 cell = vec2(float(i),float(j));
|
||||
vec2 o = hash2( n + cell );
|
||||
|
||||
o = 0.5 + 0.5 * sin( progress * PI * 2. + 6.2831 * o );
|
||||
|
||||
vec2 point = cell + o - f;
|
||||
float dist = sdTri(point);
|
||||
|
||||
if( dist < closestDist ) {
|
||||
closestDist = dist;
|
||||
closestPoint = point;
|
||||
closestCell = cell;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// second pass: distance to borders
|
||||
//----------------------------------
|
||||
closestDist = 8.0;
|
||||
for( int j = -reach - 1; j <= reach + 1; j++ )
|
||||
for( int i = -reach - 1; i <= reach + 1; i++ ) {
|
||||
vec2 cell = closestCell + vec2(float(i), float(j));
|
||||
vec2 o = hash2( n + cell );
|
||||
|
||||
o = 0.5 + 0.5 * sin( progress * PI * 2. + 6.2831 * o );
|
||||
|
||||
vec2 point = cell + o - f;
|
||||
float dist = sdTri(closestPoint - point);
|
||||
|
||||
if( dist > 0.00001 )
|
||||
closestDist = min(closestDist, triangleBorder(closestPoint, point));
|
||||
}
|
||||
|
||||
return vec3( closestDist, closestPoint );
|
||||
}
|
||||
#endregion
|
||||
|
||||
void main() { #region
|
||||
vec2 pos = v_vTexcoord - .5;
|
||||
pos.x *= (u_resolution.x / u_resolution.y);
|
||||
pos = (pos + position) * scale / 4.;
|
||||
|
||||
if(mode == 0) {
|
||||
gl_FragColor = vec4(vec3(.1 + blockVoronoi(pos * vec2(1., -1.))), 1.0);
|
||||
} else if(mode == 1) {
|
||||
vec3 v = vec3(triangleVoronoi(pos * 2.));
|
||||
gl_FragColor = vec4(vec3(v.r), 1.0);
|
||||
} else if(mode == 2) {
|
||||
gl_FragColor = vec4(vec3(squareVoronoi(pos * 4.).r), 1.0);
|
||||
}
|
||||
} #endregion
|
19
shaders/sh_voronoi_extra/sh_voronoi_extra.vsh
Normal file
19
shaders/sh_voronoi_extra/sh_voronoi_extra.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;
|
||||
}
|
10
shaders/sh_voronoi_extra/sh_voronoi_extra.yy
Normal file
10
shaders/sh_voronoi_extra/sh_voronoi_extra.yy
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"resourceType": "GMShader",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_voronoi_extra",
|
||||
"parent": {
|
||||
"name": "noise",
|
||||
"path": "folders/shader/generator/noise.yy",
|
||||
},
|
||||
"type": 1,
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
74
sprites/s_node_voronoi_extra/s_node_voronoi_extra.yy
Normal file
74
sprites/s_node_voronoi_extra/s_node_voronoi_extra.yy
Normal file
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"resourceType": "GMSprite",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "s_node_voronoi_extra",
|
||||
"bbox_bottom": 63,
|
||||
"bbox_left": 0,
|
||||
"bbox_right": 63,
|
||||
"bbox_top": 0,
|
||||
"bboxMode": 0,
|
||||
"collisionKind": 1,
|
||||
"collisionTolerance": 0,
|
||||
"DynamicTexturePage": false,
|
||||
"edgeFiltering": false,
|
||||
"For3D": false,
|
||||
"frames": [
|
||||
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"6c690644-cf50-4587-8ffd-f07d7d3a3937",},
|
||||
],
|
||||
"gridX": 0,
|
||||
"gridY": 0,
|
||||
"height": 64,
|
||||
"HTile": false,
|
||||
"layers": [
|
||||
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"68386dfb-b4ae-4dad-a431-1dd654cd1367","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
|
||||
],
|
||||
"nineSlice": null,
|
||||
"origin": 4,
|
||||
"parent": {
|
||||
"name": "generator",
|
||||
"path": "folders/nodes/icons/generator.yy",
|
||||
},
|
||||
"preMultiplyAlpha": false,
|
||||
"sequence": {
|
||||
"resourceType": "GMSequence",
|
||||
"resourceVersion": "1.4",
|
||||
"name": "s_node_voronoi_extra",
|
||||
"autoRecord": true,
|
||||
"backdropHeight": 768,
|
||||
"backdropImageOpacity": 0.5,
|
||||
"backdropImagePath": "",
|
||||
"backdropWidth": 1366,
|
||||
"backdropXOffset": 0.0,
|
||||
"backdropYOffset": 0.0,
|
||||
"events": {"resourceType":"KeyframeStore<MessageEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
|
||||
"eventStubScript": null,
|
||||
"eventToFunction": {},
|
||||
"length": 1.0,
|
||||
"lockOrigin": false,
|
||||
"moments": {"resourceType":"KeyframeStore<MomentsEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
|
||||
"playback": 1,
|
||||
"playbackSpeed": 30.0,
|
||||
"playbackSpeedType": 0,
|
||||
"showBackdrop": true,
|
||||
"showBackdropImage": false,
|
||||
"timeUnits": 1,
|
||||
"tracks": [
|
||||
{"resourceType":"GMSpriteFramesTrack","resourceVersion":"1.0","name":"frames","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"1.0","Keyframes":[
|
||||
{"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"6c690644-cf50-4587-8ffd-f07d7d3a3937","path":"sprites/s_node_voronoi_extra/s_node_voronoi_extra.yy",},},},"Disabled":false,"id":"c34e74d7-9f41-4504-8969-8090a2093e9c","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,},
|
||||
],},"modifiers":[],"spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange": null,
|
||||
"volume": 1.0,
|
||||
"xorigin": 32,
|
||||
"yorigin": 32,
|
||||
},
|
||||
"swatchColours": null,
|
||||
"swfPrecision": 2.525,
|
||||
"textureGroupId": {
|
||||
"name": "Default",
|
||||
"path": "texturegroups/Default",
|
||||
},
|
||||
"type": 0,
|
||||
"VTile": false,
|
||||
"width": 64,
|
||||
}
|
Loading…
Reference in a new issue