This commit is contained in:
luboslenco
2025-10-15 18:39:55 +02:00
parent 231fda884a
commit 5405d47fcf
242 changed files with 14647 additions and 15144 deletions
+47 -46
View File
@@ -1,19 +1,19 @@
let util_uv_uvmap: gpu_texture_t = null;
let util_uv_uvmap_cached: bool = false;
let util_uv_trianglemap: gpu_texture_t = null;
let util_uv_trianglemap_cached: bool = false;
let util_uv_dilatemap: gpu_texture_t = null;
let util_uv_dilatemap_cached: bool = false;
let util_uv_uvislandmap: gpu_texture_t = null;
let util_uv_uvislandmap_cached: bool = false;
let util_uv_dilate_bytes: buffer_t = null;
let util_uv_uvmap: gpu_texture_t = null;
let util_uv_uvmap_cached: bool = false;
let util_uv_trianglemap: gpu_texture_t = null;
let util_uv_trianglemap_cached: bool = false;
let util_uv_dilatemap: gpu_texture_t = null;
let util_uv_dilatemap_cached: bool = false;
let util_uv_uvislandmap: gpu_texture_t = null;
let util_uv_uvislandmap_cached: bool = false;
let util_uv_dilate_bytes: buffer_t = null;
let util_uv_pipe_dilate: gpu_pipeline_t = null;
function util_uv_cache_uv_map() {
if (util_uv_uvmap != null && (util_uv_uvmap.width != config_get_texture_res_x() || util_uv_uvmap.height != config_get_texture_res_y())) {
gpu_delete_texture(util_uv_uvmap);
util_uv_uvmap = null;
util_uv_uvmap = null;
util_uv_uvmap_cached = false;
}
@@ -27,22 +27,21 @@ function util_uv_cache_uv_map() {
util_uv_uvmap = gpu_create_render_target(res_x, res_y);
}
util_uv_uvmap_cached = true;
util_uv_uvmap_cached = true;
let merged: mesh_object_t = context_raw.merged_object;
let mesh: mesh_data_t = (context_raw.layer_filter == 0 && merged != null) ?
merged.data : context_raw.paint_object.data;
let mesh: mesh_data_t = (context_raw.layer_filter == 0 && merged != null) ? merged.data : context_raw.paint_object.data;
let texa: i16_array_t = mesh.vertex_arrays[2].values;
let inda: u32_array_t = mesh.index_array;
draw_begin(util_uv_uvmap, true, 0x00000000);
draw_set_color(0xffffffff);
let strength: f32 = res_x > 2048 ? 2.0 : 1.0;
let f: f32 = (1 / 32767) * util_uv_uvmap.width;
let f: f32 = (1 / 32767) * util_uv_uvmap.width;
for (let i: i32 = 0; i < math_floor(inda.length / 3); ++i) {
let x1: f32 = (texa[inda[i * 3 ] * 2 ]) * f;
let x2: f32 = (texa[inda[i * 3 + 1] * 2 ]) * f;
let x3: f32 = (texa[inda[i * 3 + 2] * 2 ]) * f;
let y1: f32 = (texa[inda[i * 3 ] * 2 + 1]) * f;
let x1: f32 = (texa[inda[i * 3] * 2]) * f;
let x2: f32 = (texa[inda[i * 3 + 1] * 2]) * f;
let x3: f32 = (texa[inda[i * 3 + 2] * 2]) * f;
let y1: f32 = (texa[inda[i * 3] * 2 + 1]) * f;
let y2: f32 = (texa[inda[i * 3 + 1] * 2 + 1]) * f;
let y3: f32 = (texa[inda[i * 3 + 2] * 2 + 1]) * f;
draw_line_aa(x1, y1, x2, y2, strength);
@@ -55,7 +54,7 @@ function util_uv_cache_uv_map() {
function util_uv_cache_triangle_map() {
if (util_uv_trianglemap != null && (util_uv_trianglemap.width != config_get_texture_res_x() || util_uv_trianglemap.height != config_get_texture_res_y())) {
gpu_delete_texture(util_uv_trianglemap);
util_uv_trianglemap = null;
util_uv_trianglemap = null;
util_uv_trianglemap_cached = false;
}
@@ -68,21 +67,22 @@ function util_uv_cache_triangle_map() {
}
util_uv_trianglemap_cached = true;
let merged: mesh_data_t = context_raw.merged_object != null ? context_raw.merged_object.data : context_raw.paint_object.data;
let mesh: mesh_data_t = merged;
let texa: i16_array_t = mesh.vertex_arrays[2].values;
let inda: u32_array_t = mesh.index_array;
let merged: mesh_data_t = context_raw.merged_object != null ? context_raw.merged_object.data : context_raw.paint_object.data;
let mesh: mesh_data_t = merged;
let texa: i16_array_t = mesh.vertex_arrays[2].values;
let inda: u32_array_t = mesh.index_array;
draw_begin(util_uv_trianglemap, true, 0xff000000);
let f: f32 = (1 / 32767) * util_uv_trianglemap.width;
let f: f32 = (1 / 32767) * util_uv_trianglemap.width;
let color: i32 = 0xff000001;
for (let i: i32 = 0; i < math_floor(inda.length / 3); ++i) {
if (color == 0xffffffff) color = 0xff000001;
if (color == 0xffffffff)
color = 0xff000001;
color++;
draw_set_color(color);
let x1: f32 = (texa[inda[i * 3 ] * 2 ]) * f;
let x2: f32 = (texa[inda[i * 3 + 1] * 2 ]) * f;
let x3: f32 = (texa[inda[i * 3 + 2] * 2 ]) * f;
let y1: f32 = (texa[inda[i * 3 ] * 2 + 1]) * f;
let x1: f32 = (texa[inda[i * 3] * 2]) * f;
let x2: f32 = (texa[inda[i * 3 + 1] * 2]) * f;
let x3: f32 = (texa[inda[i * 3 + 2] * 2]) * f;
let y1: f32 = (texa[inda[i * 3] * 2 + 1]) * f;
let y2: f32 = (texa[inda[i * 3 + 1] * 2 + 1]) * f;
let y3: f32 = (texa[inda[i * 3 + 2] * 2 + 1]) * f;
draw_filled_triangle(x1, y1, x2, y2, x3, y3);
@@ -93,27 +93,28 @@ function util_uv_cache_triangle_map() {
function util_uv_cache_dilate_map() {
if (util_uv_dilatemap != null && (util_uv_dilatemap.width != config_get_texture_res_x() || util_uv_dilatemap.height != config_get_texture_res_y())) {
gpu_delete_texture(util_uv_dilatemap);
util_uv_dilatemap = null;
util_uv_dilatemap = null;
util_uv_dilatemap_cached = false;
}
if (util_uv_dilatemap_cached) return;
if (util_uv_dilatemap_cached)
return;
if (util_uv_dilatemap == null) {
util_uv_dilatemap = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8);
}
if (util_uv_pipe_dilate == null) {
util_uv_pipe_dilate = gpu_create_pipeline();
util_uv_pipe_dilate.vertex_shader = sys_get_shader("dilate_map.vert");
util_uv_pipe_dilate = gpu_create_pipeline();
util_uv_pipe_dilate.vertex_shader = sys_get_shader("dilate_map.vert");
util_uv_pipe_dilate.fragment_shader = sys_get_shader("dilate_map.frag");
let vs: gpu_vertex_structure_t = {};
let vs: gpu_vertex_structure_t = {};
gpu_vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM);
gpu_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM);
gpu_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM);
util_uv_pipe_dilate.input_layout = vs;
util_uv_pipe_dilate.depth_write = false;
util_uv_pipe_dilate.depth_mode = compare_mode_t.ALWAYS;
util_uv_pipe_dilate.input_layout = vs;
util_uv_pipe_dilate.depth_write = false;
util_uv_pipe_dilate.depth_mode = compare_mode_t.ALWAYS;
ARRAY_ACCESS(util_uv_pipe_dilate.color_attachment, 0) = tex_format_t.R8;
gpu_pipeline_compile(util_uv_pipe_dilate);
// dilate_tex_unpack = getConstantLocation(pipeDilate, "tex_unpack");
@@ -131,7 +132,7 @@ function util_uv_cache_dilate_map() {
gpu_draw();
gpu_end();
util_uv_dilatemap_cached = true;
util_uv_dilate_bytes = null;
util_uv_dilate_bytes = null;
}
function _util_uv_check(cx: i32, cy: i32, w: i32, h: i32, r: i32, view: buffer_t, coords_x: i32[], coords_y: i32[]) {
@@ -165,14 +166,14 @@ function util_uv_cache_uv_island_map() {
util_uv_dilate_bytes = gpu_get_texture_pixels(util_uv_dilatemap);
}
util_render_pick_pos_nor_tex();
let w: i32 = 2048; // config_get_texture_res_x()
let h: i32 = 2048; // config_get_texture_res_y()
let x: i32 = math_floor(context_raw.uvx_picked * w);
let y: i32 = math_floor(context_raw.uvy_picked * h);
let w: i32 = 2048; // config_get_texture_res_x()
let h: i32 = 2048; // config_get_texture_res_y()
let x: i32 = math_floor(context_raw.uvx_picked * w);
let y: i32 = math_floor(context_raw.uvy_picked * h);
let bytes: buffer_t = buffer_create(w * h);
let coords_x: i32[] = [x];
let coords_y: i32[] = [y];
let r: i32 = math_floor(util_uv_dilatemap.width / w);
let coords_x: i32[] = [ x ];
let coords_y: i32[] = [ y ];
let r: i32 = math_floor(util_uv_dilatemap.width / w);
while (coords_x.length > 0) {
let cx: i32 = i32_array_pop(coords_x);
@@ -183,6 +184,6 @@ function util_uv_cache_uv_island_map() {
if (util_uv_uvislandmap != null) {
gpu_delete_texture(util_uv_uvislandmap);
}
util_uv_uvislandmap = gpu_create_texture_from_bytes(bytes, w, h, tex_format_t.R8);
util_uv_uvislandmap = gpu_create_texture_from_bytes(bytes, w, h, tex_format_t.R8);
util_uv_uvislandmap_cached = true;
}