From 85bcbdb7bb4775509259ca67bf9fcf87c93fe5b0 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Wed, 23 Oct 2024 14:00:19 +0200 Subject: [PATCH] Lab fixes --- armorlab/sources/make_material.ts | 16 ++++++++-------- armorlab/sources/nodes/inpaint_node.ts | 6 +++--- armorlab/sources/nodes/text_to_photo_node.ts | 4 ++-- armorlab/sources/nodes/tiling_node.ts | 2 +- armorlab/sources/nodes/upscale_node.ts | 2 +- armorlab/sources/nodes/variance_node.ts | 2 +- armorlab/sources/render_path_paint.ts | 7 ++++++- armorlab/sources/ui_nodes_ext.ts | 3 +-- base/sources/ui_base.ts | 3 ++- 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/armorlab/sources/make_material.ts b/armorlab/sources/make_material.ts index bf9ae914..737bb03b 100644 --- a/armorlab/sources/make_material.ts +++ b/armorlab/sources/make_material.ts @@ -24,15 +24,15 @@ function make_material_parse_mesh_material() { let con: node_shader_context_t = make_mesh_run(mm); let scon: shader_context_t = shader_context_create(con.data); let override_context: _shader_override_t = {}; - scon._.override_context = override_context; - if (con.frag.shared_samplers.length > 0) { - let sampler: string = con.frag.shared_samplers[0]; - scon._.override_context.shared_sampler = substring(sampler, string_last_index_of(sampler, " ") + 1, sampler.length); - } + // if (con.frag.shared_samplers.length > 0) { + // let sampler: string = con.frag.shared_samplers[0]; + // override_context.shared_sampler = substring(sampler, string_last_index_of(sampler, " ") + 1, sampler.length); + // } if (!context_raw.texture_filter) { - scon._.override_context.filter = "point"; + override_context.filter = "point"; } - scon._.override_context.addressing = "repeat"; + override_context.addressing = "repeat"; + scon._.override_context = override_context; array_push(m._.shader.contexts, scon); array_push(m._.shader._.contexts, scon); @@ -105,8 +105,8 @@ function make_material_parse_paint_material() { } let override_context: _shader_override_t = {}; + override_context.addressing = "repeat"; scon2._.override_context = override_context; - scon2._.override_context.addressing = "repeat"; let mcon3: material_context_t = material_context_create(mcon2); array_push(m._.shader.contexts, scon2); diff --git a/armorlab/sources/nodes/inpaint_node.ts b/armorlab/sources/nodes/inpaint_node.ts index 42fb0c9a..1f153545 100644 --- a/armorlab/sources/nodes/inpaint_node.ts +++ b/armorlab/sources/nodes/inpaint_node.ts @@ -51,7 +51,7 @@ function inpaint_node_init() { function inpaint_node_button(node_id: i32) { let node: ui_node_t = ui_get_node(ui_nodes_get_canvas(true).nodes, node_id); - inpaint_node_auto = node.buttons[0].default_value == 0 ? false : true; + inpaint_node_auto = node.buttons[0].default_value[0] == 0 ? false : true; if (!inpaint_node_auto) { let inpaint_node_strength_handle: ui_handle_t = ui_handle(__ID__); @@ -127,7 +127,7 @@ function inpaint_node_sd_inpaint(image: image_t, mask: image_t): image_t { inpaint_node_init(); let bytes_img: buffer_t = image_get_pixels(mask); - let u8: buffer_t = bytes_img; + let u8_img: buffer_t = bytes_img; let f32mask: f32_array_t = f32_array_create(4 * 64 * 64); let vae_encoder_blob: buffer_t = data_get_blob("models/sd_vae_encoder.quant.onnx"); @@ -142,7 +142,7 @@ function inpaint_node_sd_inpaint(image: image_t, mask: image_t): image_t { // let j = (yy * step * mask.width + xx * step) + (y * 512 * mask.width + x * 512); let step: i32 = math_floor(mask.width / 64); let j: i32 = (yy * step * mask.width + xx * step); - let f: f32 = u8[j] / 255.0; + let f: f32 = u8_img[j] / 255.0; let i: i32 = yy * 64 + xx; f32mask[i ] = f; f32mask[i + 64 * 64 ] = f; diff --git a/armorlab/sources/nodes/text_to_photo_node.ts b/armorlab/sources/nodes/text_to_photo_node.ts index ff076b0a..16cf966c 100644 --- a/armorlab/sources/nodes/text_to_photo_node.ts +++ b/armorlab/sources/nodes/text_to_photo_node.ts @@ -30,7 +30,7 @@ function text_to_photo_node_get_cached_image(self: text_to_photo_node_t): image_ function text_to_photo_node_button(node_id: i32) { let node: ui_node_t = ui_get_node(ui_nodes_get_canvas(true).nodes, node_id); - text_to_photo_node_tiling = node.buttons[0].default_value == 0 ? false : true; + text_to_photo_node_tiling = node.buttons[0].default_value[0] == 0 ? false : true; text_to_photo_node_prompt = ui_text_area(ui_handle(__ID__), ui_align_t.LEFT, true, tr("prompt"), true); node.buttons[1].height = string_split(text_to_photo_node_prompt, "\n").length; } @@ -249,7 +249,7 @@ function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): im latents[i] = 1.0 / 0.18215 * latents[i]; } - let tensors: buffer_t[] = [buffer_create_from_raw(latents.buffer, latents.length)]; + let tensors: buffer_t[] = [buffer_create_from_raw(latents.buffer, latents.length * 4)]; let input_shape: i32_array_t[] = []; let input_shape0: i32[] = [1, 4, 64, 64]; array_push(input_shape, input_shape0); diff --git a/armorlab/sources/nodes/tiling_node.ts b/armorlab/sources/nodes/tiling_node.ts index 07eaaba7..329b3291 100644 --- a/armorlab/sources/nodes/tiling_node.ts +++ b/armorlab/sources/nodes/tiling_node.ts @@ -27,7 +27,7 @@ function tiling_node_init() { function tiling_node_button(node_id: i32) { let node: ui_node_t = ui_get_node(ui_nodes_get_canvas(true).nodes, node_id); - tiling_node_auto = node.buttons[0].default_value == 0 ? false : true; + tiling_node_auto = node.buttons[0].default_value[0] == 0 ? false : true; if (!tiling_node_auto) { let tiling_node_strength_handle: ui_handle_t = ui_handle(__ID__); if (tiling_node_strength_handle.init) { diff --git a/armorlab/sources/nodes/upscale_node.ts b/armorlab/sources/nodes/upscale_node.ts index 3a75601f..477cd74a 100644 --- a/armorlab/sources/nodes/upscale_node.ts +++ b/armorlab/sources/nodes/upscale_node.ts @@ -64,7 +64,7 @@ function upscale_node_do_tile(source: image_t): image_t { f32a[i + size1w * size1w * 2] = (u8a[i * 4 + 2] / 255); } - let tensors: buffer_t[] = [buffer_create_from_raw(f32a.buffer, f32a.length)]; + let tensors: buffer_t[] = [buffer_create_from_raw(f32a.buffer, f32a.length * 4)]; let input_shape: i32_array_t[] = []; let input_shape0: i32[] = [1, 3, size1w, size1h]; array_push(input_shape, input_shape0); diff --git a/armorlab/sources/nodes/variance_node.ts b/armorlab/sources/nodes/variance_node.ts index 3102b8ba..32a3f837 100644 --- a/armorlab/sources/nodes/variance_node.ts +++ b/armorlab/sources/nodes/variance_node.ts @@ -55,7 +55,7 @@ function variance_node_get_as_image(self: variance_node_t, from: i32): image_t { iron_g4_swap_buffers(); let vae_encoder_blob: buffer_t = data_get_blob("models/sd_vae_encoder.quant.onnx"); - let tensors: buffer_t[] = [buffer_create_from_raw(f32a.buffer, f32a.length)]; + let tensors: buffer_t[] = [buffer_create_from_raw(f32a.buffer, f32a.length * 4)]; let input_shape: i32_array_t[] = []; let input_shape0: i32[] = [1, 3, 512, 512]; array_push(input_shape, input_shape0); diff --git a/armorlab/sources/render_path_paint.ts b/armorlab/sources/render_path_paint.ts index 851e1407..b923830a 100644 --- a/armorlab/sources/render_path_paint.ts +++ b/armorlab/sources/render_path_paint.ts @@ -205,7 +205,12 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 help_mat = mat4_inv(scene_camera.vp); g4_set_mat(base_cursor_inv_vp, help_mat); ///if (arm_metal || arm_vulkan) - let vs: vertex_structure_t[] = [{ name: "tex", data: "short2norm" }]; + let vs: vertex_element_t[] = [ + { + name: "tex", + data: "short2norm" + } + ]; g4_set_vertex_buffer(mesh_data_get(geom, vs)); ///else g4_set_vertex_buffer(geom._.vertex_buffer); diff --git a/armorlab/sources/ui_nodes_ext.ts b/armorlab/sources/ui_nodes_ext.ts index 9096050e..8220b34e 100644 --- a/armorlab/sources/ui_nodes_ext.ts +++ b/armorlab/sources/ui_nodes_ext.ts @@ -75,8 +75,7 @@ function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { g4_draw(); g4_end(); - let is_float_node: bool = true; - // brush_output_node_inst.base.inputs[channel_type_t.HEIGHT].node.get != float_node_get + let is_float_node: bool = brush_output_node_inst.base.inputs[channel_type_t.HEIGHT].node.base.get == float_node_get; if (ui_header_worktab.position == space_type_t.SPACE3D && !is_float_node) { diff --git a/base/sources/ui_base.ts b/base/sources/ui_base.ts index e70a6ff9..810b54a2 100644 --- a/base/sources/ui_base.ts +++ b/base/sources/ui_base.ts @@ -823,7 +823,8 @@ function ui_base_update() { if (mouse_started()) { if (context_raw.particle_timer != null) { tween_stop(context_raw.particle_timer); - context_raw.particle_timer.done(context_raw.particle_timer.done_data); + let timer: tween_anim_t = context_raw.particle_timer; + timer.done(timer.done_data); context_raw.particle_timer = null; } history_push_undo = true;