This commit is contained in:
Tanasart 2024-10-24 17:40:14 +07:00
parent 15f47f2a37
commit cdc1ba7e58
916 changed files with 4256 additions and 2293 deletions

View file

@ -615,6 +615,9 @@
{"$GMIncludedFile":"","%Name":"CommonPS.hlsl","CopyToMask":-1,"filePath":"datafiles/Shaders/3dInstance","name":"CommonPS.hlsl","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"CommonVS.hlsl","CopyToMask":-1,"filePath":"datafiles/Shaders/3dInstance","name":"CommonVS.hlsl","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"rubber_duck_toy_1k.bin","CopyToMask":-1,"filePath":"datafiles/Shaders/3dInstance","name":"rubber_duck_toy_1k.bin","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"sampler_simple.glsl","CopyToMask":-1,"filePath":"datafiles/Shaders","name":"sampler_simple.glsl","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"sampler.glsl","CopyToMask":-1,"filePath":"datafiles/Shaders","name":"sampler.glsl","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"shader_replace.py","CopyToMask":-1,"filePath":"datafiles/Shaders","name":"shader_replace.py","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"snap_license.txt","CopyToMask":-1,"filePath":"datafiles","name":"snap_license.txt","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"ucrtbased.dll","ConfigValues":{},"CopyToMask":-1,"filePath":"datafiles","name":"ucrtbased.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"webpmux.exe","CopyToMask":-1,"filePath":"datafiles/webp","name":"webpmux.exe","resourceType":"GMIncludedFile","resourceVersion":"2.0",},

View file

@ -0,0 +1,86 @@
uniform int interpolation;
uniform vec2 sampleDimension;
uniform int sampleMode;
const float PI = 3.14159265358979323846;
float sinc ( float x ) { return x == 0.? 1. : sin(x * PI) / (x * PI); }
vec4 texture2D_bicubic( sampler2D texture, vec2 uv ) {
uv = uv * sampleDimension + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv);
uv = (uv - 0.5) / sampleDimension;
return texture2D( texture, uv );
}
const int RSIN_RADIUS = 1;
vec4 texture2D_rsin( sampler2D texture, vec2 uv ) {
vec2 tx = 1.0 / sampleDimension;
vec2 p = uv * sampleDimension;
vec4 col = vec4(0.);
float wei = 0.;
for (int x = -RSIN_RADIUS; x <= RSIN_RADIUS; x++)
for (int y = -RSIN_RADIUS; y <= RSIN_RADIUS; y++) {
vec2 sx = vec2(float(x), float(y));
float a = length(sx) / float(RSIN_RADIUS);
// if(a > 1.) continue;
vec4 sample = texture2D(texture, uv + sx * tx);
float w = sinc(a * PI * tx.x) * sinc(a * PI * tx.y);
col += w * sample;
wei += w;
}
col /= wei;
return col;
}
const int LANCZOS_RADIUS = 3;
float lanczosWeight(float d, float n) { return d == 0.0 ? 1.0 : (d * d < n * n ? sinc(d) * sinc(d / n) : 0.0); }
vec4 texture2D_lanczos3( sampler2D texture, vec2 uv ) {
vec2 center = uv - (mod(uv * sampleDimension, 1.0) - 0.5) / sampleDimension;
vec2 offset = (uv - center) * sampleDimension;
vec2 tx = 1. / sampleDimension;
vec4 col = vec4(0.);
float wei = 0.;
for(int x = -LANCZOS_RADIUS; x < LANCZOS_RADIUS; x++)
for(int y = -LANCZOS_RADIUS; y < LANCZOS_RADIUS; y++) {
float wx = lanczosWeight(float(x) - offset.x, float(LANCZOS_RADIUS));
float wy = lanczosWeight(float(y) - offset.y, float(LANCZOS_RADIUS));
float w = wx * wy;
col += w * texture2D(texture, center + vec2(x, y) * tx);
wei += w;
}
col /= wei;
return col;
}
vec4 texture2Dintp( sampler2D texture, vec2 uv ) {
if(interpolation <= 1) return texture2D( texture, uv );
else if(interpolation == 2) return texture2D_bicubic( texture, uv );
else if(interpolation == 3) return texture2D_lanczos3( texture, uv );
return texture2D( texture, uv );
}
vec4 sampleTexture( sampler2D texture, vec2 pos) {
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2Dintp(texture, pos);
if(sampleMode <= 1) return vec4(0.);
else if(sampleMode == 2) return texture2Dintp(texture, clamp(pos, 0., 1.));
else if(sampleMode == 3) return texture2Dintp(texture, fract(pos));
else if(sampleMode == 4) return vec4(vec3(0.), 1.);
return vec4(0.);
}

View file

@ -0,0 +1,13 @@
uniform int sampleMode;
vec4 sampleTexture( sampler2D texture, vec2 pos) {
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2D(texture, pos);
if(sampleMode <= 1) return vec4(0.);
else if(sampleMode == 2) return texture2D(texture, clamp(pos, 0., 1.));
else if(sampleMode == 3) return texture2D(texture, fract(pos));
else if(sampleMode == 4) return vec4(vec3(0.), 1.);
return vec4(0.);
}

View file

@ -0,0 +1,65 @@
import os
import re
lib = []
modified = 0
def replace_shader(shader_path):
with open(shader_path, 'r') as f:
shader = f.read()
edit = False
for lName, lCon, lModi in lib:
reg = f'\n#region -- {lName} --'
ereg = f'\n#endregion -- {lName} --\n'
if f'#pragma use({lName})' not in shader:
continue
if reg not in shader:
shader = f'#pragma use({lName})\n' + reg + f' [{lModi}]\n' + lCon + ereg + re.sub(fr'#pragma use\({lName}\)\n', '', shader)
edit = True
else:
modi = re.search(r'\[(.*)\]', shader.split(reg)[1]).group(0)
modi = float(modi[1:-1])
if modi != lModi:
pre_sh = shader.split(reg)[0]
post_sh = shader.split(ereg)[1]
shader = pre_sh + reg + f' [{lModi}]\n' + lCon + ereg + post_sh
edit = True
if edit:
with open(shader_path, 'w') as f:
f.write(shader)
global modified
modified += 1
######################################################################################################
gm_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))
for l in os.listdir(f'{gm_dir}/datafiles/Shaders'):
path = f'{gm_dir}/datafiles/Shaders/{l}'
if not os.path.isfile(path):
continue
name = l.split('.')[0]
ext = l.split('.')[1]
if ext != 'glsl':
continue
with open(path, 'r') as f:
modi = os.path.getmtime(path)
lib.append((name, f.read(), modi))
print(f' > Using library {name} ({modi})')
for sh in os.listdir(f'{gm_dir}/shaders'):
fsh = f'{gm_dir}/shaders/{sh}/{sh}.fsh'
replace_shader(fsh)
print(f'\nModified {modified} shaders')

1
pre_build_step.bat Normal file
View file

@ -0,0 +1 @@
py "%~dp0datafiles/Shaders/shader_replace.py"

View file

@ -2,9 +2,11 @@ enum AUTOTILE_TYPE {
box9,
side15,
top48,
top55,
}
function tiler_brush_autotile(_type, _index) constructor {
name = "autotile";
type = _type;
index = _index;
@ -13,22 +15,11 @@ function tiler_brush_autotile(_type, _index) constructor {
drawing_surface = noone;
target_surface = noone;
eraseMode = false;
bitmask = [];
switch(type) {
case AUTOTILE_TYPE.box9 :
// - 1 - | 0 1 2
// 2 x 4 | 3 4 5
// - 8 - | 6 7 8
bitmask = [ 4,
/* 1 */ 7,
/* 2 */ 5, 8,
/* 4 */ 3, 6, 4, 7,
/* 8 */ 1, 4, 2, 5, 0, 3, 1, 4,
];
break;
}
preview_surface = noone;
preview_surface_tile = noone;
open = false;
static drawing_start = function(surface, _erase = false) {
target_surface = surface;
@ -50,7 +41,7 @@ function tiler_brush_autotile(_type, _index) constructor {
static apply_drawing = function() {
var _dim = surface_get_dimension(target_surface);
mask_surface = surface_verify(mask_surface, _dim[0], _dim[1], surface_r8unorm);
update_surface = surface_verify(update_surface, _dim[0], _dim[1], surface_r16float);
update_surface = surface_verify(update_surface, _dim[0], _dim[1], surface_rgba16float);
// autotile mask
// #000000 : not part of autotile
@ -69,8 +60,6 @@ function tiler_brush_autotile(_type, _index) constructor {
shader_set_2("dimension", _dim);
shader_set_surface("maskSurface", mask_surface);
shader_set_i("bitmask", bitmask);
shader_set_i("bitmaskSize", array_length(bitmask));
shader_set_i("bitmaskType", type);
shader_set_i("indexes", index);

View file

@ -3,6 +3,7 @@ function tiler_brush(node) constructor {
brush_indices = [[]];
brush_width = 0;
brush_height = 0;
brush_varient = 0;
brush_surface = noone;
brush_erase = false;
autotiler = noone;
@ -54,14 +55,12 @@ function tiler_brush(node) constructor {
function tiler_draw_point_brush(brush, _x, _y, _shader = true) {
if(brush.brush_height * brush.brush_width == 0) return;
if(_shader) {
shader_set(sh_draw_tile_brush);
BLEND_OVERRIDE
}
if(_shader) { shader_set(sh_draw_tile_brush); BLEND_OVERRIDE }
for( var i = 0, n = brush.brush_height; i < n; i++ )
for( var j = 0, m = brush.brush_width; j < m; j++ ) {
shader_set_f("index", brush.brush_erase? -1 : brush.brush_indices[i][j]);
shader_set_f("index", brush.brush_erase? -1 : brush.brush_indices[i][j]);
shader_set_f("varient", brush.brush_erase? 0 : brush.brush_varient);
var _xx = _x + j;
var _yy = _y + i;
@ -77,23 +76,18 @@ function tiler_draw_point_brush(brush, _x, _y, _shader = true) {
}
}
if(_shader) {
BLEND_NORMAL
shader_reset();
}
if(_shader) { BLEND_NORMAL shader_reset(); }
}
function tiler_draw_line_brush(brush, _x0, _y0, _x1, _y1, _shader = true) {
if(brush.brush_height * brush.brush_width == 0) return;
if(_shader) {
shader_set(sh_draw_tile_brush);
BLEND_OVERRIDE
}
if(_shader) { shader_set(sh_draw_tile_brush); BLEND_OVERRIDE }
for( var i = 0, n = brush.brush_height; i < n; i++ )
for( var j = 0, m = brush.brush_width; j < m; j++ ) {
shader_set_f("index", brush.brush_erase? -1 : brush.brush_indices[i][j]);
shader_set_f("index", brush.brush_erase? -1 : brush.brush_indices[i][j]);
shader_set_f("varient", brush.brush_erase? 0 : brush.brush_varient);
var _xx0 = _x0 + j;
var _yy0 = _y0 + i;
@ -122,10 +116,7 @@ function tiler_draw_line_brush(brush, _x0, _y0, _x1, _y1, _shader = true) {
}
}
if(_shader) {
BLEND_NORMAL
shader_reset();
}
if(_shader) { BLEND_NORMAL shader_reset(); }
}
function tiler_draw_rect_brush(brush, _x0, _y0, _x1, _y1, _fill, _shader = true) {
@ -150,12 +141,19 @@ function tiler_draw_rect_brush(brush, _x0, _y0, _x1, _y1, _fill, _shader = true)
var _max_x = max(_x0, _x1);
var _min_y = min(_y0, _y1);
var _may_y = max(_y0, _y1);
if(_fill) {
if(_shader) { shader_set(sh_draw_tile_brush); BLEND_OVERRIDE shader_set_f("index", brush.brush_indices[0][0]); shader_set_f("varient", brush.brush_varient); }
draw_rectangle(_min_x, _min_y, _max_x, _may_y, 0);
if(_shader) { BLEND_NORMAL shader_reset(); }
}
if(_fill) draw_rectangle(_min_x, _min_y, _max_x, _may_y, 0);
if(brush.brush_size == 1 && !is_surface(brush.brush_surface))
if(brush.brush_size == 1) {
if(_shader) { shader_set(sh_draw_tile_brush); BLEND_OVERRIDE shader_set_f("index", brush.brush_indices[0][0]); shader_set_f("varient", brush.brush_varient); }
draw_rectangle(_min_x + 1, _min_y + 1, _max_x - 1, _may_y - 1, 1);
else {
if(_shader) { BLEND_NORMAL shader_reset(); }
} else {
tiler_draw_line_brush(brush, _min_x, _min_y, _max_x, _min_y, _shader);
tiler_draw_line_brush(brush, _min_x, _min_y, _min_x, _may_y, _shader);
tiler_draw_line_brush(brush, _max_x, _may_y, _max_x, _min_y, _shader);
@ -187,41 +185,22 @@ function tiler_draw_ellp_brush(brush, _x0, _y0, _x1, _y1, _fill, _shader = true)
var _min_y = min(_y0, _y1) - 0.5;
var _max_y = max(_y0, _y1) - 0.5;
if(!is_surface(brush.brush_surface)) {
if(_fill) draw_ellipse(_min_x, _min_y, _max_x, _max_y, 0);
if(brush.brush_size == 1) {
draw_ellipse(_min_x, _min_y, _max_x, _max_y, 1);
} else if(brush.brush_size < global.FIX_POINTS_AMOUNT) {
var fx = global.FIX_POINTS[brush.brush_size];
for( var i = 0, n = array_length(fx); i < n; i++ )
draw_ellipse(_min_x + fx[i][0], _min_y + fx[i][1], _max_x + fx[i][0], _max_y + fx[i][1], 1);
} else {
draw_ellipse(_min_x, _min_y, _max_x, _max_y, brush.brush_size);
}
return;
}
if(_shader) { shader_set(sh_draw_tile_brush); BLEND_OVERRIDE shader_set_f("index", brush.brush_indices[0][0]); shader_set_f("varient", brush.brush_varient); }
if(_fill) draw_ellipse(_min_x, _min_y, _max_x, _max_y, 0);
if(brush.brush_size == 1) {
draw_ellipse(_min_x, _min_y, _max_x, _max_y, 1);
var samp = 64;
var cx = (_min_x + _max_x) / 2;
var cy = (_min_y + _max_y) / 2;
var rx = abs(_x0 - _x1) / 2;
var ry = abs(_y0 - _y1) / 2;
var ox, oy, nx, ny;
for( var i = 0; i <= samp; i++ ) {
nx = round(cx + lengthdir_x(rx, 360 / samp * i));
ny = round(cy + lengthdir_y(ry, 360 / samp * i));
if(i) tiler_draw_line_brush(brush, ox, oy, nx, ny, _shader);
ox = nx;
oy = ny;
} else if(brush.brush_size < global.FIX_POINTS_AMOUNT) {
var fx = global.FIX_POINTS[brush.brush_size];
for( var i = 0, n = array_length(fx); i < n; i++ )
draw_ellipse(_min_x + fx[i][0], _min_y + fx[i][1], _max_x + fx[i][0], _max_y + fx[i][1], 1);
} else {
draw_ellipse(_min_x, _min_y, _max_x, _max_y, brush.brush_size);
}
if(_shader) { BLEND_NORMAL shader_reset(); }
}

View file

@ -42,7 +42,7 @@
LATEST_VERSION = 1_18_00_0;
VERSION = 1_18_01_0;
SAVE_VERSION = 1_18_02_0;
VERSION_STRING = MAC? "1.18.003m" : "1.18.3.002";
VERSION_STRING = MAC? "1.18.003m" : "1.18.3.003";
BUILD_NUMBER = 1_18_01_0;
HOTKEYS = ds_map_create();

View file

@ -4,7 +4,8 @@
new scrollItem("Pixel"),
new scrollItem("Bilinear"),
new scrollItem("Bicubic"),
new scrollItem("radSin"),
// new scrollItem("RadSin"),
new scrollItem("Lanczos3"),
];
global.SURFACE_OVERSAMPLE = [

View file

@ -43,7 +43,6 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
if(is_real(renaming))
inputs[renaming].setName(_name);
else if(is_struct(renaming) && is_instanceof(renaming, Node))
renaming.setDisplayName(_name)

View file

@ -2,6 +2,16 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
name = "Tile Drawer";
bypass_grid = true;
renaming = noone;
rename_text = "";
tb_rename = new textBox(TEXTBOX_INPUT.text, function(_name) {
if(renaming == noone) return;
renaming.name = _name;
renaming = noone;
});
tb_rename.font = f_p2;
tb_rename.hide = true;
newInput( 0, nodeValue_Surface("Tileset", self, noone));
newInput( 1, nodeValue_IVec2("Map size", self, [ 16, 16 ]));
@ -15,8 +25,8 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
tile_selector_x = 0;
tile_selector_y = 0;
tile_selector_s = 1;
tile_selector_s_to = 1;
tile_selector_s = 2;
tile_selector_s_to = 2;
tile_dragging = false;
tile_drag_sx = 0;
@ -24,6 +34,9 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
tile_drag_mx = 0;
tile_drag_my = 0;
selecting_surface = noone;
selecting_surface_tile = noone;
tile_selecting = false;
tile_select_ss = [ 0, 0 ];
@ -34,23 +47,21 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
tile_selector = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus, _panel = noone) {
var _h = tile_selector_h;
var _pd = ui(4);
var _tileSet = current_data[0];
var _tileSiz = current_data[2];
var _tileSet = array_safe_get(current_data, 0);
var _tileSiz = array_safe_get(current_data, 2);
var _sx = _x + _pd;
var _sy = _y + _pd;
var _sw = _w - _pd * 2;
var _sh = _h - _pd * 2;
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _y, _w, _h, c_white, 1);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _y, _w, _h, COLORS.node_composite_bg_blend, 1);
tile_selector_surface = surface_verify(tile_selector_surface, _sw, _sh);
tile_selector_mask = surface_verify(tile_selector_mask, _sw, _sh);
autotile_selector_mask = surface_verify(autotile_selector_mask, _sw, _sh);
if(!is_surface(_tileSet)) return _h;
var _tdim = surface_get_dimension(_tileSet);
var _tileAmo = [ floor(_tdim[0] / _tileSiz[0]), floor(_tdim[1] / _tileSiz[1]) ];
var _tileSel_w = _tileSiz[0] * tile_selector_s;
@ -61,16 +72,17 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
var _mtx = floor(_msx / tile_selector_s / _tileSiz[0]);
var _mty = floor(_msy / tile_selector_s / _tileSiz[1]);
var _mid = _mtx >= 0 && _mtx < _tileAmo[0] && _mty >= 0 && _mtx < _tileAmo[1]? _mty * _tileAmo[0] + _mtx : noone;
var _mid = _mtx >= 0 && _mtx < _tileAmo[0] && _mty >= 0 && _mty < _tileAmo[1]? _mty * _tileAmo[0] + _mtx : noone;
var _tileHov_x = tile_selector_x + _mtx * _tileSiz[0] * tile_selector_s;
var _tileHov_y = tile_selector_y + _mty * _tileSiz[1] * tile_selector_s;
var _hov = _hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h);
surface_set_target(tile_selector_surface);
draw_clear(COLORS.panel_bg_clear);
draw_sprite_tiled_ext(s_transparent, 0, tile_selector_x, tile_selector_y, tile_selector_s, tile_selector_s, COLORS.panel_preview_transparent, 1);
#region surface_set_target(tile_selector_surface);
surface_set_target(tile_selector_surface);
draw_clear(colorMultiply(COLORS.panel_bg_clear, COLORS.node_composite_bg_blend));
draw_sprite_tiled_ext(s_transparent, 0, tile_selector_x, tile_selector_y, tile_selector_s, tile_selector_s, colorMultiply(COLORS.panel_preview_transparent, COLORS.node_composite_bg_blend), 1);
draw_surface_ext(_tileSet, tile_selector_x, tile_selector_y, tile_selector_s, tile_selector_s, 0, c_white, 1);
@ -110,14 +122,25 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
draw_rectangle_width(_tileHov_x, _tileHov_y, _tileHov_x + _tileSel_w - 1, _tileHov_y + _tileSel_h - 1, 1);
if(_hov && _mid > noone && mouse_press(mb_left, _focus)) {
tile_selecting = true;
tile_select_ss = [ _mtx, _mty ];
if(autotile_subtile_selecting == noone) {
autotile_selecting = noone;
tile_selecting = true;
tile_select_ss = [ _mtx, _mty ];
} else {
autotiles[autotile_selecting].index[autotile_subtile_selecting] = _mid;
autotile_subtile_selecting++;
if(autotile_subtile_selecting >= array_length(autotiles[autotile_selecting].index))
autotile_subtile_selecting = noone;
}
}
surface_reset_target();
#endregion
#region surface_set_target(tile_selector_mask);
surface_set_target(tile_selector_mask);
DRAW_CLEAR
draw_set_color(c_white);
for( var i = 0, n = array_length(brush.brush_indices); i < n; i++ )
@ -130,6 +153,7 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
draw_rectangle(_tileSel_x, _tileSel_y, _tileSel_x + _tileSel_w, _tileSel_y + _tileSel_h, false);
}
surface_reset_target();
#endregion
#region tile selection
if(tile_selecting) {
@ -174,8 +198,10 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
}
var _s = tile_selector_s;
if(mouse_wheel_up()) { tile_selector_s_to = clamp(tile_selector_s_to * 1.2, 0.5, 4); }
if(mouse_wheel_down()) { tile_selector_s_to = clamp(tile_selector_s_to / 1.2, 0.5, 4); }
if(key_mod_press(CTRL)) {
if(mouse_wheel_up()) { tile_selector_s_to = clamp(tile_selector_s_to * 1.2, 0.5, 4); }
if(mouse_wheel_down()) { tile_selector_s_to = clamp(tile_selector_s_to / 1.2, 0.5, 4); }
}
tile_selector_s = lerp_float(tile_selector_s, tile_selector_s_to, 2);
if(_s != tile_selector_s) {
@ -202,37 +228,110 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
draw_surface(tile_selector_surface, _sx, _sy);
shader_set(sh_brush_outline);
var _brush_tiles = brush.brush_width * brush.brush_height;
var _cc = c_white;
if(_brush_tiles == 9 || _brush_tiles == 15 || _brush_tiles == 48 || _brush_tiles == 55) _cc = COLORS._main_value_positive;
shader_set_f("dimension", _sw, _sh);
draw_surface(tile_selector_mask, _sx, _sy);
draw_surface_ext(tile_selector_mask, _sx, _sy, 1, 1, 0, _cc, 1);
shader_reset();
#region autotile
if(autotile_selecting != noone) { // autotile
var _att = autotiles[autotile_selecting];
for( var i = 0, n = array_length(autotiles); i < n; i++ ) {
var _att = autotiles[i];
surface_set_target(autotile_selector_mask);
DRAW_CLEAR
draw_set_color(c_white);
for( var j = 0, m = array_length(_att.index); j < m; j++ ) {
var _bindex = _att.index[j];
var _tileSel_row = floor(_bindex / _tileAmo[0]);
var _tileSel_col = safe_mod(_bindex, _tileAmo[0]);
var _tileSel_x = tile_selector_x + _tileSel_col * _tileSiz[0] * tile_selector_s;
var _tileSel_y = tile_selector_y + _tileSel_row * _tileSiz[1] * tile_selector_s;
draw_rectangle(_tileSel_x, _tileSel_y, _tileSel_x + _tileSel_w, _tileSel_y + _tileSel_h, false);
}
surface_reset_target();
shader_set(sh_brush_outline);
shader_set_f("dimension", _sw, _sh);
draw_surface_ext(autotile_selector_mask, _sx, _sy, 1, 1, 0, COLORS._main_accent, 1);
shader_reset();
surface_set_target(autotile_selector_mask);
DRAW_CLEAR
draw_set_color(c_white);
for( var j = 0, m = array_length(_att.index); j < m; j++ ) {
var _bindex = _att.index[j];
var _tileSel_row = floor(_bindex / _tileAmo[0]);
var _tileSel_col = safe_mod(_bindex, _tileAmo[0]);
var _tileSel_x = tile_selector_x + _tileSel_col * _tileSiz[0] * tile_selector_s;
var _tileSel_y = tile_selector_y + _tileSel_row * _tileSiz[1] * tile_selector_s;
draw_rectangle(_tileSel_x, _tileSel_y, _tileSel_x + _tileSel_w, _tileSel_y + _tileSel_h, false);
}
surface_reset_target();
shader_set(sh_brush_outline);
shader_set_f("dimension", _sw, _sh);
draw_surface_ext(autotile_selector_mask, _sx, _sy, 1, 1, 0, COLORS._main_accent, 1);
shader_reset();
}
#region varients
var _bw = power(2, ceil(log2(brush.brush_width)));
var _bh = power(2, ceil(log2(brush.brush_height)));
var _sel_sw = brush.brush_width * _tileSiz[0];
var _sel_sh = brush.brush_height * _tileSiz[1];
selecting_surface = surface_verify(selecting_surface, _bw, _bh, surface_rgba16float);
selecting_surface_tile = surface_verify(selecting_surface_tile, _sel_sw, _sel_sh);
var _ty = _y + _h + ui(8);
var _th = ui(48);
_h += ui(8) + _th;
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _ty, _w, _th, COLORS.node_composite_bg_blend, 1);
var _sx = _x + ui(8);
var _variences = [ 0, 1, 2, 3, 8, 16 ];
if(brush.brush_width * brush.brush_height > 1) {
_variences = [ 0 ];
brush.brush_varient = 0;
}
#endregion
for( var v = 0, p = array_length(_variences); v < p; v++ ) {
surface_set_shader(selecting_surface, sh_draw_tile_brush, true, BLEND.over);
for( var i = 0, n = array_length(brush.brush_indices); i < n; i++ )
for( var j = 0, m = array_length(brush.brush_indices[i]); j < m; j++ ) {
var _bindex = brush.brush_indices[i][j];
shader_set_f("index", _bindex);
shader_set_f("varient", _variences[v]);
draw_point(j, i);
}
surface_reset_shader();
var _tileSetDim = surface_get_dimension(_tileSet);
surface_set_shader(selecting_surface_tile, sh_draw_tile_map, true, BLEND.over);
shader_set_2("dimension", [ _sel_sw, _sel_sh ]);
shader_set_2("tileSize", _tileSiz);
shader_set_2("tileAmo", [ floor(_tileSetDim[0] / _tileSiz[0]), floor(_tileSetDim[1] / _tileSiz[1]) ]);
shader_set_surface("tileTexture", _tileSet);
shader_set_2("tileTextureDim", _tileSetDim);
shader_set_surface("indexTexture", selecting_surface);
shader_set_2("indexTextureDim", surface_get_dimension(selecting_surface));
draw_empty();
surface_reset_shader();
var _sy = _ty + ui(8);
var _ss = (_th - ui(16)) / _sel_sh;
var _sw = _ss * _sel_sw;
var _sh = _ss * _sel_sh;
draw_surface_ext(selecting_surface_tile, _sx, _sy, _ss, _ss, 0, c_white, 1);
var _shov = _hover && point_in_rectangle(_m[0], _m[1], _sx, _sy, _sx + _sw, _sy + _sh);
var cc = _shov? COLORS._main_icon_light : COLORS._main_icon;
if(v == brush.brush_varient)
cc = COLORS._main_accent;
draw_set_color(cc);
draw_rectangle(_sx, _sy, _sx + _sw, _sy + _sh, true);
if(_shov && mouse_press(mb_left, _focus))
brush.brush_varient = brush.brush_varient == _variences[v]? 0 : _variences[v];
_sx += _sw + ui(8);
}
#endregion
return _h;
});
#endregion
@ -240,20 +339,257 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
#region ++++ auto tile ++++
autotiles = [];
autotile_selecting = 0;
autotile_selecting = noone;
autotile_selector_h = 0;
autotile_subtile_selecting = noone;
autotile_selector = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus, _panel = noone) {
var _hh = 0;
var _yy = _y;
var _h = 0;
var _tileSet = array_safe_get(current_data, 0);
var _tileSiz = array_safe_get(current_data, 2);
if(!is_surface(_tileSet)) return _h;
var _tdim = surface_get_dimension(_tileSet);
var _tileAmo = [ floor(_tdim[0] / _tileSiz[0]), floor(_tdim[1] / _tileSiz[1]) ];
var bx = _x;
var by = _yy;
var bs = ui(24);
var _brush_tiles = brush.brush_width * brush.brush_height;
var _fromSel = (_brush_tiles == 9 || _brush_tiles == 15 || _brush_tiles == 48 || _brush_tiles == 55);
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, _m, _focus, _hover, _fromSel? "New autotile from selection" : "New autotile", THEME.add_16, 0, COLORS._main_value_positive) == 2) {
var _new_at = noone;
if(_brush_tiles == 9) _new_at = new tiler_brush_autotile(AUTOTILE_TYPE.box9, array_spread(brush.brush_indices));
else if(_brush_tiles == 15) _new_at = new tiler_brush_autotile(AUTOTILE_TYPE.side15, array_spread(brush.brush_indices));
else if(_brush_tiles == 48) _new_at = new tiler_brush_autotile(AUTOTILE_TYPE.top48, array_spread(brush.brush_indices));
else if(_brush_tiles == 55) _new_at = new tiler_brush_autotile(AUTOTILE_TYPE.top55, array_spread(brush.brush_indices));
if(_new_at != noone) {
autotile_selecting = array_length(autotiles);
array_push(autotiles, _new_at);
brush.brush_indices = [[ _new_at.index[0] ]];
brush.brush_width = 1;
brush.brush_height = 1;
}
}
_h += bs + ui(8);
_yy += bs + ui(8);
var _pd = ui(4);
var _ah = _pd * 2;
var del = -1;
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _yy, _w, autotile_selector_h, COLORS.node_composite_bg_blend, 1);
_yy += _pd;
for( var i = 0, n = array_length(autotiles); i < n; i++ ) {
var _hg = ui(32);
var _at = autotiles[i];
var _pw = ui(24);
var _ph = ui(24);
var _px = _x + ui(8);
var _py = _yy + ui(4);
var _prin = array_safe_get(_at.index, 0, noone);
if(_prin == noone) {
draw_set_color(COLORS._main_icon);
draw_rectangle(_px, _py, _px + _pw, _py + _ph, true);
} else {
var _prc = safe_mod(_prin, _tileAmo[0]);
var _prr = floor(_prin / _tileAmo[0]);
var _pr_tx = _prc * _tileSiz[0];
var _pr_ty = _prr * _tileSiz[1];
var _pr_sx = _pw / _tileSiz[0];
var _pr_sy = _ph / _tileSiz[1];
draw_surface_part_ext(_tileSet, _pr_tx, _pr_ty, _tileSiz[0], _tileSiz[1], _px, _py, _pr_sx, _pr_sy, c_white, 1);
}
var _tx = _px + _pw + ui(8);
var _hov = _hover && point_in_rectangle(_m[0], _m[1], _x, _yy, _x + _w, _yy + _hg - 1);
var _cc = i == autotile_selecting? COLORS._main_accent : (_hov? COLORS._main_text : COLORS._main_text_sub);
if(renaming == _at) {
tb_rename.setFocusHover(_focus, _hover);
tb_rename.draw(_tx, _yy, _w - _pw - ui(8), _hg, rename_text, _m);
} else {
draw_set_text(f_p2, fa_left, fa_center, _cc);
draw_text_add(_tx, _yy + _hg / 2, _at.name);
var bs = ui(24);
var bx = _w - bs;
var by = _yy + _hg / 2 - bs / 2;
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, _m, _focus, _hover, "", THEME.minus_16, 0, _hov? COLORS._main_value_negative : COLORS._main_icon) == 2)
del = i;
}
if(_hov && _m[0] < _x + _w - ui(32)) {
if(DOUBLE_CLICK && _focus) {
renaming = _at;
rename_text = _at.name;
tb_rename._current_text = _at.name;
tb_rename.activate();
} else if(mouse_press(mb_left, _focus)) {
if(_m[0] > _tx) {
autotile_selecting = autotile_selecting == i? noone : i;
brush.brush_indices = [[ _prin ]];
brush.brush_width = 1;
brush.brush_height = 1;
} else {
_at.open = !_at.open;
}
}
}
_yy += _hg;
_ah += _hg;
if(_at.open) {
_yy += ui(4);
_ah += ui(4);
var _atIdx = _at.index;
var _coll = floor(_w - ui(16)) / _tileSiz[0];
switch(_at.type) {
case AUTOTILE_TYPE.box9 : _coll = 3; break;
case AUTOTILE_TYPE.side15 : _coll = 5; break;
case AUTOTILE_TYPE.top48 : _coll = 8; break;
case AUTOTILE_TYPE.top55 : _coll = 11; break;
}
var _roww = ceil(array_length(_atIdx) / _coll);
var _pre_sx = _x + ui(8);
var _pre_sy = _yy;
var _pre_sw = _coll * _tileSiz[0];
var _pre_sh = _roww * _tileSiz[1];
var _ss = (_w - ui(16)) / _pre_sw;
var _bw = power(2, ceil(log2(_coll)));
var _bh = power(2, ceil(log2(_roww)));
_at.preview_surface = surface_verify(_at.preview_surface, _bw, _bh, surface_rgba16float);
_at.preview_surface_tile = surface_verify(_at.preview_surface_tile, _pre_sw, _pre_sh);
surface_set_shader(_at.preview_surface, sh_draw_tile_brush, true, BLEND.over);
for( var j = 0, m = array_length(_atIdx); j < m; j++ ) {
var _til_row = floor(j / _coll);
var _til_col = j % _coll;
var _bindex = _atIdx[j];
shader_set_f("index", _bindex);
shader_set_f("varient", 0);
draw_point(_til_col, _til_row);
}
surface_reset_shader();
var _tileSetDim = surface_get_dimension(_tileSet);
surface_set_shader(_at.preview_surface_tile, sh_draw_tile_map, true, BLEND.over);
shader_set_2("dimension", surface_get_dimension(_at.preview_surface_tile));
shader_set_2("tileSize", _tileSiz);
shader_set_2("tileAmo", [ floor(_tileSetDim[0] / _tileSiz[0]), floor(_tileSetDim[1] / _tileSiz[1]) ]);
shader_set_surface("tileTexture", _tileSet);
shader_set_2("tileTextureDim", _tileSetDim);
shader_set_surface("indexTexture", _at.preview_surface);
shader_set_2("indexTextureDim", surface_get_dimension(_at.preview_surface));
draw_empty();
surface_reset_shader();
draw_surface_ext(_at.preview_surface_tile, _pre_sx, _pre_sy, _ss, _ss, 0, c_white, 1);
draw_set_color(COLORS._main_icon);
draw_rectangle(_pre_sx, _pre_sy, _pre_sx + _pre_sw * _ss, _pre_sy + _pre_sh * _ss, true);
var _dtile_w = _tileSiz[0] * _ss;
var _dtile_h = _tileSiz[1] * _ss;
if(_hover && point_in_rectangle(_m[0], _m[1], _pre_sx, _pre_sy, _pre_sx + _pre_sw * _ss, _pre_sy + _pre_sh * _ss)) {
var _at_cx = clamp(floor((_m[0] - _pre_sx) / _dtile_w), 0, _coll - 1);
var _at_cy = clamp(floor((_m[1] - _pre_sy) / _dtile_h), 0, _roww - 1);
var _at_id = _at_cy * _coll + _at_cx;
if(_at_id >= 0 && _at_id < array_length(_atIdx)) {
var _at_c_sx = _pre_sx + _at_cx * _dtile_w;
var _at_c_sy = _pre_sy + _at_cy * _dtile_h;
draw_set_color(COLORS._main_icon_light);
draw_rectangle(_at_c_sx, _at_c_sy, _at_c_sx + _dtile_w, _at_c_sy + _dtile_h, true);
if(mouse_press(mb_left, _focus)) {
autotile_selecting = i;
autotile_subtile_selecting = autotile_subtile_selecting == _at_id? noone : _at_id;
}
if(mouse_press(mb_right, _focus))
_at.index[_at_id] = -1;
}
}
if(autotile_selecting == i && autotile_subtile_selecting != noone) {
var _at_sl_x = autotile_subtile_selecting % _coll;
var _at_sl_y = floor(autotile_subtile_selecting / _coll);
var _at_c_sx = _pre_sx + _at_sl_x * _dtile_w;
var _at_c_sy = _pre_sy + _at_sl_y * _dtile_h;
draw_set_color(COLORS._main_accent);
draw_rectangle(_at_c_sx, _at_c_sy, _at_c_sx + _dtile_w, _at_c_sy + _dtile_h, true);
}
_yy += _pre_sh * _ss + ui(4);
_ah += _pre_sh * _ss + ui(4);
}
}
if(del != -1) {
array_delete(autotiles, del, 1);
autotile_selecting = noone;
}
autotile_selector_h = _ah;
return _h + _ah;
});
#endregion
#region ++++ brush palette ++++
brush_palette = surface_create(1, 1, surface_rgba16float);
palette_viewer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus, _panel = noone) {
var _h = 0;
return _hh;
return _h;
});
#endregion
input_display_list = [
["Tileset", false], 0, 2,
["Map", false], 1,
["Tiles", false], tile_selector,
["Autotiles",false], autotile_selector,
["Tileset", false], 0, 2,
["Map", false], 1,
["Tiles", false], tile_selector,
["Autotiles", false], autotile_selector,
["Palette", false], palette_viewer
]
newOutput(0, nodeValue_Output("Tile output", self, VALUE_TYPE.surface, noone));
@ -264,10 +600,10 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
.setArrayDepth(1);
#region ++++ data ++++
canvas_surface = surface_create_empty(1, 1, surface_r16float);
canvas_surface = surface_create_empty(1, 1, surface_rgba16float);
canvas_buffer = buffer_create(1 * 1 * 2, buffer_grow, 2);
drawing_surface = surface_create_empty(1, 1, surface_r16float);
drawing_surface = noone;
draw_stack = ds_list_create();
preview_drawing_tile = surface_create_empty(1, 1);
@ -325,11 +661,11 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
.setSetting(tool_size)
.setToolObject(tool_eraser),
new NodeTool( "Rectangle", [ THEME.canvas_tools_rect, THEME.canvas_tools_rect_fill ])
new NodeTool( "Rectangle", [ THEME.canvas_tools_rect_fill ])
.setSetting(tool_size)
.setToolObject(tool_rectangle),
new NodeTool( "Ellipse", [ THEME.canvas_tools_ellip, THEME.canvas_tools_ellip_fill ])
new NodeTool( "Ellipse", [ THEME.canvas_tools_ellip_fill ])
.setSetting(tool_size)
.setToolObject(tool_ellipse),
@ -340,7 +676,7 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
#endregion
function apply_draw_surface() {
if(!is_surface(canvas_surface)) return;
if(!is_surface(canvas_surface)) return;
if(!is_surface(drawing_surface)) return;
if(selecting) {
@ -358,14 +694,22 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
triggerRender();
}
function reset_surface(surface) {
surface_set_shader(surface, noone, true, BLEND.over);
draw_surface(canvas_surface, 0, 0);
surface_reset_shader();
}
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, params) {
var _tileSet = current_data[0];
var _mapSize = current_data[1];
var _tileSize = current_data[2];
if(!is_surface(drawing_surface)) {
drawing_surface = surface_verify(drawing_surface, _mapSize[0], _mapSize[1], surface_r16float);
canvas_surface = surface_verify(canvas_surface, _mapSize[0], _mapSize[1], surface_rgba16float);
if(!surface_valid(drawing_surface, _mapSize[0], _mapSize[1], surface_rgba16float)) {
drawing_surface = surface_verify(drawing_surface, _mapSize[0], _mapSize[1], surface_rgba16float);
surface_set_shader(drawing_surface, noone, true, BLEND.over);
draw_surface(canvas_surface, 0, 0);
surface_reset_shader();
@ -375,7 +719,7 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
var _dim = attributes.dimension;
var _outDim = [ _tileSize[0] * _dim[0], _tileSize[1] * _dim[1] ];
preview_draw_overlay = surface_verify(preview_draw_overlay, _dim[0], _dim[1], surface_r16float);
preview_draw_overlay = surface_verify(preview_draw_overlay, _dim[0], _dim[1], surface_rgba16float);
preview_drawing_tile = surface_verify(preview_drawing_tile, _dim[0] * _tileSize[0], _dim[1] * _tileSize[1]);
preview_draw_overlay_tile = surface_verify(preview_draw_overlay_tile, _dim[0] * _tileSize[0], _dim[1] * _tileSize[1]);
@ -393,7 +737,7 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
var _tool = _currTool == noone? noone : _currTool.getToolObject();
brush.brush_size = tool_attribute.size;
brush.autotiler = autotile_selecting == noone? noone : autotiles[autotile_selecting];
brush.autotiler = autotile_selecting == noone? noone : array_safe_get(autotiles, autotile_selecting, noone);
if(_tool) {
_tool.subtool = _currTool.selecting;
@ -477,7 +821,10 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
#endregion
if(autotiles[0].mask_surface) draw_surface_ext(autotiles[0].mask_surface, 32, 32, 8, 8, 0, c_white, 1);
//if(!array_empty(autotiles)) draw_surface_ext(autotiles[0].mask_surface, 32, 32, 8, 8, 0, c_white, 1);
// draw_surface_ext(canvas_surface, 32, 32, 8, 8, 0, c_white, 1);
// draw_surface_ext(drawing_surface, 232, 32, 8, 8, 0, c_white, 1);
// draw_surface_ext(preview_draw_overlay, 432, 32, 8, 8, 0, c_white, 1);
}
static processData = function(_outData, _data, _output_index, _array_index) {
@ -488,12 +835,14 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
attributes.dimension[0] = _mapSize[0];
attributes.dimension[1] = _mapSize[1];
//print($"{canvas_surface} [{is_surface(canvas_surface)}] : {drawing_surface} [{is_surface(drawing_surface)}]");
if(!is_surface(canvas_surface) && buffer_exists(canvas_buffer)) {
canvas_surface = surface_create(_mapSize[0], _mapSize[1], surface_r16float);
canvas_surface = surface_create(_mapSize[0], _mapSize[1], surface_rgba16float);
buffer_set_surface(canvas_buffer, canvas_surface, 0);
} else
canvas_surface = surface_verify(canvas_surface, _mapSize[0], _mapSize[1], surface_r16float);
drawing_surface = surface_verify(drawing_surface, _mapSize[0], _mapSize[1], surface_r16float);
canvas_surface = surface_verify(canvas_surface, _mapSize[0], _mapSize[1], surface_rgba16float);
drawing_surface = surface_verify(drawing_surface, _mapSize[0], _mapSize[1], surface_rgba16float);
surface_set_shader(drawing_surface, noone, true, BLEND.over);
draw_surface(canvas_surface, 0, 0);
@ -508,7 +857,7 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
var _outDim = [ _tileSize[0] * _mapSize[0], _tileSize[1] * _mapSize[1] ];
_tileOut = surface_verify(_tileOut, _outDim[0], _outDim[1]);
_tileMap = surface_verify(_tileMap, _mapSize[0], _mapSize[1], surface_r16float);
_tileMap = surface_verify(_tileMap, _mapSize[0], _mapSize[1], surface_rgba16float);
_arrIndx = array_verify(_arrIndx, _mapSize[0] * _mapSize[1]);
buffer_resize(canvas_buffer, _mapSize[0] * _mapSize[1] * 2);
@ -548,11 +897,41 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
static doApplyDeserialize = function() {
canvas_buffer = buffer_deserialize(load_map.surface);
canvas_surface = surface_verify(canvas_surface, attributes.dimension[0], attributes.dimension[1], surface_r16float);
drawing_surface = surface_verify(drawing_surface, attributes.dimension[0], attributes.dimension[1], surface_r16float);
canvas_surface = surface_verify(canvas_surface, attributes.dimension[0], attributes.dimension[1], surface_rgba16float);
drawing_surface = surface_verify(drawing_surface, attributes.dimension[0], attributes.dimension[1], surface_rgba16float);
buffer_set_surface(canvas_buffer, canvas_surface, 0);
buffer_set_surface(canvas_buffer, drawing_surface, 0);
}
static attributeSerialize = function() {
var _attr = {
autotiles,
canvas: buffer_from_surface(canvas_surface),
palette: buffer_from_surface(brush_palette),
};
return _attr;
}
static attributeDeserialize = function(attr) {
var _auto = struct_try_get(attr, "autotiles", []);
var _canv = struct_try_get(attr, "canvas", noone);
var _palt = struct_try_get(attr, "palette", noone);
for( var i = 0, n = array_length(_auto); i < n; i++ ) {
autotiles[i] = new tiler_brush_autotile(_auto[i].type, _auto[i].index);
autotiles[i].name = _auto[i].name;
}
if(_canv) {
surface_free_safe(canvas_surface);
canvas_surface = surface_from_buffer(_canv);
}
if(_palt) {
surface_free_safe(brush_palette);
brush_palette = surface_from_buffer(_canv);
}
}
}

View file

@ -209,6 +209,7 @@ function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount",
var intp = getAttribute("interpolate");
gpu_set_tex_filter(bool(intp));
shader_set_i("interpolation", intp);
shader_set_f("sampleDimension", _dim == noone? surface_get_dimension(surface) : _dim);
shader_set_i("sampleMode", getAttribute("oversample"));

View file

@ -15,6 +15,8 @@ function tiler_tool_shape(node, _brush, _shape) : tiler_tool(node) constructor {
mouse_cur_x = floor(round((_mx - _x) / _s - 0.5) / tile_size[0]);
mouse_cur_y = floor(round((_my - _y) / _s - 0.5) / tile_size[1]);
var _auto = brush.autotiler;
if(mouse_holding && key_mod_press(SHIFT)) {
var ww = mouse_cur_x - mouse_pre_x;
var hh = mouse_cur_y - mouse_pre_y;
@ -26,16 +28,26 @@ function tiler_tool_shape(node, _brush, _shape) : tiler_tool(node) constructor {
if(mouse_holding) {
surface_set_shader(drawing_surface, noone);
node.reset_surface(drawing_surface);
surface_set_target(drawing_surface);
switch(shape) {
case CANVAS_TOOL_SHAPE.rectangle : tiler_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
case CANVAS_TOOL_SHAPE.ellipse : tiler_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
case CANVAS_TOOL_SHAPE.rectangle : tiler_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, true); break;
case CANVAS_TOOL_SHAPE.ellipse : tiler_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, true); break;
}
surface_reset_shader();
surface_reset_target();
if(_auto != noone) {
_auto.drawing_start(drawing_surface, false);
switch(shape) {
case CANVAS_TOOL_SHAPE.rectangle : tiler_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, true); break;
case CANVAS_TOOL_SHAPE.ellipse : tiler_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, true); break;
}
_auto.drawing_end();
}
if(mouse_release(mb_left)) {
apply_draw_surface();
mouse_holding = false;
apply_draw_surface();
}
} else if(mouse_press(mb_left, active)) {
@ -43,8 +55,6 @@ function tiler_tool_shape(node, _brush, _shape) : tiler_tool(node) constructor {
mouse_pre_y = mouse_cur_y;
mouse_holding = true;
node.tool_pick_color(mouse_cur_x, mouse_cur_y);
}
}
@ -57,8 +67,8 @@ function tiler_tool_shape(node, _brush, _shape) : tiler_tool(node) constructor {
}
switch(shape) {
case CANVAS_TOOL_SHAPE.rectangle : tiler_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
case CANVAS_TOOL_SHAPE.ellipse : tiler_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
case CANVAS_TOOL_SHAPE.rectangle : tiler_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, true); break;
case CANVAS_TOOL_SHAPE.ellipse : tiler_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, true); break;
}
}

View file

@ -15,17 +15,25 @@ function tiler_tool_fill(node, _brush, toolAttr) : tiler_tool(node) constructor
surface_w = surface_get_width(drawing_surface);
surface_h = surface_get_height(drawing_surface);
var _auto = brush.autotiler;
if(mouse_press(mb_left, active) && point_in_rectangle(mouse_cur_x, mouse_cur_y, 0, 0, surface_w - 1, surface_h - 1)) {
surface_set_target(drawing_surface);
tiler_flood_fill_scanline(drawing_surface, mouse_cur_x, mouse_cur_y, brush, tool_attribute.fillType);
surface_reset_target();
if(_auto != noone) {
_auto.drawing_start(drawing_surface, isEraser);
tiler_flood_fill_scanline(drawing_surface, mouse_cur_x, mouse_cur_y, brush, tool_attribute.fillType);
_auto.drawing_end();
}
apply_draw_surface();
}
}
}
function _tiler_ff_getPixel(_x, _y) { return round(buffer_read_at(_ff_buff, (_y * _ff_w + _x) * 2, buffer_f16)); }
function _tiler_ff_getPixel(_x, _y) { return round(buffer_read_at(_ff_buff, (_y * _ff_w + _x) * 8, buffer_f16)); }
function tiler_flood_fill_scanline(_surf, _x, _y, brush, _corner = false) {
if(brush.brush_height * brush.brush_width == 0) return;
@ -38,7 +46,7 @@ function tiler_flood_fill_scanline(_surf, _x, _y, brush, _corner = false) {
_ff_w = surface_get_width(_surf);
_ff_h = surface_get_height(_surf);
_ff_buff = buffer_create(_ff_w * _ff_h * 2, buffer_fixed, 2);
_ff_buff = buffer_create(_ff_w * _ff_h * 8, buffer_fixed, 2);
buffer_get_surface(_ff_buff, _surf, 0);
var x1, y1, x_start;
@ -71,7 +79,7 @@ function tiler_flood_fill_scanline(_surf, _x, _y, brush, _corner = false) {
while(x1 < surface_w && colorBase == _tiler_ff_getPixel(x1, y1)) {
draw_point(x1, y1);
buffer_write_at(_ff_buff, (y1 * _ff_w + x1) * 2, buffer_f16, _index);
buffer_write_at(_ff_buff, (y1 * _ff_w + x1) * 8, buffer_f16, _index);
// print($"----Filling {x1}, {y1}")

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6162882+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6164724+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6169090+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6171249+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6175486+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6177304+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6190716+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6192756+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6181936+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6186239+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6295656+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6297549+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.7597385+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.7599121+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.7603465+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.7605191+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.7656699+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.7658435+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6198590+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6200728+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6205921+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6208149+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6212598+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6214409+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6227715+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6229475+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6241814+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6243651+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6247948+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6249712+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6259961+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6261855+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6254036+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6255755+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6266469+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6268137+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6272573+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6274145+07:00

View file

@ -1,3 +1,21 @@
#pragma use(sampler_simple)
#region -- sampler_simple -- [1729740692.1417658]
uniform int sampleMode;
vec4 sampleTexture( sampler2D texture, vec2 pos) {
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2D(texture, pos);
if(sampleMode <= 1) return vec4(0.);
else if(sampleMode == 2) return texture2D(texture, clamp(pos, 0., 1.));
else if(sampleMode == 3) return texture2D(texture, fract(pos));
else if(sampleMode == 4) return vec4(vec3(0.), 1.);
return vec4(0.);
}
#endregion -- sampler_simple --
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
@ -7,7 +25,6 @@ uniform vec2 dimension;
uniform vec2 scale;
uniform vec2 shift;
uniform int slope;
uniform int sampleMode;
uniform vec2 height;
uniform int heightUseSurf;
@ -15,25 +32,6 @@ uniform sampler2D heightSurf;
float bright(in vec4 col) { return (col.r + col.g + col.b) / 3. * col.a; }
vec4 sampleTexture(vec2 pos) { #region
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2D(gm_BaseTexture, pos);
if(sampleMode == 0)
return vec4(0.);
else if(sampleMode == 1)
return texture2D(gm_BaseTexture, clamp(pos, 0., 1.));
else if(sampleMode == 2)
return texture2D(gm_BaseTexture, fract(pos));
else if(sampleMode == 3)
return vec4(vec3(0.), 1.);
return vec4(0.);
} #endregion
void main() {
float hei = height.x;
float heiMax = max(height.x, height.y);
@ -81,7 +79,7 @@ void main() {
shf = vec2( cos(ang), sin(ang)) * (i * added_distance) / scale;
pxs = v_vTexcoord + shf * pixelStep;
col1 = sampleTexture( pxs );
col1 = sampleTexture( gm_BaseTexture, pxs );
_b1 = bright(col1);
if(_b1 < b1) {

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6287892+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6289682+07:00

View file

@ -1,3 +1,21 @@
#pragma use(sampler_simple)
#region -- sampler_simple -- [1729740692.1417658]
uniform int sampleMode;
vec4 sampleTexture( sampler2D texture, vec2 pos) {
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2D(texture, pos);
if(sampleMode <= 1) return vec4(0.);
else if(sampleMode == 2) return texture2D(texture, clamp(pos, 0., 1.));
else if(sampleMode == 3) return texture2D(texture, fract(pos));
else if(sampleMode == 4) return vec4(vec3(0.), 1.);
return vec4(0.);
}
#endregion -- sampler_simple --
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
@ -7,7 +25,6 @@ uniform vec2 dimension;
uniform vec2 scale;
uniform vec2 shift;
uniform int slope;
uniform int sampleMode;
uniform vec2 height;
uniform int heightUseSurf;
@ -15,25 +32,6 @@ uniform sampler2D heightSurf;
float bright(in vec4 col) { return (col.r + col.g + col.b) / 3. * col.a; }
vec4 sampleTexture(vec2 pos) { #region
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2D(gm_BaseTexture, pos);
if(sampleMode == 0)
return vec4(0.);
else if(sampleMode == 1)
return texture2D(gm_BaseTexture, clamp(pos, 0., 1.));
else if(sampleMode == 2)
return texture2D(gm_BaseTexture, fract(pos));
else if(sampleMode == 3)
return vec4(vec3(0.), 1.);
return vec4(0.);
} #endregion
void main() {
float hei = height.x;
float heiMax = max(height.x, height.y);
@ -81,7 +79,7 @@ void main() {
shf = vec2( cos(ang), sin(ang)) * (i * added_distance) / scale;
pxs = v_vTexcoord + shf * pixelStep;
col1 = sampleTexture( pxs );
col1 = sampleTexture( gm_BaseTexture, pxs );
_b1 = bright(col1);
if(_b1 < b1) {

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6278334+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6280208+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6311851+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6313489+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6302004+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6303803+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6322810+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6324546+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6329414+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6331211+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6335747+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6337646+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6342036+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6344134+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6352504+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6354844+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6365260+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6367075+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6384264+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6386075+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6371368+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6373006+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6377496+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6379252+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6390975+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6392924+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6397609+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6399628+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6404039+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6405813+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6410000+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6411994+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6416873+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6419096+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6423720+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6425497+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6429622+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6431481+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6439390+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6441087+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6455113+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6456782+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6464658+07:00

View file

@ -0,0 +1 @@
// Date: 2024-10-15T09:38:04.6466477+07:00

Some files were not shown because too many files have changed in this diff Show more