mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +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_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_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_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",},
|
||||
|
|
|
@ -2059,6 +2059,8 @@
|
|||
{"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_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","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",},},
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#macro __vec3_up new __vec3(0.0, 0.0, 1.0)
|
||||
|
||||
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)) {
|
||||
x = _x.x;
|
||||
y = _x.y;
|
||||
|
@ -29,14 +29,14 @@ function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
|||
y = _y;
|
||||
z = _z;
|
||||
return self;
|
||||
} set(_x, _y, _z); #endregion
|
||||
} set(_x, _y, _z);
|
||||
|
||||
static isZero = function() { #region
|
||||
static isZero = function() {
|
||||
INLINE
|
||||
return x == 0 && y == 0 && z == 0;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static setIndex = function(index, value) { #region
|
||||
static setIndex = function(index, value) {
|
||||
INLINE
|
||||
switch(index) {
|
||||
case 0 : x = value; break;
|
||||
|
@ -44,73 +44,73 @@ function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
|||
case 2 : z = value; break;
|
||||
}
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static getIndex = function(index) { #region
|
||||
static getIndex = function(index) {
|
||||
switch(index) {
|
||||
case 0 : return x;
|
||||
case 1 : return y;
|
||||
case 2 : return z;
|
||||
}
|
||||
return 0;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static add = function(_vec3) { #region
|
||||
static add = function(_vec3) {
|
||||
INLINE
|
||||
return new __vec3(x + _vec3.x, y + _vec3.y, z + _vec3.z);
|
||||
} #endregion
|
||||
static _add = function(_vec3) { #region
|
||||
}
|
||||
static _add = function(_vec3) {
|
||||
INLINE
|
||||
x += _vec3.x;
|
||||
y += _vec3.y;
|
||||
z += _vec3.z;
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static subtract = function(_vec3) { #region
|
||||
static subtract = function(_vec3) {
|
||||
INLINE
|
||||
return new __vec3(x - _vec3.x, y - _vec3.y, z - _vec3.z);
|
||||
} #endregion
|
||||
static _subtract = function(_vec3) { #region
|
||||
}
|
||||
static _subtract = function(_vec3) {
|
||||
INLINE
|
||||
x -= _vec3.x;
|
||||
y -= _vec3.y;
|
||||
z -= _vec3.z;
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static multiply = function(_scalar) { #region
|
||||
static multiply = function(_scalar) {
|
||||
INLINE
|
||||
return new __vec3(x * _scalar, y * _scalar, z * _scalar);
|
||||
} #endregion
|
||||
static _multiply = function(_scalar) { #region
|
||||
}
|
||||
static _multiply = function(_scalar) {
|
||||
INLINE
|
||||
x *= _scalar;
|
||||
y *= _scalar;
|
||||
z *= _scalar;
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static multiplyVec = function(_vec) { #region
|
||||
static multiplyVec = function(_vec) {
|
||||
INLINE
|
||||
return new __vec3(x * _vec.x, y * _vec.y, z * _vec.z);
|
||||
} #endregion
|
||||
static _multiplyVec = function(_vec) { #region
|
||||
}
|
||||
static _multiplyVec = function(_vec) {
|
||||
INLINE
|
||||
x *= _vec.x;
|
||||
y *= _vec.y;
|
||||
z *= _vec.z;
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static divide = function(_scalar) { #region
|
||||
static divide = function(_scalar) {
|
||||
INLINE
|
||||
if (_scalar != 0)
|
||||
return new __vec3(x / _scalar, y / _scalar, z / _scalar);
|
||||
|
||||
return new __vec3(x, y, z); // Avoid division by zero
|
||||
} #endregion
|
||||
static _divide = function(_scalar) { #region
|
||||
}
|
||||
static _divide = function(_scalar) {
|
||||
INLINE
|
||||
if (_scalar != 0) {
|
||||
x /= _scalar;
|
||||
|
@ -118,39 +118,39 @@ function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
|||
z /= _scalar;
|
||||
}
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static dot = function(_vec3) { #region
|
||||
static dot = function(_vec3) {
|
||||
INLINE
|
||||
return x * _vec3.x + y * _vec3.y + z * _vec3.z;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static cross = function(_vec3) { #region
|
||||
static cross = function(_vec3) {
|
||||
INLINE
|
||||
var cross_x = y * _vec3.z - z * _vec3.y;
|
||||
var cross_y = z * _vec3.x - x * _vec3.z;
|
||||
var cross_z = x * _vec3.y - y * _vec3.x;
|
||||
return new __vec3(cross_x, cross_y, cross_z);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static distance = function(_vec3) { #region
|
||||
static distance = function(_vec3) {
|
||||
INLINE
|
||||
var dx = _vec3.x - x;
|
||||
var dy = _vec3.y - y;
|
||||
var dz = _vec3.z - z;
|
||||
return sqrt(dx * dx + dy * dy + dz * dz);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static length = function() { #region
|
||||
static length = function() {
|
||||
INLINE
|
||||
return sqrt(x * x + y * y + z * z);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static normalize = function() { #region
|
||||
static normalize = function() {
|
||||
INLINE
|
||||
return clone()._normalize();
|
||||
} #endregion
|
||||
static _normalize = function() { #region
|
||||
}
|
||||
static _normalize = function() {
|
||||
INLINE
|
||||
var _length = length();
|
||||
if (_length != 0) {
|
||||
|
@ -159,49 +159,49 @@ function __vec3(_x = 0, _y = _x, _z = _x) constructor {
|
|||
z /= _length;
|
||||
}
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static _lerpTo = function(to, speed = 0.3) { #region
|
||||
static _lerpTo = function(to, speed = 0.3) {
|
||||
INLINE
|
||||
x = lerp(x, to.x, speed);
|
||||
y = lerp(y, to.y, 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
|
||||
x = lerp_float(x, to.x, speed, pre);
|
||||
y = lerp_float(y, to.y, speed, pre);
|
||||
z = lerp_float(z, to.z, speed, pre);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static equal = function(to) { #region
|
||||
static equal = function(to) {
|
||||
INLINE
|
||||
return x == to.x && y == to.y && z == to.z;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static minVal = function(vec) { #region
|
||||
static minVal = function(vec) {
|
||||
INLINE
|
||||
return new __vec3(
|
||||
min(x, vec.x),
|
||||
min(y, vec.y),
|
||||
min(z, vec.z),
|
||||
);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static maxVal = function(vec) { #region
|
||||
static maxVal = function(vec) {
|
||||
INLINE
|
||||
return new __vec3(
|
||||
max(x, vec.x),
|
||||
max(y, vec.y),
|
||||
max(z, vec.z),
|
||||
);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static clone = function() { #region
|
||||
static clone = function() {
|
||||
INLINE
|
||||
return new __vec3(x, y, z);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
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,
|
||||
]
|
||||
|
||||
static step = function() { #region
|
||||
static step = function() {
|
||||
var _caps = getInputData(in_mesh + 5);
|
||||
|
||||
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 _sides = _data[in_mesh + 1];
|
||||
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);
|
||||
|
||||
return object;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
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 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(array_empty(lengths)) return out;
|
||||
|
||||
var _cKey = _dist;
|
||||
|
||||
if(ds_map_exists(cached_pos, _cKey)) {
|
||||
var _p = cached_pos[? _cKey];
|
||||
out.x = _p.x;
|
||||
|
@ -933,7 +934,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
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) {
|
||||
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;
|
||||
} #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;
|
||||
return getPointDistance(pix, _ind, out);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static getPointSegment = function(_rat) { #region
|
||||
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[| 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);
|
||||
|
||||
input_display_list = [ 4,
|
||||
["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,
|
||||
];
|
||||
|
||||
temp_surface = array_create(3);
|
||||
|
||||
static step = function() { #region
|
||||
var _filt = getInputData(8);
|
||||
static step = function() {
|
||||
var _filt = getInputData( 8);
|
||||
var _fclr = getInputData(11);
|
||||
|
||||
inputs[| 2].setVisible(_filt == 0);
|
||||
inputs[| 9].setVisible(_filt == 1, _filt == 1);
|
||||
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) {
|
||||
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 _fill = _data[3];
|
||||
var _seed = _data[4];
|
||||
var _targ = _data[5];
|
||||
var _innr = _data[6];
|
||||
var _rnbg = _data[7];
|
||||
var _filt = _data[8];
|
||||
var _cmap = _data[9];
|
||||
var _tmap = _data[10];
|
||||
|
||||
var _fclr = _data[11];
|
||||
var _targ = _data[5];
|
||||
var _innr = _data[6];
|
||||
|
||||
var _sw = surface_get_width_safe(_surf);
|
||||
var _sh = surface_get_height_safe(_surf)
|
||||
|
||||
|
@ -67,6 +76,10 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
|||
surface_clear(temp_surface[i]);
|
||||
}
|
||||
|
||||
var base = 0;
|
||||
var cmap = temp_surface[0];
|
||||
|
||||
if(_fclr) {
|
||||
#region filter color
|
||||
surface_set_shader(temp_surface[1], sh_region_fill_init);
|
||||
shader_set_color("targetColor", _targ);
|
||||
|
@ -76,7 +89,6 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
|||
#endregion
|
||||
|
||||
#region inner region
|
||||
var base = 0;
|
||||
var amo = _sw;
|
||||
|
||||
if(_innr) {
|
||||
|
@ -126,11 +138,35 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
|||
|
||||
draw_surface_safe(temp_surface[!base]);
|
||||
surface_reset_shader();
|
||||
|
||||
cmap = temp_surface[base];
|
||||
#endregion
|
||||
|
||||
var _pal = [];
|
||||
for( var i = 0, n = array_length(_colr); i < n; i++ )
|
||||
array_append(_pal, colToVec4(_colr[i]));
|
||||
} else {
|
||||
|
||||
#region coordinate
|
||||
surface_set_shader(temp_surface[base], sh_region_fill_coordinate_all_init);
|
||||
draw_surface_safe(_surf);
|
||||
surface_reset_shader();
|
||||
|
||||
base = !base;
|
||||
var amo = _sw + _sh;
|
||||
|
||||
repeat( amo ) {
|
||||
surface_set_shader(temp_surface[base], sh_region_fill_coordinate_all);
|
||||
shader_set_f("dimension", _sw, _sh);
|
||||
shader_set_surface("base", _surf);
|
||||
|
||||
draw_surface_safe(temp_surface[!base]);
|
||||
surface_reset_shader();
|
||||
|
||||
base = !base;
|
||||
}
|
||||
|
||||
cmap = temp_surface[!base];
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
surface_set_target(_outSurf);
|
||||
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
|
||||
|
||||
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_f("colors", _pal);
|
||||
shader_set_f("seed", _seed);
|
||||
shader_set_f("colorAmount", array_length(_colr));
|
||||
|
||||
draw_surface_safe(temp_surface[base]);
|
||||
draw_surface_safe(cmap);
|
||||
shader_reset();
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
case 1 : // Color Map
|
||||
shader_set(sh_region_fill_map);
|
||||
shader_set_surface("colorMap", _cmap);
|
||||
|
||||
draw_surface_safe(temp_surface[base]);
|
||||
draw_surface_safe(cmap);
|
||||
shader_reset();
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
case 2 : // Texture Map
|
||||
shader_set(sh_region_fill_rg_map);
|
||||
shader_set_surface("textureMap", _tmap);
|
||||
|
||||
draw_surface_safe(temp_surface[base]);
|
||||
draw_surface_safe(cmap);
|
||||
shader_reset();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ function array_to_string(arr) {
|
|||
}
|
||||
|
||||
function string_partial_match(str, key) {
|
||||
if(str == key) return 9999;
|
||||
|
||||
var amo = string_length(str);
|
||||
var run = 1;
|
||||
var consec = 0;
|
||||
|
|
|
@ -92,7 +92,7 @@ void main() {
|
|||
}
|
||||
|
||||
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);
|
||||
} else if(colored == 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() {
|
||||
vec4 c = texture2D( gm_BaseTexture, v_vTexcoord );
|
||||
|
||||
if(targetColor.a == 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.);
|
||||
if(targetColor.a == 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.);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue