mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-03-04 06:34:48 +01:00
[Checker] Add diagonal mode.
This commit is contained in:
parent
178f14241f
commit
8d441aad2f
2 changed files with 33 additions and 8 deletions
|
@ -34,11 +34,13 @@ function Node_Checker(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
|
||||||
|
|
||||||
newInput(8, nodeValue_Enum_Button("Type", self, 0, [ "Solid", "Smooth", "AA" ]));
|
newInput(8, nodeValue_Enum_Button("Type", self, 0, [ "Solid", "Smooth", "AA" ]));
|
||||||
|
|
||||||
|
newInput(9, nodeValue_Bool("Diagonal", self, false));
|
||||||
|
|
||||||
newOutput(0, nodeValue_Output("Surface Out", self, VALUE_TYPE.surface, noone));
|
newOutput(0, nodeValue_Output("Surface Out", self, VALUE_TYPE.surface, noone));
|
||||||
|
|
||||||
input_display_list = [
|
input_display_list = [
|
||||||
["Output", true], 0,
|
["Output", true], 0,
|
||||||
["Pattern", false], 1, 6, 2, 7, 3,
|
["Pattern", false], 9, 1, 6, 2, 7, 3,
|
||||||
["Render", false], 8, 4, 5,
|
["Render", false], 8, 4, 5,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -63,20 +65,23 @@ function Node_Checker(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
|
||||||
|
|
||||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||||
var _dim = _data[0];
|
var _dim = _data[0];
|
||||||
var _pos = _data[3];
|
var _pos = _data[3]
|
||||||
|
|
||||||
|
inputs[2].setVisible(!_data[9]);
|
||||||
|
|
||||||
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
|
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
|
||||||
|
|
||||||
surface_set_shader(_outSurf, sh_checkerboard);
|
surface_set_shader(_outSurf, sh_checkerboard);
|
||||||
shader_set_f("dimension", surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf));
|
shader_set_2("dimension", _dim);
|
||||||
|
shader_set_i("diagonal", _data[9]);
|
||||||
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
|
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("amount", _data[1], _data[6], inputs[1]);
|
||||||
shader_set_f_map("angle", _data[2], _data[7], inputs[2]);
|
shader_set_f_map("angle", _data[2], _data[7], inputs[2]);
|
||||||
shader_set_color("col1", _data[4]);
|
shader_set_color("col1", _data[4]);
|
||||||
shader_set_color("col2", _data[5]);
|
shader_set_color("col2", _data[5]);
|
||||||
shader_set_i("blend", _data[8]);
|
shader_set_i("blend", _data[8]);
|
||||||
|
|
||||||
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
|
draw_empty();
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
return _outSurf;
|
return _outSurf;
|
||||||
|
|
|
@ -5,6 +5,7 @@ varying vec4 v_vColour;
|
||||||
|
|
||||||
uniform vec2 dimension;
|
uniform vec2 dimension;
|
||||||
uniform vec2 position;
|
uniform vec2 position;
|
||||||
|
uniform int diagonal;
|
||||||
uniform int blend;
|
uniform int blend;
|
||||||
|
|
||||||
uniform vec2 amount;
|
uniform vec2 amount;
|
||||||
|
@ -28,7 +29,6 @@ float check(vec2 c, float amo, float ang) {
|
||||||
float mm = mod(floor(_x / _a) + floor(_y / _a), 2.);
|
float mm = mod(floor(_x / _a) + floor(_y / _a), 2.);
|
||||||
|
|
||||||
return mm < .5? 0.5 + dd : 0.5 - dd;
|
return mm < .5? 0.5 + dd : 0.5 - dd;
|
||||||
//return mod(floor(_x / _a) + floor(_y / _a), 2.);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -49,8 +49,28 @@ void main() {
|
||||||
|
|
||||||
vec2 a = dimension / dimension.y;
|
vec2 a = dimension / dimension.y;
|
||||||
vec2 c = (v_vTexcoord - position) * a;
|
vec2 c = (v_vTexcoord - position) * a;
|
||||||
|
float ch;
|
||||||
|
|
||||||
|
if(diagonal == 0 || blend != 0) {
|
||||||
|
if(diagonal == 1) {
|
||||||
|
ang += PI / 4.;
|
||||||
|
amo *= sqrt(2.);
|
||||||
|
}
|
||||||
|
|
||||||
|
ch = check(c, amo, ang);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
vec2 pa = floor(dimension / amo);
|
||||||
|
vec2 px = floor(dimension * c);
|
||||||
|
px = mod(px, pa);
|
||||||
|
|
||||||
|
bool d1 = px.x > px.y;
|
||||||
|
bool d2 = (pa.x - px.x) > px.y;
|
||||||
|
bool chk = (d1 && d2) || (!d1 && !d2);
|
||||||
|
|
||||||
|
ch = chk? 1. : 0.;
|
||||||
|
}
|
||||||
|
|
||||||
float ch = check(c, amo, ang);
|
|
||||||
|
|
||||||
if(blend == 0) gl_FragColor = ch < 0.5? col1 : col2;
|
if(blend == 0) gl_FragColor = ch < 0.5? col1 : col2;
|
||||||
else if(blend == 1) {
|
else if(blend == 1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue