aa mode for generators

This commit is contained in:
Tanasart 2024-03-27 20:18:39 +07:00
parent 0a7b9bcee0
commit 88ef6faf13
17 changed files with 149 additions and 62 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

@ -86,7 +86,9 @@ function Panel_Linear_Setting() : PanelContent() constructor { #region
_widg.setFocusHover(pFOCUS, pHOVER);
_widg.register();
//if(i % 2) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, ui(4), yy - th / 2, w - ui(8), th, COLORS.panel_prop_bg, 0.25);
if(pHOVER && point_in_rectangle(mx, my, 0, yy - th / 2, w, yy + th / 2)) {
bg_y_to = yy - th / 2;
_hov = true;

View file

@ -318,12 +318,13 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
case VALUE_TYPE.boolean :
if(is_instanceof(wid, checkBoxActive)) break;
param.halign = breakLine? fa_left : fa_center;
param.s = breakLine? ui(24) : editBoxH;
param.s = editBoxH;
if(!breakLine) {
param.w = ui(128);
param.x = param.x + editBoxW - param.w;
param.w = ww - min(ui(80) + ww * 0.2, ui(200));
param.x = editBoxX + editBoxW - param.w;
}
break;

View file

@ -28,12 +28,15 @@ function Node_Checker(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
//////////////////////////////////////////////////////////////////////////////////
inputs[| 8] = nodeValue("Type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_button, [ "Solid", "Smooth", "AA" ]);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [
["Output", true], 0,
["Pattern", false], 1, 6, 2, 7, 3,
["Render", false], 4, 5,
["Render", false], 8, 4, 5,
];
attribute_surface_depth();
@ -65,6 +68,7 @@ function Node_Checker(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
shader_set_f_map("angle", _data[2], _data[7], inputs[| 2]);
shader_set_color("col1", _data[4]);
shader_set_color("col2", _data[5]);
shader_set_i("blend", _data[8]);
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
surface_reset_shader();

View file

@ -12,7 +12,8 @@ function Node_Stripe(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
.setDisplay(VALUE_DISPLAY.rotation)
.setMappable(12);
inputs[| 3] = nodeValue("Blend", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, 0, "Smoothly blend between each stripe.");
inputs[| 3] = nodeValue("Type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_button, [ "Solid", "Smooth", "AA" ]);
inputs[| 4] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 0 ] )
.setDisplay(VALUE_DISPLAY.vector)
@ -97,7 +98,7 @@ function Node_Stripe(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
surface_set_shader(_outSurf, sh_stripe);
shader_set_f("dimension", _dim[0], _dim[1]);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("blend", _bnd);
shader_set_i("blend", _bnd);
shader_set_f_map("amount", _data[ 1], _data[11], inputs[| 1]);
shader_set_f_map("angle", _data[ 2], _data[12], inputs[| 2]);

View file

@ -908,9 +908,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
var len = array_length(val);
if(len <= 4) {
editWidget = new vectorBox(len, function(index, val) {
return setValueInspector(val, index);
}, unit );
editWidget = new vectorBox(len, function(index, val) { return setValueInspector(val, index); }, unit );
if(struct_has(display_data, "label")) editWidget.axis = display_data.label;
if(struct_has(display_data, "linkable")) editWidget.linkable = display_data.linkable;

View file

@ -16,30 +16,43 @@ function Node_Zigzag(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
inputs[| 4] = nodeValue("Color 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
inputs[| 5] = nodeValue("Smooth", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| 5] = nodeValue("Type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_button, [ "Solid", "Smooth", "AA" ]);
//////////////////////////////////////////////////////////////////////////////////
inputs[| 6] = nodeValueMap("Amount map", self);
inputs[| 7] = nodeValueMap("Angle map", self);
//////////////////////////////////////////////////////////////////////////////////
inputs[| 8] = nodeValue("Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.rotation)
.setMappable(7);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [
["Output", false], 0,
["Pattern", false], 1, 6, 2,
["Render", false], 3, 4, 5,
["Pattern", false], 1, 6, 2, 8,
["Render", false], 5, 3, 4,
];
attribute_surface_depth();
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var pos = getInputData(2);
var px = _x + pos[0] * _s;
var py = _y + pos[1] * _s;
inputs[| 2].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
inputs[| 8].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny);
}
static step = function() { #region
inputs[| 1].mappableStep();
inputs[| 8].mappableStep();
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) {
@ -53,8 +66,10 @@ function Node_Zigzag(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_zigzag);
shader_set_f("dimension", _dim);
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[8], _data[7], inputs[| 8]);
shader_set_i("blend", _bnd);
shader_set_color("col1", _col1);
shader_set_color("col2", _col2);

View file

@ -145,7 +145,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
show_dimension : true,
show_compute : true,
avoid_label : true,
avoid_label : false,
preview_scale : 100,
highlight : false,
}

View file

@ -97,7 +97,7 @@ function graph_export_image(allList, nodeList, settings = {}) {
param.show_dimension = true;
param.show_compute = true;
param.avoid_label = true;
param.avoid_label = false;
param.preview_scale = 100;
for(var i = 0; i < ds_list_size(nodeList); i++)

View file

@ -1,14 +1,17 @@
function Panel_Test() : PanelContent() constructor {
w = ui(480);
h = ui(96);
h = ui(160);
title = "Tester";
test_dir = "D:\\Project\\MakhamDev\\LTS-PixelComposer\\TEST";
tb_test_dir = new textBox(TEXTBOX_INPUT.text, function(txt) { test_dir = txt; });
tb_test_dir = new textBox(TEXTBOX_INPUT.text, function(txt) { test_dir = txt; });
tb_index = new textBox(TEXTBOX_INPUT.number, function(txt) { start_index = txt; });
tb_amount = new textBox(TEXTBOX_INPUT.number, function(txt) { test_amount = txt; });
testing = false;
test_files = [];
start_index = 0;
test_amount = 100;
test_index = start_index;
test_button_surface = surface_create(1, 1);
@ -46,13 +49,15 @@ function Panel_Test() : PanelContent() constructor {
test_files = [];
scanDir(test_dir);
for( var i = start_index, n = array_length(test_files); i < n; i++ ) {
__start_time = get_timer();
for( var i = start_index, n = min(start_index + test_amount, array_length(test_files)); i < n; i++ ) {
run_in(1 + (i - start_index) * 3, function(i) {
try {
show_debug_message($"TESTING {i}/{array_length(test_files)}: {test_files[i]}");
TEST_PATH(test_files[i]);
test_index = i;
show_debug_message($" > Test complete");
show_debug_message($" > Test complete : {(get_timer() - __start_time) / 1_000_000} s");
} catch(e) {
show_debug_message($" > Test failed");
exception_print(e);
@ -67,12 +72,27 @@ function Panel_Test() : PanelContent() constructor {
var yy = 8;
var hh = TEXTBOX_HEIGHT;
tb_test_dir.setFocusHover(pFOCUS, pHOVER);
tb_index.setFocusHover(pFOCUS, pHOVER);
tb_amount.setFocusHover(pFOCUS, pHOVER);
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
draw_text(8, yy + hh / 2, "Directory");
tb_test_dir.setFocusHover(pFOCUS, pHOVER);
tb_test_dir.draw(128, yy, w - 8 - 128, hh, test_dir, [ mx, my ]);
yy += hh + 8;
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
draw_text(8, yy + hh / 2, "Start");
tb_index.draw(128, yy, w - 8 - 128, hh, start_index, [ mx, my ]);
yy += hh + 8;
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
draw_text(8, yy + hh / 2, "Amount");
tb_amount.draw(128, yy, w - 8 - 128, hh, test_amount, [ mx, my ]);
yy += hh + 8;
if(testing) {
var _w = (w - 16) * test_index / array_length(test_files);

View file

@ -49,7 +49,6 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
for(var i = 0; i < 4; i++) {
tb[i] = new textBox(TEXTBOX_INPUT.number, onModifySingle[i]);
tb[i].slidable = true;
tb[i].label = axis[i];
}
static setLinkInactiveColor = function(color) { #region
@ -95,7 +94,7 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
x = _x;
y = _y;
w = _w;
h = per_line? (_h + ui(8)) * size - ui(8) : _h;
h = per_line? (_h + ui(4)) * size - ui(4) : _h;
if(struct_has(_display_data, "linked")) linked = _display_data.linked;
if(struct_has(_display_data, "side_button")) side_button = _display_data.side_button;
@ -143,16 +142,19 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
var sz = min(size, array_length(_data));
var ww = per_line? _w : _w / sz;
draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, c_white, 1);
draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable);
if(!per_line) {
draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, c_white, 1);
draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable);
}
for(var i = 0; i < sz; i++) {
var bx = per_line? _x : _x + ww * i;
var by = per_line? _y + (_h + ui(8)) * i : _y;
var by = per_line? _y + (_h + ui(4)) * i : _y;
tb[i].setFocusHover(active, hover);
tb[i].hide = true;
tb[i].hide = !per_line;
tb[i].label = axis[i];
tb[i].draw(bx, by, ww, _h, _data[i], _m);
}

View file

@ -1,11 +1,11 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
#define PI 3.14159265359
uniform vec2 dimension;
uniform vec2 position;
uniform int blend;
uniform vec2 amount;
uniform int amountUseSurf;
@ -18,6 +18,19 @@ uniform sampler2D angleSurf;
uniform vec4 col1;
uniform vec4 col2;
float check(vec2 c, float amo, float ang) {
float _x = c.x * cos(ang) - c.y * sin(ang);
float _y = c.x * sin(ang) + c.y * cos(ang);
float _a = 1. / amo;
vec2 px = vec2(floor(_x / _a) + 0.5, floor(_y / _a) + 0.5) * _a;
float dd = 1. - (max(abs(px.x - _x), abs(px.y - _y)) / _a + 0.5);
float mm = mod(floor(_x / _a) + floor(_y / _a), 2.);
return mm < .5? 0.5 + dd : 0.5 - dd;
//return mod(floor(_x / _a) + floor(_y / _a), 2.);
}
void main() {
#region params
float amo = amount.x;
@ -34,14 +47,19 @@ void main() {
ang = radians(ang);
#endregion
vec2 dimension_norm = dimension / dimension.y;
vec2 c = (v_vTexcoord - position) * dimension_norm;
float _x = c.x * cos(ang) - c.y * sin(ang);
float _y = c.x * sin(ang) + c.y * cos(ang);
float _a = 1. / amo;
vec2 a = dimension / dimension.y;
vec2 c = (v_vTexcoord - position) * a;
if(mod(floor(_x / _a) + floor(_y / _a), 2.) > 0.5)
gl_FragColor = col1;
else
gl_FragColor = col2;
float ch = check(c, amo, ang);
if(blend == 0) gl_FragColor = ch < 0.5? col1 : col2;
else if(blend == 1) {
gl_FragColor = mix(col1, col2, ch);
} else if(blend == 2) {
float px = 2. / max(dimension.x, dimension.y);
ch = smoothstep(0.5 - px, 0.5 + px, ch);
gl_FragColor = mix(col1, col2, ch);
}
}

View file

@ -203,10 +203,16 @@ void main() { #region
float _s = (prog - ground) / (ceiling - ground);
if(gradient_use == 0) {
if(blend == 0) gl_FragColor = _s > rat? color0 : color1;
else {
if(blend == 0) gl_FragColor = _s > rat? color0 : color1;
else if(blend == 1) {
_s = sin(_s * 2. * PI) * 0.5 + 0.5;
gl_FragColor = mix(color0, color1, _s);
gl_FragColor = mix(color0, color1, _s);
} else if(blend == 2) {
float px = 3. / max(dimension.x, dimension.y);
_s = smoothstep(-px, px, sin(_s * 2. * PI));
gl_FragColor = mix(color0, color1, _s);
}
} else {
if(_s > rat) gl_FragColor = gradientEval(random(vec2(slot)));

View file

@ -1,27 +1,42 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 position;
uniform int blend;
uniform int blend;
uniform float rotation;
uniform vec2 amount;
uniform int amountUseSurf;
uniform sampler2D amountSurf;
uniform vec2 angle;
uniform int angleUseSurf;
uniform sampler2D angleSurf;
uniform vec4 col1, col2;
void main() {
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.);
}
#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.);
}
vec2 pos = v_vTexcoord - position;
float _cell = 1. / (amo * 2.);
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);
#endregion
vec2 pos = v_vTexcoord - position;
float _cell = 1. / (amo * 2.);
pos.y -= _cell / 2.;
pos *= mat2(cos(ang), -sin(ang), sin(ang), cos(ang));
float _xind = floor(pos.x / _cell);
float _yind = floor(pos.y / _cell);
@ -35,16 +50,21 @@ void main() {
if(mod(_xind, 2.) == 1.)
_x = 1. - _xcell;
float _h = _x > _y? _y + (1. - _x) : _y - _x;
float _ychi = _x > _y ? _yind + 1. : _yind;
if(mod(_ychi, 2.) == 1.) _h = 1. - _h;
if(blend == 0) {
if(mod(_yind, 2.) == 1.) {
if(_x > _y) gl_FragColor = col1;
else gl_FragColor = col2;
} else {
if(_x > _y) gl_FragColor = col2;
else gl_FragColor = col1;
}
} else {
if(_x > _y) gl_FragColor = mix(col1, col2, _y + (1. - _x));
else gl_FragColor = mix(col1, col2, _y - _x);
gl_FragColor = _h < 0.5? col1 : col2;
} else if(blend == 1) {
gl_FragColor = mix(col1, col2, _h);
} else if(blend == 2) {
float px = 1. / max(dimension.x, dimension.y);
_h = smoothstep(0.5 - px, 0.5 + px, _h);
gl_FragColor = mix(col1, col2, _h);
}
}