mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
- [Path] Fix NaN error with 0 distance line.
This commit is contained in:
parent
533fd6ec75
commit
f1120a928c
17 changed files with 320 additions and 130 deletions
|
@ -1560,6 +1560,8 @@
|
||||||
{"name":"sh_rd_render","order":2,"path":"shaders/sh_rd_render/sh_rd_render.yy",},
|
{"name":"sh_rd_render","order":2,"path":"shaders/sh_rd_render/sh_rd_render.yy",},
|
||||||
{"name":"sh_region_fill_border","order":5,"path":"shaders/sh_region_fill_border/sh_region_fill_border.yy",},
|
{"name":"sh_region_fill_border","order":5,"path":"shaders/sh_region_fill_border/sh_region_fill_border.yy",},
|
||||||
{"name":"sh_region_fill_color","order":1,"path":"shaders/sh_region_fill_color/sh_region_fill_color.yy",},
|
{"name":"sh_region_fill_color","order":1,"path":"shaders/sh_region_fill_color/sh_region_fill_color.yy",},
|
||||||
|
{"name":"sh_region_fill_coordinate_all_init","order":9,"path":"shaders/sh_region_fill_coordinate_all_init/sh_region_fill_coordinate_all_init.yy",},
|
||||||
|
{"name":"sh_region_fill_coordinate_all","order":10,"path":"shaders/sh_region_fill_coordinate_all/sh_region_fill_coordinate_all.yy",},
|
||||||
{"name":"sh_region_fill_coordinate_init","order":6,"path":"shaders/sh_region_fill_coordinate_init/sh_region_fill_coordinate_init.yy",},
|
{"name":"sh_region_fill_coordinate_init","order":6,"path":"shaders/sh_region_fill_coordinate_init/sh_region_fill_coordinate_init.yy",},
|
||||||
{"name":"sh_region_fill_init","order":2,"path":"shaders/sh_region_fill_init/sh_region_fill_init.yy",},
|
{"name":"sh_region_fill_init","order":2,"path":"shaders/sh_region_fill_init/sh_region_fill_init.yy",},
|
||||||
{"name":"sh_region_fill_inner_remove","order":8,"path":"shaders/sh_region_fill_inner_remove/sh_region_fill_inner_remove.yy",},
|
{"name":"sh_region_fill_inner_remove","order":8,"path":"shaders/sh_region_fill_inner_remove/sh_region_fill_inner_remove.yy",},
|
||||||
|
|
|
@ -2059,6 +2059,8 @@
|
||||||
{"id":{"name":"sh_rd_render","path":"shaders/sh_rd_render/sh_rd_render.yy",},},
|
{"id":{"name":"sh_rd_render","path":"shaders/sh_rd_render/sh_rd_render.yy",},},
|
||||||
{"id":{"name":"sh_region_fill_border","path":"shaders/sh_region_fill_border/sh_region_fill_border.yy",},},
|
{"id":{"name":"sh_region_fill_border","path":"shaders/sh_region_fill_border/sh_region_fill_border.yy",},},
|
||||||
{"id":{"name":"sh_region_fill_color","path":"shaders/sh_region_fill_color/sh_region_fill_color.yy",},},
|
{"id":{"name":"sh_region_fill_color","path":"shaders/sh_region_fill_color/sh_region_fill_color.yy",},},
|
||||||
|
{"id":{"name":"sh_region_fill_coordinate_all_init","path":"shaders/sh_region_fill_coordinate_all_init/sh_region_fill_coordinate_all_init.yy",},},
|
||||||
|
{"id":{"name":"sh_region_fill_coordinate_all","path":"shaders/sh_region_fill_coordinate_all/sh_region_fill_coordinate_all.yy",},},
|
||||||
{"id":{"name":"sh_region_fill_coordinate_init","path":"shaders/sh_region_fill_coordinate_init/sh_region_fill_coordinate_init.yy",},},
|
{"id":{"name":"sh_region_fill_coordinate_init","path":"shaders/sh_region_fill_coordinate_init/sh_region_fill_coordinate_init.yy",},},
|
||||||
{"id":{"name":"sh_region_fill_coordinate","path":"shaders/sh_region_fill_coordinate/sh_region_fill_coordinate.yy",},},
|
{"id":{"name":"sh_region_fill_coordinate","path":"shaders/sh_region_fill_coordinate/sh_region_fill_coordinate.yy",},},
|
||||||
{"id":{"name":"sh_region_fill_init","path":"shaders/sh_region_fill_init/sh_region_fill_init.yy",},},
|
{"id":{"name":"sh_region_fill_init","path":"shaders/sh_region_fill_init/sh_region_fill_init.yy",},},
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#macro __vec3_up new __vec3(0.0, 0.0, 1.0)
|
#macro __vec3_up new __vec3(0.0, 0.0, 1.0)
|
||||||
|
|
||||||
function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
||||||
static set = function(_x = 0, _y = _x, _z = _x) { #region
|
static set = function(_x = 0, _y = _x, _z = _x) {
|
||||||
if(is_struct(_x) && is_instanceof(_x, __vec3)) {
|
if(is_struct(_x) && is_instanceof(_x, __vec3)) {
|
||||||
x = _x.x;
|
x = _x.x;
|
||||||
y = _x.y;
|
y = _x.y;
|
||||||
|
@ -29,14 +29,14 @@ function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
||||||
y = _y;
|
y = _y;
|
||||||
z = _z;
|
z = _z;
|
||||||
return self;
|
return self;
|
||||||
} set(_x, _y, _z); #endregion
|
} set(_x, _y, _z);
|
||||||
|
|
||||||
static isZero = function() { #region
|
static isZero = function() {
|
||||||
INLINE
|
INLINE
|
||||||
return x == 0 && y == 0 && z == 0;
|
return x == 0 && y == 0 && z == 0;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static setIndex = function(index, value) { #region
|
static setIndex = function(index, value) {
|
||||||
INLINE
|
INLINE
|
||||||
switch(index) {
|
switch(index) {
|
||||||
case 0 : x = value; break;
|
case 0 : x = value; break;
|
||||||
|
@ -44,73 +44,73 @@ function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
||||||
case 2 : z = value; break;
|
case 2 : z = value; break;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getIndex = function(index) { #region
|
static getIndex = function(index) {
|
||||||
switch(index) {
|
switch(index) {
|
||||||
case 0 : return x;
|
case 0 : return x;
|
||||||
case 1 : return y;
|
case 1 : return y;
|
||||||
case 2 : return z;
|
case 2 : return z;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static add = function(_vec3) { #region
|
static add = function(_vec3) {
|
||||||
INLINE
|
INLINE
|
||||||
return new __vec3(x + _vec3.x, y + _vec3.y, z + _vec3.z);
|
return new __vec3(x + _vec3.x, y + _vec3.y, z + _vec3.z);
|
||||||
} #endregion
|
}
|
||||||
static _add = function(_vec3) { #region
|
static _add = function(_vec3) {
|
||||||
INLINE
|
INLINE
|
||||||
x += _vec3.x;
|
x += _vec3.x;
|
||||||
y += _vec3.y;
|
y += _vec3.y;
|
||||||
z += _vec3.z;
|
z += _vec3.z;
|
||||||
return self;
|
return self;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static subtract = function(_vec3) { #region
|
static subtract = function(_vec3) {
|
||||||
INLINE
|
INLINE
|
||||||
return new __vec3(x - _vec3.x, y - _vec3.y, z - _vec3.z);
|
return new __vec3(x - _vec3.x, y - _vec3.y, z - _vec3.z);
|
||||||
} #endregion
|
}
|
||||||
static _subtract = function(_vec3) { #region
|
static _subtract = function(_vec3) {
|
||||||
INLINE
|
INLINE
|
||||||
x -= _vec3.x;
|
x -= _vec3.x;
|
||||||
y -= _vec3.y;
|
y -= _vec3.y;
|
||||||
z -= _vec3.z;
|
z -= _vec3.z;
|
||||||
return self;
|
return self;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static multiply = function(_scalar) { #region
|
static multiply = function(_scalar) {
|
||||||
INLINE
|
INLINE
|
||||||
return new __vec3(x * _scalar, y * _scalar, z * _scalar);
|
return new __vec3(x * _scalar, y * _scalar, z * _scalar);
|
||||||
} #endregion
|
}
|
||||||
static _multiply = function(_scalar) { #region
|
static _multiply = function(_scalar) {
|
||||||
INLINE
|
INLINE
|
||||||
x *= _scalar;
|
x *= _scalar;
|
||||||
y *= _scalar;
|
y *= _scalar;
|
||||||
z *= _scalar;
|
z *= _scalar;
|
||||||
return self;
|
return self;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static multiplyVec = function(_vec) { #region
|
static multiplyVec = function(_vec) {
|
||||||
INLINE
|
INLINE
|
||||||
return new __vec3(x * _vec.x, y * _vec.y, z * _vec.z);
|
return new __vec3(x * _vec.x, y * _vec.y, z * _vec.z);
|
||||||
} #endregion
|
}
|
||||||
static _multiplyVec = function(_vec) { #region
|
static _multiplyVec = function(_vec) {
|
||||||
INLINE
|
INLINE
|
||||||
x *= _vec.x;
|
x *= _vec.x;
|
||||||
y *= _vec.y;
|
y *= _vec.y;
|
||||||
z *= _vec.z;
|
z *= _vec.z;
|
||||||
return self;
|
return self;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static divide = function(_scalar) { #region
|
static divide = function(_scalar) {
|
||||||
INLINE
|
INLINE
|
||||||
if (_scalar != 0)
|
if (_scalar != 0)
|
||||||
return new __vec3(x / _scalar, y / _scalar, z / _scalar);
|
return new __vec3(x / _scalar, y / _scalar, z / _scalar);
|
||||||
|
|
||||||
return new __vec3(x, y, z); // Avoid division by zero
|
return new __vec3(x, y, z); // Avoid division by zero
|
||||||
} #endregion
|
}
|
||||||
static _divide = function(_scalar) { #region
|
static _divide = function(_scalar) {
|
||||||
INLINE
|
INLINE
|
||||||
if (_scalar != 0) {
|
if (_scalar != 0) {
|
||||||
x /= _scalar;
|
x /= _scalar;
|
||||||
|
@ -118,39 +118,39 @@ function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
||||||
z /= _scalar;
|
z /= _scalar;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static dot = function(_vec3) { #region
|
static dot = function(_vec3) {
|
||||||
INLINE
|
INLINE
|
||||||
return x * _vec3.x + y * _vec3.y + z * _vec3.z;
|
return x * _vec3.x + y * _vec3.y + z * _vec3.z;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static cross = function(_vec3) { #region
|
static cross = function(_vec3) {
|
||||||
INLINE
|
INLINE
|
||||||
var cross_x = y * _vec3.z - z * _vec3.y;
|
var cross_x = y * _vec3.z - z * _vec3.y;
|
||||||
var cross_y = z * _vec3.x - x * _vec3.z;
|
var cross_y = z * _vec3.x - x * _vec3.z;
|
||||||
var cross_z = x * _vec3.y - y * _vec3.x;
|
var cross_z = x * _vec3.y - y * _vec3.x;
|
||||||
return new __vec3(cross_x, cross_y, cross_z);
|
return new __vec3(cross_x, cross_y, cross_z);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static distance = function(_vec3) { #region
|
static distance = function(_vec3) {
|
||||||
INLINE
|
INLINE
|
||||||
var dx = _vec3.x - x;
|
var dx = _vec3.x - x;
|
||||||
var dy = _vec3.y - y;
|
var dy = _vec3.y - y;
|
||||||
var dz = _vec3.z - z;
|
var dz = _vec3.z - z;
|
||||||
return sqrt(dx * dx + dy * dy + dz * dz);
|
return sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static length = function() { #region
|
static length = function() {
|
||||||
INLINE
|
INLINE
|
||||||
return sqrt(x * x + y * y + z * z);
|
return sqrt(x * x + y * y + z * z);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static normalize = function() { #region
|
static normalize = function() {
|
||||||
INLINE
|
INLINE
|
||||||
return clone()._normalize();
|
return clone()._normalize();
|
||||||
} #endregion
|
}
|
||||||
static _normalize = function() { #region
|
static _normalize = function() {
|
||||||
INLINE
|
INLINE
|
||||||
var _length = length();
|
var _length = length();
|
||||||
if (_length != 0) {
|
if (_length != 0) {
|
||||||
|
@ -159,49 +159,49 @@ function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
||||||
z /= _length;
|
z /= _length;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static _lerpTo = function(to, speed = 0.3) { #region
|
static _lerpTo = function(to, speed = 0.3) {
|
||||||
INLINE
|
INLINE
|
||||||
x = lerp(x, to.x, speed);
|
x = lerp(x, to.x, speed);
|
||||||
y = lerp(y, to.y, speed);
|
y = lerp(y, to.y, speed);
|
||||||
z = lerp(z, to.z, speed);
|
z = lerp(z, to.z, speed);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static _lerp_float = function(to, speed = 5, pre = 0.01) { #region
|
static _lerp_float = function(to, speed = 5, pre = 0.01) {
|
||||||
INLINE
|
INLINE
|
||||||
x = lerp_float(x, to.x, speed, pre);
|
x = lerp_float(x, to.x, speed, pre);
|
||||||
y = lerp_float(y, to.y, speed, pre);
|
y = lerp_float(y, to.y, speed, pre);
|
||||||
z = lerp_float(z, to.z, speed, pre);
|
z = lerp_float(z, to.z, speed, pre);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static equal = function(to) { #region
|
static equal = function(to) {
|
||||||
INLINE
|
INLINE
|
||||||
return x == to.x && y == to.y && z == to.z;
|
return x == to.x && y == to.y && z == to.z;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static minVal = function(vec) { #region
|
static minVal = function(vec) {
|
||||||
INLINE
|
INLINE
|
||||||
return new __vec3(
|
return new __vec3(
|
||||||
min(x, vec.x),
|
min(x, vec.x),
|
||||||
min(y, vec.y),
|
min(y, vec.y),
|
||||||
min(z, vec.z),
|
min(z, vec.z),
|
||||||
);
|
);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static maxVal = function(vec) { #region
|
static maxVal = function(vec) {
|
||||||
INLINE
|
INLINE
|
||||||
return new __vec3(
|
return new __vec3(
|
||||||
max(x, vec.x),
|
max(x, vec.x),
|
||||||
max(y, vec.y),
|
max(y, vec.y),
|
||||||
max(z, vec.z),
|
max(z, vec.z),
|
||||||
);
|
);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static clone = function() { #region
|
static clone = function() {
|
||||||
INLINE
|
INLINE
|
||||||
return new __vec3(x, y, z);
|
return new __vec3(x, y, z);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static toString = function() { return $"[__vec3] ({x}, {y}, {z})"; }
|
static toString = function() { return $"[__vec3] ({x}, {y}, {z})"; }
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,13 @@ function Node_3D_Mesh_Path_Extrude(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y
|
||||||
["Material", false], in_mesh + 4, in_mesh + 2, in_mesh + 3, in_mesh + 9,
|
["Material", false], in_mesh + 4, in_mesh + 2, in_mesh + 3, in_mesh + 9,
|
||||||
]
|
]
|
||||||
|
|
||||||
static step = function() { #region
|
static step = function() {
|
||||||
var _caps = getInputData(in_mesh + 5);
|
var _caps = getInputData(in_mesh + 5);
|
||||||
|
|
||||||
inputs[| in_mesh + 3].setVisible(_caps, _caps);
|
inputs[| in_mesh + 3].setVisible(_caps, _caps);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
|
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||||
var _path = _data[in_mesh + 0];
|
var _path = _data[in_mesh + 0];
|
||||||
var _sides = _data[in_mesh + 1];
|
var _sides = _data[in_mesh + 1];
|
||||||
var _mat_sid = _data[in_mesh + 2];
|
var _mat_sid = _data[in_mesh + 2];
|
||||||
|
@ -104,7 +104,7 @@ function Node_3D_Mesh_Path_Extrude(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y
|
||||||
setTransform(object, _data);
|
setTransform(object, _data);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getPreviewValues = function() { return array_safe_get_fast(all_inputs, in_mesh + 2, noone); }
|
static getPreviewValues = function() { return array_safe_get_fast(all_inputs, in_mesh + 2, noone); }
|
||||||
}
|
}
|
|
@ -904,11 +904,12 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
static getLength = function() { return lengthTotal; }
|
static getLength = function() { return lengthTotal; }
|
||||||
static getAccuLength = function() { return lengthAccs; }
|
static getAccuLength = function() { return lengthAccs; }
|
||||||
|
|
||||||
static getPointDistance = function(_dist, _ind = 0, out = undefined) { #region
|
static getPointDistance = function(_dist, _ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
||||||
if(array_empty(lengths)) return out;
|
if(array_empty(lengths)) return out;
|
||||||
|
|
||||||
var _cKey = _dist;
|
var _cKey = _dist;
|
||||||
|
|
||||||
if(ds_map_exists(cached_pos, _cKey)) {
|
if(ds_map_exists(cached_pos, _cKey)) {
|
||||||
var _p = cached_pos[? _cKey];
|
var _p = cached_pos[? _cKey];
|
||||||
out.x = _p.x;
|
out.x = _p.x;
|
||||||
|
@ -933,7 +934,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _t = _dist / lengths[i];
|
var _t = lengths[i] == 0? 0 : _dist / lengths[i];
|
||||||
|
|
||||||
if(_a0[4] == 0 && _a0[5] == 0 && _a1[2] == 0 && _a1[3] == 0) {
|
if(_a0[4] == 0 && _a0[5] == 0 && _a1[2] == 0 && _a1[3] == 0) {
|
||||||
out.x = lerp(_a0[0], _a1[0], _t);
|
out.x = lerp(_a0[0], _a1[0], _t);
|
||||||
|
@ -948,12 +949,12 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getPointRatio = function(_rat, _ind = 0, out = undefined) { #region
|
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
||||||
var pix = (path_loop? frac(_rat) : clamp(_rat, 0, 0.99)) * lengthTotal;
|
var pix = (path_loop? frac(_rat) : clamp(_rat, 0, 0.99)) * lengthTotal;
|
||||||
return getPointDistance(pix, _ind, out);
|
return getPointDistance(pix, _ind, out);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getPointSegment = function(_rat) { #region
|
static getPointSegment = function(_rat) { #region
|
||||||
if(array_empty(lengths)) return new __vec2();
|
if(array_empty(lengths)) return new __vec2();
|
||||||
|
|
|
@ -27,23 +27,30 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
|
|
||||||
inputs[| 10] = nodeValue("Texture map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
inputs[| 10] = nodeValue("Texture map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
|
inputs[| 11] = nodeValue("Color Filter", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
input_display_list = [ 4,
|
input_display_list = [ 4,
|
||||||
["Surfaces", false], 0, 1,
|
["Surfaces", false], 0, 1,
|
||||||
["Fill", false], 5, 8, 2, 9, 10, 6,
|
["Regions", false, 11], 5, 6,
|
||||||
|
["Fill", false], 8, 2, 9, 10,
|
||||||
["Render", false], 7,
|
["Render", false], 7,
|
||||||
];
|
];
|
||||||
|
|
||||||
temp_surface = array_create(3);
|
temp_surface = array_create(3);
|
||||||
|
|
||||||
static step = function() { #region
|
static step = function() {
|
||||||
var _filt = getInputData(8);
|
var _filt = getInputData( 8);
|
||||||
|
var _fclr = getInputData(11);
|
||||||
|
|
||||||
inputs[| 2].setVisible(_filt == 0);
|
inputs[| 2].setVisible(_filt == 0);
|
||||||
inputs[| 9].setVisible(_filt == 1, _filt == 1);
|
inputs[| 9].setVisible(_filt == 1, _filt == 1);
|
||||||
inputs[| 10].setVisible(_filt == 2, _filt == 2);
|
inputs[| 10].setVisible(_filt == 2, _filt == 2);
|
||||||
} #endregion
|
|
||||||
|
inputs[| 5].setVisible(_fclr);
|
||||||
|
inputs[| 6].setVisible(_fclr);
|
||||||
|
}
|
||||||
|
|
||||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||||
var _surf = _data[0];
|
var _surf = _data[0];
|
||||||
|
@ -52,13 +59,15 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
var _colr = _data[2];
|
var _colr = _data[2];
|
||||||
var _fill = _data[3];
|
var _fill = _data[3];
|
||||||
var _seed = _data[4];
|
var _seed = _data[4];
|
||||||
var _targ = _data[5];
|
|
||||||
var _innr = _data[6];
|
|
||||||
var _rnbg = _data[7];
|
var _rnbg = _data[7];
|
||||||
var _filt = _data[8];
|
var _filt = _data[8];
|
||||||
var _cmap = _data[9];
|
var _cmap = _data[9];
|
||||||
var _tmap = _data[10];
|
var _tmap = _data[10];
|
||||||
|
|
||||||
|
var _fclr = _data[11];
|
||||||
|
var _targ = _data[5];
|
||||||
|
var _innr = _data[6];
|
||||||
|
|
||||||
var _sw = surface_get_width_safe(_surf);
|
var _sw = surface_get_width_safe(_surf);
|
||||||
var _sh = surface_get_height_safe(_surf)
|
var _sh = surface_get_height_safe(_surf)
|
||||||
|
|
||||||
|
@ -67,22 +76,55 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
surface_clear(temp_surface[i]);
|
surface_clear(temp_surface[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region filter color
|
var base = 0;
|
||||||
surface_set_shader(temp_surface[1], sh_region_fill_init);
|
var cmap = temp_surface[0];
|
||||||
shader_set_color("targetColor", _targ);
|
|
||||||
|
|
||||||
draw_surface_safe(_surf);
|
if(_fclr) {
|
||||||
surface_reset_shader();
|
#region filter color
|
||||||
#endregion
|
surface_set_shader(temp_surface[1], sh_region_fill_init);
|
||||||
|
shader_set_color("targetColor", _targ);
|
||||||
|
|
||||||
#region inner region
|
draw_surface_safe(_surf);
|
||||||
var base = 0;
|
surface_reset_shader();
|
||||||
var amo = _sw;
|
#endregion
|
||||||
|
|
||||||
|
#region inner region
|
||||||
|
var amo = _sw;
|
||||||
|
|
||||||
|
if(_innr) {
|
||||||
|
repeat( amo ) {
|
||||||
|
surface_set_shader(temp_surface[base], sh_region_fill_inner);
|
||||||
|
shader_set_f("dimension", _sw, _sh);
|
||||||
|
|
||||||
|
draw_surface_safe(temp_surface[!base]);
|
||||||
|
surface_reset_shader();
|
||||||
|
|
||||||
|
base = !base;
|
||||||
|
}
|
||||||
|
|
||||||
|
surface_set_shader(temp_surface[2], sh_region_fill_inner_remove);
|
||||||
|
draw_surface_safe(temp_surface[!base]);
|
||||||
|
surface_reset_shader();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
surface_set_shader(temp_surface[2], sh_region_fill_inner_remove);
|
||||||
|
draw_surface_safe(temp_surface[1]);
|
||||||
|
surface_reset_shader();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region coordinate
|
||||||
|
surface_set_shader(temp_surface[base], sh_region_fill_coordinate_init);
|
||||||
|
draw_surface_safe(temp_surface[2]);
|
||||||
|
surface_reset_shader();
|
||||||
|
|
||||||
|
base = !base;
|
||||||
|
var amo = _sw + _sh;
|
||||||
|
|
||||||
if(_innr) {
|
|
||||||
repeat( amo ) {
|
repeat( amo ) {
|
||||||
surface_set_shader(temp_surface[base], sh_region_fill_inner);
|
surface_set_shader(temp_surface[base], sh_region_fill_coordinate);
|
||||||
shader_set_f("dimension", _sw, _sh);
|
shader_set_f("dimension", _sw, _sh);
|
||||||
|
shader_set_surface("base", temp_surface[2]);
|
||||||
|
|
||||||
draw_surface_safe(temp_surface[!base]);
|
draw_surface_safe(temp_surface[!base]);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
@ -90,47 +132,41 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
base = !base;
|
base = !base;
|
||||||
}
|
}
|
||||||
|
|
||||||
surface_set_shader(temp_surface[2], sh_region_fill_inner_remove);
|
surface_set_shader(temp_surface[base], sh_region_fill_border);
|
||||||
|
shader_set_f("dimension", _sw, _sh);
|
||||||
|
shader_set_surface("original", _surf);
|
||||||
|
|
||||||
draw_surface_safe(temp_surface[!base]);
|
draw_surface_safe(temp_surface[!base]);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
} else {
|
cmap = temp_surface[base];
|
||||||
surface_set_shader(temp_surface[2], sh_region_fill_inner_remove);
|
#endregion
|
||||||
draw_surface_safe(temp_surface[1]);
|
|
||||||
surface_reset_shader();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region coordinate
|
} else {
|
||||||
surface_set_shader(temp_surface[base], sh_region_fill_coordinate_init);
|
|
||||||
draw_surface_safe(temp_surface[2]);
|
|
||||||
surface_reset_shader();
|
|
||||||
|
|
||||||
base = !base;
|
#region coordinate
|
||||||
var amo = _sw + _sh;
|
surface_set_shader(temp_surface[base], sh_region_fill_coordinate_all_init);
|
||||||
|
draw_surface_safe(_surf);
|
||||||
repeat( amo ) {
|
|
||||||
surface_set_shader(temp_surface[base], sh_region_fill_coordinate);
|
|
||||||
shader_set_f("dimension", _sw, _sh);
|
|
||||||
shader_set_surface("base", temp_surface[2]);
|
|
||||||
|
|
||||||
draw_surface_safe(temp_surface[!base]);
|
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
base = !base;
|
base = !base;
|
||||||
}
|
var amo = _sw + _sh;
|
||||||
|
|
||||||
surface_set_shader(temp_surface[base], sh_region_fill_border);
|
repeat( amo ) {
|
||||||
shader_set_f("dimension", _sw, _sh);
|
surface_set_shader(temp_surface[base], sh_region_fill_coordinate_all);
|
||||||
shader_set_surface("original", _surf);
|
shader_set_f("dimension", _sw, _sh);
|
||||||
|
shader_set_surface("base", _surf);
|
||||||
|
|
||||||
draw_surface_safe(temp_surface[!base]);
|
draw_surface_safe(temp_surface[!base]);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
#endregion
|
|
||||||
|
|
||||||
var _pal = [];
|
base = !base;
|
||||||
for( var i = 0, n = array_length(_colr); i < n; i++ )
|
}
|
||||||
array_append(_pal, colToVec4(_colr[i]));
|
|
||||||
|
cmap = temp_surface[!base];
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
surface_set_target(_outSurf);
|
surface_set_target(_outSurf);
|
||||||
DRAW_CLEAR
|
DRAW_CLEAR
|
||||||
|
@ -138,29 +174,33 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
if(_rnbg == 2) draw_surface_safe(_surf); // render original
|
if(_rnbg == 2) draw_surface_safe(_surf); // render original
|
||||||
|
|
||||||
switch(_filt) {
|
switch(_filt) {
|
||||||
case 0 :
|
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(sh_region_fill_color);
|
||||||
shader_set_f("colors", _pal);
|
shader_set_f("colors", _pal);
|
||||||
shader_set_f("seed", _seed);
|
shader_set_f("seed", _seed);
|
||||||
shader_set_f("colorAmount", array_length(_colr));
|
shader_set_f("colorAmount", array_length(_colr));
|
||||||
|
|
||||||
draw_surface_safe(temp_surface[base]);
|
draw_surface_safe(cmap);
|
||||||
shader_reset();
|
shader_reset();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1 :
|
case 1 : // Color Map
|
||||||
shader_set(sh_region_fill_map);
|
shader_set(sh_region_fill_map);
|
||||||
shader_set_surface("colorMap", _cmap);
|
shader_set_surface("colorMap", _cmap);
|
||||||
|
|
||||||
draw_surface_safe(temp_surface[base]);
|
draw_surface_safe(cmap);
|
||||||
shader_reset();
|
shader_reset();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2 :
|
case 2 : // Texture Map
|
||||||
shader_set(sh_region_fill_rg_map);
|
shader_set(sh_region_fill_rg_map);
|
||||||
shader_set_surface("textureMap", _tmap);
|
shader_set_surface("textureMap", _tmap);
|
||||||
|
|
||||||
draw_surface_safe(temp_surface[base]);
|
draw_surface_safe(cmap);
|
||||||
shader_reset();
|
shader_reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ function array_to_string(arr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function string_partial_match(str, key) {
|
function string_partial_match(str, key) {
|
||||||
|
if(str == key) return 9999;
|
||||||
|
|
||||||
var amo = string_length(str);
|
var amo = string_length(str);
|
||||||
var run = 1;
|
var run = 1;
|
||||||
var consec = 0;
|
var consec = 0;
|
||||||
|
|
|
@ -92,7 +92,7 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(colored == 0) {
|
if(colored == 0) {
|
||||||
float c = middle + (random(mp) - middle) * contrast;
|
float c = middle + (random(mp + 1.) - middle) * contrast;
|
||||||
gl_FragColor = vec4(vec3(c), 1.0);
|
gl_FragColor = vec4(vec3(c), 1.0);
|
||||||
} else if(colored == 1) {
|
} else if(colored == 1) {
|
||||||
gl_FragColor = vec4(colorNoise(mp), 1.);
|
gl_FragColor = vec4(colorNoise(mp), 1.);
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
varying vec2 v_vTexcoord;
|
||||||
|
varying vec4 v_vColour;
|
||||||
|
|
||||||
|
#define ITERATION 4.
|
||||||
|
|
||||||
|
uniform sampler2D base;
|
||||||
|
uniform vec2 dimension;
|
||||||
|
|
||||||
|
vec2 minn( in vec2 a, in vec2 b) {
|
||||||
|
if(a.y < b.y) return a;
|
||||||
|
else if(a.y > b.y) return b;
|
||||||
|
|
||||||
|
return (a.x < b.x)? a : b;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 maxx( in vec2 a, in vec2 b) {
|
||||||
|
if(a.y < b.y) return b;
|
||||||
|
else if(a.y > b.y) return a;
|
||||||
|
|
||||||
|
return (a.x < b.x)? b : a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec2 tx = 1. / dimension;
|
||||||
|
vec4 c = texture2D( gm_BaseTexture, v_vTexcoord );
|
||||||
|
vec4 ba = texture2D( base, v_vTexcoord );
|
||||||
|
|
||||||
|
gl_FragColor = c;
|
||||||
|
|
||||||
|
for( float i = 1.; i < ITERATION; i++ ) {
|
||||||
|
vec2 x = v_vTexcoord + vec2(tx.x * i, 0);
|
||||||
|
if(x.x < 0. || x.y < 0. || x.x > 1. || x.y > 1.) break;
|
||||||
|
|
||||||
|
vec4 b = texture2D( base, x );
|
||||||
|
if(b != ba) break;
|
||||||
|
|
||||||
|
vec4 s = texture2D( gm_BaseTexture, x );
|
||||||
|
gl_FragColor.xy = minn( gl_FragColor.xy, s.xy );
|
||||||
|
gl_FragColor.zw = maxx( gl_FragColor.zw, s.zw );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( float i = 1.; i < ITERATION; i++ ) {
|
||||||
|
vec2 x = v_vTexcoord - vec2(tx.x * i, 0);
|
||||||
|
if(x.x < 0. || x.y < 0. || x.x > 1. || x.y > 1.) break;
|
||||||
|
|
||||||
|
vec4 b = texture2D( base, x );
|
||||||
|
if(b != ba) break;
|
||||||
|
|
||||||
|
vec4 s = texture2D( gm_BaseTexture, x );
|
||||||
|
gl_FragColor.xy = min( gl_FragColor.xy, s.xy );
|
||||||
|
gl_FragColor.zw = max( gl_FragColor.zw, s.zw );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( float i = 1.; i < ITERATION; i++ ) {
|
||||||
|
vec2 x = v_vTexcoord + vec2(0, tx.y * i);
|
||||||
|
if(x.x < 0. || x.y < 0. || x.x > 1. || x.y > 1.) break;
|
||||||
|
|
||||||
|
vec4 b = texture2D( base, x );
|
||||||
|
if(b != ba) break;
|
||||||
|
|
||||||
|
vec4 s = texture2D( gm_BaseTexture, x );
|
||||||
|
gl_FragColor.xy = min( gl_FragColor.xy, s.xy );
|
||||||
|
gl_FragColor.zw = max( gl_FragColor.zw, s.zw );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( float i = 1.; i < ITERATION; i++ ) {
|
||||||
|
vec2 x = v_vTexcoord - vec2(0, tx.y * i);
|
||||||
|
if(x.x < 0. || x.y < 0. || x.x > 1. || x.y > 1.) break;
|
||||||
|
|
||||||
|
vec4 b = texture2D( base, x );
|
||||||
|
if(b != ba) break;
|
||||||
|
|
||||||
|
vec4 s = texture2D( gm_BaseTexture, x );
|
||||||
|
gl_FragColor.xy = min( gl_FragColor.xy, s.xy );
|
||||||
|
gl_FragColor.zw = max( gl_FragColor.zw, s.zw );
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"$GMShader":"",
|
||||||
|
"%Name":"sh_region_fill_coordinate_all",
|
||||||
|
"name":"sh_region_fill_coordinate_all",
|
||||||
|
"parent":{
|
||||||
|
"name":"region",
|
||||||
|
"path":"folders/shader/generator/region.yy",
|
||||||
|
},
|
||||||
|
"resourceType":"GMShader",
|
||||||
|
"resourceVersion":"2.0",
|
||||||
|
"type":1,
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
varying vec2 v_vTexcoord;
|
||||||
|
varying vec4 v_vColour;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_FragColor = vec4(v_vTexcoord, v_vTexcoord);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"$GMShader":"",
|
||||||
|
"%Name":"sh_region_fill_coordinate_all_init",
|
||||||
|
"name":"sh_region_fill_coordinate_all_init",
|
||||||
|
"parent":{
|
||||||
|
"name":"region",
|
||||||
|
"path":"folders/shader/generator/region.yy",
|
||||||
|
},
|
||||||
|
"resourceType":"GMShader",
|
||||||
|
"resourceVersion":"2.0",
|
||||||
|
"type":1,
|
||||||
|
}
|
|
@ -6,8 +6,6 @@ uniform vec4 targetColor;
|
||||||
void main() {
|
void main() {
|
||||||
vec4 c = texture2D( gm_BaseTexture, v_vTexcoord );
|
vec4 c = texture2D( gm_BaseTexture, v_vTexcoord );
|
||||||
|
|
||||||
if(targetColor.a == 0.)
|
if(targetColor.a == 0.) gl_FragColor = c.a == 0.? vec4(1., 0., 0., 1.) : vec4(0.);
|
||||||
gl_FragColor = c.a == 0.? vec4(1., 0., 0., 1.) : vec4(0.);
|
else gl_FragColor = targetColor == c? vec4(1., 0., 0., 1.) : vec4(0.);
|
||||||
else
|
|
||||||
gl_FragColor = targetColor == c? vec4(1., 0., 0., 1.) : vec4(0.);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ vec4 smear(vec2 angle) { #region
|
||||||
|
|
||||||
if(modulateStr != 2) {
|
if(modulateStr != 2) {
|
||||||
if(alpha == 0) col.rgb *= 1. - i;
|
if(alpha == 0) col.rgb *= 1. - i;
|
||||||
else col.a *= 1. - i;
|
else col.a *= 1. - i;
|
||||||
}
|
}
|
||||||
|
|
||||||
float bright = (col.r + col.g + col.b) / 3. * col.a;
|
float bright = (col.r + col.g + col.b) / 3. * col.a;
|
||||||
|
|
Loading…
Reference in a new issue