From 92226566581d7492b95899c96f45994b43380ecb Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sat, 9 Nov 2024 11:31:18 +0100 Subject: [PATCH] Cleanup --- armorlab/sources/nodes/inpaint_node.ts | 12 +- armorlab/sources/render_path_paint.ts | 23 +- armorlab/sources/ui_nodes_ext.ts | 18 +- armorpaint/sources/base_ext.ts | 71 ++-- armorpaint/sources/make_brush.ts | 2 +- armorpaint/sources/make_paint.ts | 2 +- armorpaint/sources/make_texcoord.ts | 2 +- armorpaint/sources/nodes/input_node.ts | 3 +- armorpaint/sources/render_path_paint.ts | 31 +- armorsculpt/sources/import_mesh.ts | 2 +- armorsculpt/sources/make_sculpt.ts | 3 +- armorsculpt/sources/render_path_sculpt.ts | 3 - base/sources/base.ts | 98 +++--- base/sources/box_preferences.ts | 6 +- base/sources/config.ts | 4 +- base/sources/context.ts | 20 +- base/sources/export_texture.ts | 54 ++- base/sources/import_arm.ts | 17 +- base/sources/import_envmap.ts | 6 +- base/sources/keymap.ts | 8 +- base/sources/pipes.ts | 393 +++++++++++----------- base/sources/render_path_base.ts | 4 +- base/sources/slot_layer.ts | 29 +- base/sources/tab_materials.ts | 2 +- base/sources/tab_textures.ts | 10 +- base/sources/ui_base.ts | 28 +- base/sources/ui_files.ts | 10 +- base/sources/ui_header.ts | 16 +- base/sources/ui_nodes.ts | 2 +- base/sources/ui_view2d.ts | 4 +- base/sources/uniforms_ext.ts | 6 +- base/sources/util_render.ts | 5 +- 32 files changed, 398 insertions(+), 496 deletions(-) diff --git a/armorlab/sources/nodes/inpaint_node.ts b/armorlab/sources/nodes/inpaint_node.ts index 9233ff83d..59f83ec0a 100644 --- a/armorlab/sources/nodes/inpaint_node.ts +++ b/armorlab/sources/nodes/inpaint_node.ts @@ -87,16 +87,10 @@ function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): image_t { function inpaint_node_get_cached_image(self: inpaint_node_t): image_t { app_notify_on_next_frame(function (self: inpaint_node_t) { let source: image_t = logic_node_input_get_as_image(self.base.inputs[0]); - if (base_pipe_copy == null) { - base_make_pipe(); - } - if (const_data_screen_aligned_vb == null) { - const_data_create_screen_aligned_data(); - } g4_begin(inpaint_node_image); - g4_set_pipeline(base_pipe_inpaint_preview); - g4_set_tex(base_tex0_inpaint_preview, source); - g4_set_tex(base_texa_inpaint_preview, inpaint_node_mask); + g4_set_pipeline(pipes_inpaint_preview); + g4_set_tex(pipes_tex0_inpaint_preview, source); + g4_set_tex(pipes_texa_inpaint_preview, inpaint_node_mask); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); diff --git a/armorlab/sources/render_path_paint.ts b/armorlab/sources/render_path_paint.ts index 6ad32cce9..9b7e568d5 100644 --- a/armorlab/sources/render_path_paint.ts +++ b/armorlab/sources/render_path_paint.ts @@ -186,26 +186,23 @@ function render_path_paint_commands_cursor() { function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f32 = 1.0, tint_g: f32 = 1.0, tint_b: f32 = 1.0) { let plane: mesh_object_t = scene_get_child(".Plane").ext; let geom: mesh_data_t = plane.data; - if (base_pipe_cursor == null) { - base_make_cursor_pipe(); - } render_path_set_target(""); - g4_set_pipeline(base_pipe_cursor); + g4_set_pipeline(pipes_cursor); let img: image_t = resource_get("cursor.k"); - g4_set_tex(base_cursor_tex, img); + g4_set_tex(pipes_cursor_tex, img); let gbuffer0: render_target_t = map_get(render_path_render_targets, "gbuffer0"); - g4_set_tex_depth(base_cursor_gbufferd, gbuffer0._image); - g4_set_float2(base_cursor_mouse, mx, my); - g4_set_float2(base_cursor_tex_step, 1 / gbuffer0._image.width, 1 / gbuffer0._image.height); - g4_set_float(base_cursor_radius, radius); + g4_set_tex_depth(pipes_cursor_gbufferd, gbuffer0._image); + g4_set_float2(pipes_cursor_mouse, mx, my); + g4_set_float2(pipes_cursor_tex_step, 1 / gbuffer0._image.width, 1 / gbuffer0._image.height); + g4_set_float(pipes_cursor_radius, radius); let right: vec4_t = vec4_norm(camera_object_right_world(scene_camera)); - g4_set_float3(base_cursor_camera_right, right.x, right.y, right.z); - g4_set_float3(base_cursor_tint, tint_r, tint_g, tint_b); - g4_set_mat(base_cursor_vp, scene_camera.vp); + g4_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); + g4_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); + g4_set_mat(pipes_cursor_vp, scene_camera.vp); let help_mat: mat4_t = mat4_identity(); help_mat = mat4_inv(scene_camera.vp); - g4_set_mat(base_cursor_inv_vp, help_mat); + g4_set_mat(pipes_cursor_inv_vp, help_mat); ///if (arm_metal || arm_vulkan) let vs: vertex_element_t[] = [ { diff --git a/armorlab/sources/ui_nodes_ext.ts b/armorlab/sources/ui_nodes_ext.ts index 38919da91..3c802f0f1 100644 --- a/armorlab/sources/ui_nodes_ext.ts +++ b/armorlab/sources/ui_nodes_ext.ts @@ -37,21 +37,11 @@ function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { g2_end(); } - if (base_pipe_copy == null) { - base_make_pipe(); - } - if (base_pipe_copy_a == null) { - base_make_pipe_copy_a(); - } - if (const_data_screen_aligned_vb == null) { - const_data_create_screen_aligned_data(); - } - let texpaint_pack: render_target_t = map_get(render_path_render_targets, "texpaint_pack"); if (texocc != null) { g2_begin(texpaint_pack._image); - g2_set_pipeline(base_pipe_copy_r); + g2_set_pipeline(pipes_copy_r); g2_draw_scaled_image(texocc, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); g2_set_pipeline(null); g2_end(); @@ -59,7 +49,7 @@ function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { if (texrough != null) { g2_begin(texpaint_pack._image); - g2_set_pipeline(base_pipe_copy_g); + g2_set_pipeline(pipes_copy_g); g2_draw_scaled_image(texrough, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); g2_set_pipeline(null); g2_end(); @@ -67,8 +57,8 @@ function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { if (texheight != null) { g4_begin(texpaint_pack._image); - g4_set_pipeline(base_pipe_copy_a); - g4_set_tex(base_pipe_copy_a_tex, texheight); + g4_set_pipeline(pipes_copy_a); + g4_set_tex(pipes_copy_a_tex, texheight); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); diff --git a/armorpaint/sources/base_ext.ts b/armorpaint/sources/base_ext.ts index e6dd7468b..beb0591c5 100644 --- a/armorpaint/sources/base_ext.ts +++ b/armorpaint/sources/base_ext.ts @@ -35,12 +35,7 @@ function base_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t[] } base_make_temp_img(); base_make_export_img(); - if (base_pipe_merge == null) { - base_make_pipe(); - } - if (const_data_screen_aligned_vb == null) { - const_data_create_screen_aligned_data(); - } + let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); let empty: image_t = empty_rt._image; @@ -70,14 +65,14 @@ function base_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t[] if (l1masks != null) { if (l1masks.length > 1) { base_make_temp_mask_img(); - g2_begin(base_temp_mask_image); + g2_begin(pipes_temp_mask_image); g2_clear(0x00000000); g2_end(); - let l1: slot_layer_t = { texpaint: base_temp_mask_image }; + let l1: slot_layer_t = { texpaint: pipes_temp_mask_image }; for (let i: i32 = 0; i < l1masks.length; ++i) { base_merge_layer(l1, l1masks[i]); } - mask = base_temp_mask_image; + mask = pipes_temp_mask_image; } else { mask = l1masks[0].texpaint; @@ -86,19 +81,19 @@ function base_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t[] if (l1.paint_base) { g2_begin(base_temp_image); // Copy to temp - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(base_expa, 0, 0); g2_set_pipeline(null); g2_end(); g4_begin(base_expa); - g4_set_pipeline(base_pipe_merge); - g4_set_tex(base_tex0, l1.texpaint); - g4_set_tex(base_tex1, empty); - g4_set_tex(base_texmask, mask); - g4_set_tex(base_texa, base_temp_image); - g4_set_float(base_opac, slot_layer_get_opacity(l1)); - g4_set_int(base_blending, layers.length > 1 ? l1.blending : 0); + g4_set_pipeline(pipes_merge); + g4_set_tex(pipes_tex0, l1.texpaint); + g4_set_tex(pipes_tex1, empty); + g4_set_tex(pipes_texmask, mask); + g4_set_tex(pipes_texa, base_temp_image); + g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + g4_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -107,19 +102,19 @@ function base_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t[] if (l1.paint_nor) { g2_begin(base_temp_image); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(base_expb, 0, 0); g2_set_pipeline(null); g2_end(); g4_begin(base_expb); - g4_set_pipeline(base_pipe_merge); - g4_set_tex(base_tex0, l1.texpaint); - g4_set_tex(base_tex1, l1.texpaint_nor); - g4_set_tex(base_texmask, mask); - g4_set_tex(base_texa, base_temp_image); - g4_set_float(base_opac, slot_layer_get_opacity(l1)); - g4_set_int(base_blending, l1.paint_nor_blend ? -2 : -1); + g4_set_pipeline(pipes_merge); + g4_set_tex(pipes_tex0, l1.texpaint); + g4_set_tex(pipes_tex1, l1.texpaint_nor); + g4_set_tex(pipes_texmask, mask); + g4_set_tex(pipes_texa, base_temp_image); + g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -128,23 +123,23 @@ function base_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t[] if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { g2_begin(base_temp_image); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(base_expc, 0, 0); g2_set_pipeline(null); g2_end(); if (l1.paint_occ && l1.paint_rough && l1.paint_met && l1.paint_height) { - base_commands_merge_pack(base_pipe_merge, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? -3 : -1); + base_commands_merge_pack(pipes_merge, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? -3 : -1); } else { if (l1.paint_occ) { - base_commands_merge_pack(base_pipe_merge_r, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + base_commands_merge_pack(pipes_merge_r, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); } if (l1.paint_rough) { - base_commands_merge_pack(base_pipe_merge_g, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + base_commands_merge_pack(pipes_merge_g, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); } if (l1.paint_met) { - base_commands_merge_pack(base_pipe_merge_b, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + base_commands_merge_pack(pipes_merge_b, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); } } } @@ -170,19 +165,19 @@ function base_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t[] if (height_to_normal && make_material_height_used) { g2_begin(base_temp_image); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(l0.texpaint_nor, 0, 0); g2_set_pipeline(null); g2_end(); g4_begin(l0.texpaint_nor); - g4_set_pipeline(base_pipe_merge); - g4_set_tex(base_tex0, base_temp_image); - g4_set_tex(base_tex1, l0.texpaint_pack); - g4_set_tex(base_texmask, empty); - g4_set_tex(base_texa, empty); - g4_set_float(base_opac, 1.0); - g4_set_int(base_blending, -4); + g4_set_pipeline(pipes_merge); + g4_set_tex(pipes_tex0, base_temp_image); + g4_set_tex(pipes_tex1, l0.texpaint_pack); + g4_set_tex(pipes_texmask, empty); + g4_set_tex(pipes_texa, empty); + g4_set_float(pipes_opac, 1.0); + g4_set_int(pipes_blending, -4); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); diff --git a/armorpaint/sources/make_brush.ts b/armorpaint/sources/make_brush.ts index 148bcbe15..0f417719c 100644 --- a/armorpaint/sources/make_brush.ts +++ b/armorpaint/sources/make_brush.ts @@ -8,7 +8,7 @@ function make_brush_run(vert: node_shader_t, frag: node_shader_t) { } let fill_layer: bool = context_raw.layer.fill_layer != null; - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); if (decal && !fill_layer) { node_shader_write(frag, "if (decal_mask.z > 0.0) {"); } diff --git a/armorpaint/sources/make_paint.ts b/armorpaint/sources/make_paint.ts index 177cebdb3..9f1c11d36 100644 --- a/armorpaint/sources/make_paint.ts +++ b/armorpaint/sources/make_paint.ts @@ -91,7 +91,7 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad let face_fill: bool = context_raw.tool == workspace_tool_t.FILL && context_raw.fill_type_handle.position == fill_type_t.FACE; let uv_island_fill: bool = context_raw.tool == workspace_tool_t.FILL && context_raw.fill_type_handle.position == fill_type_t.UV_ISLAND; - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); ///if (arm_direct3d11 || arm_direct3d12 || arm_metal || arm_vulkan) node_shader_write(vert, "vec2 tpos = vec2(tex.x * 2.0 - 1.0, (1.0 - tex.y) * 2.0 - 1.0);"); diff --git a/armorpaint/sources/make_texcoord.ts b/armorpaint/sources/make_texcoord.ts index afc4975a6..bb587cfe6 100644 --- a/armorpaint/sources/make_texcoord.ts +++ b/armorpaint/sources/make_texcoord.ts @@ -3,7 +3,7 @@ function make_texcoord_run(vert: node_shader_t, frag: node_shader_t) { let fill_layer: bool = context_raw.layer.fill_layer != null; let uv_type: uv_type_t = fill_layer ? context_raw.layer.uv_type : context_raw.brush_paint; - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); let angle: f32 = context_raw.brush_angle + context_raw.brush_nodes_angle; let uv_angle: f32 = fill_layer ? context_raw.layer.angle : angle; diff --git a/armorpaint/sources/nodes/input_node.ts b/armorpaint/sources/nodes/input_node.ts index ceeb7d6f1..7af39bb0d 100644 --- a/armorpaint/sources/nodes/input_node.ts +++ b/armorpaint/sources/nodes/input_node.ts @@ -32,8 +32,7 @@ function input_node_update(self: float_node_t) { context_raw.view_index = mouse_view_x() > base_w() / 2 ? 1 : 0; } - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; - let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); + let decal_mask: bool = context_is_decal_mask_paint(); let lazy_paint: bool = context_raw.brush_lazy_radius > 0 && (operator_shortcut(map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN) || diff --git a/armorpaint/sources/render_path_paint.ts b/armorpaint/sources/render_path_paint.ts index bafa7b768..289ca4e93 100644 --- a/armorpaint/sources/render_path_paint.ts +++ b/armorpaint/sources/render_path_paint.ts @@ -442,8 +442,7 @@ function render_path_paint_commands_live_brush() { function render_path_paint_commands_cursor() { if (!config_raw.brush_3d) return; - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; - let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask"), shortcut_type_t.DOWN); + let decal_mask: bool = context_is_decal_mask(); let tool: workspace_tool_t = context_raw.tool; if (tool != workspace_tool_t.BRUSH && tool != workspace_tool_t.ERASER && @@ -475,29 +474,25 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 let plane: mesh_object_t = scene_get_child(".Plane").ext; let geom: mesh_data_t = plane.data; - if (base_pipe_cursor == null) { - base_make_cursor_pipe(); - } - render_path_set_target(""); - g4_set_pipeline(base_pipe_cursor); - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; - let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask"), shortcut_type_t.DOWN); + g4_set_pipeline(pipes_cursor); + let decal: bool = context_is_decal(); + let decal_mask: bool = context_is_decal_mask(); let img: image_t = (decal && !decal_mask) ? context_raw.decal_image : resource_get("cursor.k"); - g4_set_tex(base_cursor_tex, img); + g4_set_tex(pipes_cursor_tex, img); let rt: render_target_t = map_get(render_path_render_targets, "gbuffer0"); let gbuffer0: image_t = rt._image; - g4_set_tex_depth(base_cursor_gbufferd, gbuffer0); - g4_set_float2(base_cursor_mouse, mx, my); - g4_set_float2(base_cursor_tex_step, 1 / gbuffer0.width, 1 / gbuffer0.height); - g4_set_float(base_cursor_radius, radius); + g4_set_tex_depth(pipes_cursor_gbufferd, gbuffer0); + g4_set_float2(pipes_cursor_mouse, mx, my); + g4_set_float2(pipes_cursor_tex_step, 1 / gbuffer0.width, 1 / gbuffer0.height); + g4_set_float(pipes_cursor_radius, radius); let right: vec4_t = vec4_norm(camera_object_right_world(scene_camera)); - g4_set_float3(base_cursor_camera_right, right.x, right.y, right.z); - g4_set_float3(base_cursor_tint, tint_r, tint_g, tint_b); - g4_set_mat(base_cursor_vp, scene_camera.vp); + g4_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); + g4_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); + g4_set_mat(pipes_cursor_vp, scene_camera.vp); let help_mat: mat4_t = mat4_identity(); help_mat = mat4_inv(scene_camera.vp); - g4_set_mat(base_cursor_inv_vp, help_mat); + g4_set_mat(pipes_cursor_inv_vp, help_mat); ///if (arm_metal || arm_vulkan) let vs: vertex_element_t[] = [ { diff --git a/armorsculpt/sources/import_mesh.ts b/armorsculpt/sources/import_mesh.ts index bb4bfa2c5..33bc94a18 100644 --- a/armorsculpt/sources/import_mesh.ts +++ b/armorsculpt/sources/import_mesh.ts @@ -230,7 +230,7 @@ function import_mesh_pack_to_texture(mesh: raw_mesh_t) { let imgmesh: image_t = image_from_bytes(b, config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.RGBA128); let texpaint: image_t = project_layers[0].texpaint; g2_begin(texpaint); - g2_set_pipeline(base_pipe_copy128); + g2_set_pipeline(pipes_copy128); g2_draw_scaled_image(imgmesh, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); g2_set_pipeline(null); g2_end(); diff --git a/armorsculpt/sources/make_sculpt.ts b/armorsculpt/sources/make_sculpt.ts index c5abfe42c..c8070c44f 100644 --- a/armorsculpt/sources/make_sculpt.ts +++ b/armorsculpt/sources/make_sculpt.ts @@ -32,8 +32,7 @@ function make_sculpt_run(data: material_t, matcon: material_context_t): node_sha let frag: node_shader_t = node_shader_context_make_frag(con_paint); frag.ins = vert.outs; - let face_fill: bool = context_raw.tool == workspace_tool_t.FILL && context_raw.fill_type_handle.position == fill_type_t.FACE; - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); node_shader_add_out(vert, "vec2 tex_coord"); node_shader_write(vert, "const vec2 madd = vec2(0.5, 0.5);"); diff --git a/armorsculpt/sources/render_path_sculpt.ts b/armorsculpt/sources/render_path_sculpt.ts index c07261f37..ed6b8d0ce 100644 --- a/armorsculpt/sources/render_path_sculpt.ts +++ b/armorsculpt/sources/render_path_sculpt.ts @@ -29,9 +29,6 @@ function render_path_sculpt_commands() { mesh_object_get_contexts(project_paint_objects[0], "paint", mats, material_contexts, shader_contexts); let cc_context: shader_context_t = shader_contexts[0]; - if (const_data_screen_aligned_vb == null) { - const_data_create_screen_aligned_data(); - } g4_set_pipeline(cc_context._.pipe_state); uniforms_set_context_consts(cc_context,_render_path_bind_params); uniforms_set_obj_consts(cc_context, project_paint_objects[0].base); diff --git a/base/sources/base.ts b/base/sources/base.ts index 4063394dc..3d311289c 100644 --- a/base/sources/base.ts +++ b/base/sources/base.ts @@ -470,8 +470,8 @@ function base_update() { base_handle_drop_paths(); ///if arm_windows - let is_picker: bool = context_raw.tool == workspace_tool_t.PICKER || context_raw.tool == workspace_tool_t.MATERIAL; - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let is_picker: bool = context_is_picker(); + let decal: bool = context_is_decal(); ui_always_redraw_window = !context_raw.cache_draws || ui_menu_show || ui_box_show || @@ -994,15 +994,15 @@ function base_make_temp_img() { } function base_make_temp_mask_img() { - if (base_temp_mask_image != null && (base_temp_mask_image.width != config_get_texture_res_x() || base_temp_mask_image.height != config_get_texture_res_y())) { - let _temp_mask_image: image_t = base_temp_mask_image; + if (pipes_temp_mask_image != null && (pipes_temp_mask_image.width != config_get_texture_res_x() || pipes_temp_mask_image.height != config_get_texture_res_y())) { + let _temp_mask_image: image_t = pipes_temp_mask_image; app_notify_on_next_frame(function (_temp_mask_image: image_t) { image_unload(_temp_mask_image); }, _temp_mask_image); - base_temp_mask_image = null; + pipes_temp_mask_image = null; } - if (base_temp_mask_image == null) { - base_temp_mask_image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + if (pipes_temp_mask_image == null) { + pipes_temp_mask_image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); } } @@ -1080,26 +1080,20 @@ function base_apply_mask(l: slot_layer_t, m: slot_layer_t) { return; } - if (base_pipe_merge == null) { - base_make_pipe(); - } base_make_temp_img(); // Copy layer to temp g2_begin(base_temp_image); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(l.texpaint, 0, 0); g2_set_pipeline(null); g2_end(); // Apply mask - if (const_data_screen_aligned_vb == null) { - const_data_create_screen_aligned_data(); - } g4_begin(l.texpaint); - g4_set_pipeline(base_pipe_apply_mask); - g4_set_tex(base_tex0_mask, base_temp_image); - g4_set_tex(base_texa_mask, m.texpaint); + g4_set_pipeline(pipes_apply_mask); + g4_set_tex(pipes_tex0_mask, base_temp_image); + g4_set_tex(pipes_texa_mask, m.texpaint); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -1109,12 +1103,12 @@ function base_apply_mask(l: slot_layer_t, m: slot_layer_t) { function base_commands_merge_pack(pipe: pipeline_t, i0: image_t, i1: image_t, i1pack: image_t, i1mask_opacity: f32, i1texmask: image_t, i1blending: i32 = -1) { g4_begin(i0); g4_set_pipeline(pipe); - g4_set_tex(base_tex0, i1); - g4_set_tex(base_tex1, i1pack); - g4_set_tex(base_texmask, i1texmask); - g4_set_tex(base_texa, base_temp_image); - g4_set_float(base_opac, i1mask_opacity); - g4_set_int(base_blending, i1blending); + g4_set_tex(pipes_tex0, i1); + g4_set_tex(pipes_tex1, i1pack); + g4_set_tex(pipes_texmask, i1texmask); + g4_set_tex(pipes_texa, base_temp_image); + g4_set_float(pipes_opac, i1mask_opacity); + g4_set_int(pipes_blending, i1blending); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -1547,16 +1541,10 @@ function base_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool = return; } - if (base_pipe_merge == null) { - base_make_pipe(); - } base_make_temp_img(); - if (const_data_screen_aligned_vb == null) { - const_data_create_screen_aligned_data(); - } g2_begin(base_temp_image); // Copy to temp - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(l0.texpaint, 0, 0); g2_set_pipeline(null); g2_end(); @@ -1574,11 +1562,11 @@ function base_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool = if (slot_layer_is_mask(l1)) { g4_begin(l0.texpaint); - g4_set_pipeline(base_pipe_merge_mask); - g4_set_tex(base_tex0_merge_mask, l1.texpaint); - g4_set_tex(base_texa_merge_mask, base_temp_image); - g4_set_float(base_opac_merge_mask, slot_layer_get_opacity(l1)); - g4_set_int(base_blending_merge_mask, l1.blending); + g4_set_pipeline(pipes_merge_mask); + g4_set_tex(pipes_tex0_merge_mask, l1.texpaint); + g4_set_tex(pipes_texa_merge_mask, base_temp_image); + g4_set_float(pipes_opac_merge_mask, slot_layer_get_opacity(l1)); + g4_set_int(pipes_blending_merge_mask, l1.blending); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -1588,13 +1576,13 @@ function base_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool = if (slot_layer_is_layer(l1)) { if (l1.paint_base) { g4_begin(l0.texpaint); - g4_set_pipeline(base_pipe_merge); - g4_set_tex(base_tex0, l1.texpaint); - g4_set_tex(base_tex1, empty); - g4_set_tex(base_texmask, mask); - g4_set_tex(base_texa, base_temp_image); - g4_set_float(base_opac, slot_layer_get_opacity(l1)); - g4_set_int(base_blending, l1.blending); + g4_set_pipeline(pipes_merge); + g4_set_tex(pipes_tex0, l1.texpaint); + g4_set_tex(pipes_tex1, empty); + g4_set_tex(pipes_texmask, mask); + g4_set_tex(pipes_texa, base_temp_image); + g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + g4_set_int(pipes_blending, l1.blending); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -1603,20 +1591,20 @@ function base_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool = if (l0.texpaint_nor != null) { g2_begin(base_temp_image); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(l0.texpaint_nor, 0, 0); g2_set_pipeline(null); g2_end(); if (l1.paint_nor) { g4_begin(l0.texpaint_nor); - g4_set_pipeline(base_pipe_merge); - g4_set_tex(base_tex0, l1.texpaint); - g4_set_tex(base_tex1, l1.texpaint_nor); - g4_set_tex(base_texmask, mask); - g4_set_tex(base_texa, base_temp_image); - g4_set_float(base_opac, slot_layer_get_opacity(l1)); - g4_set_int(base_blending, l1.paint_nor_blend ? -2 : -1); + g4_set_pipeline(pipes_merge); + g4_set_tex(pipes_tex0, l1.texpaint); + g4_set_tex(pipes_tex1, l1.texpaint_nor); + g4_set_tex(pipes_texmask, mask); + g4_set_tex(pipes_texa, base_temp_image); + g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -1626,24 +1614,24 @@ function base_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool = if (l0.texpaint_pack != null) { g2_begin(base_temp_image); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(l0.texpaint_pack, 0, 0); g2_set_pipeline(null); g2_end(); if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { if (l1.paint_occ && l1.paint_rough && l1.paint_met && l1.paint_height) { - base_commands_merge_pack(base_pipe_merge, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? -3 : -1); + base_commands_merge_pack(pipes_merge, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? -3 : -1); } else { if (l1.paint_occ) { - base_commands_merge_pack(base_pipe_merge_r, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + base_commands_merge_pack(pipes_merge_r, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); } if (l1.paint_rough) { - base_commands_merge_pack(base_pipe_merge_g, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + base_commands_merge_pack(pipes_merge_g, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); } if (l1.paint_met) { - base_commands_merge_pack(base_pipe_merge_b, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + base_commands_merge_pack(pipes_merge_b, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); } } } diff --git a/base/sources/box_preferences.ts b/base/sources/box_preferences.ts index 0029fb402..0aae0f7c4 100644 --- a/base/sources/box_preferences.ts +++ b/base/sources/box_preferences.ts @@ -732,7 +732,7 @@ function box_preferences_show() { if (box_preferences_preset_handle.changed) { config_raw.keymap = box_preferences_files_keymap[box_preferences_preset_handle.position] + ".json"; config_apply(); - config_load_keymap(); + keymap_load(); } if (ui_button(tr("New"))) { @@ -745,7 +745,7 @@ function box_preferences_show() { } let keymap_name: string = ui_text_input(h, tr("Name")); if (ui_button(tr("OK")) || ui.is_return_down) { - let template: string = config_keymap_to_json(keymap_get_default()); + let template: string = keymap_to_json(keymap_get_default()); if (!ends_with(keymap_name, ".json")) { keymap_name += ".json"; } @@ -796,7 +796,7 @@ function box_preferences_show() { } if (ui.changed) { config_apply(); - config_save_keymap(); + keymap_save(); } } if (ui_tab(box_preferences_htab, tr("Plugins"), true)) { diff --git a/base/sources/config.ts b/base/sources/config.ts index 13ba3467c..08e89f63e 100644 --- a/base/sources/config.ts +++ b/base/sources/config.ts @@ -167,7 +167,7 @@ function config_init() { ui_touch_hold = config_raw.touch_ui; ui_touch_tooltip = config_raw.touch_ui; base_res_handle.position = config_raw.layer_res; - config_load_keymap(); + keymap_load(); } type version_t = { @@ -239,7 +239,7 @@ function config_import_from(from: config_t) { config_raw.sha = _sha; config_raw.version = _version; ui_children = map_create(); // Reset ui handles - config_load_keymap(); + keymap_load(); base_init_layout(); translator_load_translations(config_raw.locale); config_apply(); diff --git a/base/sources/context.ts b/base/sources/context.ts index 1bcfe6208..c3204fd85 100644 --- a/base/sources/context.ts +++ b/base/sources/context.ts @@ -518,7 +518,7 @@ function context_set_material(m: slot_material_t) { ui_nodes_hwnd.redraws = 2; ui_nodes_group_stack = []; - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); if (decal) { app_notify_on_next_frame(util_render_make_decal_preview); } @@ -602,7 +602,7 @@ function context_select_tool(i: i32) { } function context_init_tool() { - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); if (decal) { if (context_raw.tool == workspace_tool_t.TEXT) { util_render_make_text_preview(); @@ -740,6 +740,22 @@ function context_in_browser(): bool { return tab == tr("Browser"); } +function context_is_picker(): bool { + return context_raw.tool == workspace_tool_t.PICKER || context_raw.tool == workspace_tool_t.MATERIAL; +} + +function context_is_decal(): bool { + return context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; +} + +function context_is_decal_mask(): bool { + return context_is_decal() && operator_shortcut(map_get(config_keymap, "decal_mask"), shortcut_type_t.DOWN); +} + +function context_is_decal_mask_paint(): bool { + return context_is_decal() && operator_shortcut(map_get(config_keymap, "decal_mask") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); +} + function context_get_area_type(): area_type_t { if (context_in_viewport()) { return area_type_t.VIEWPORT; diff --git a/base/sources/export_texture.ts b/base/sources/export_texture.ts index 91756d978..5cc68e7b5 100644 --- a/base/sources/export_texture.ts +++ b/base/sources/export_texture.ts @@ -177,12 +177,6 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ base_make_temp_img(); base_make_export_img(); - if (base_pipe_merge == null) { - base_make_pipe(); - } - if (const_data_screen_aligned_vb == null) { - const_data_create_screen_aligned_data(); - } let rt: render_target_t = map_get(render_path_render_targets, "empty_white"); let empty: image_t = rt._image; @@ -231,16 +225,16 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ if (l1masks != null && !bake_material) { if (l1masks.length > 1) { base_make_temp_mask_img(); - g2_begin(base_temp_mask_image); + g2_begin(pipes_temp_mask_image); g2_clear(0x00000000); g2_end(); let l1: slot_layer_t = { - texpaint: base_temp_mask_image + texpaint: pipes_temp_mask_image }; for (let i: i32 = 0; i < l1masks.length; ++i) { base_merge_layer(l1, l1masks[i]); } - mask = base_temp_mask_image; + mask = pipes_temp_mask_image; } else { mask = l1masks[0].texpaint; @@ -249,19 +243,19 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ if (l1.paint_base) { g2_begin(base_temp_image); // Copy to temp - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(base_expa, 0, 0); g2_set_pipeline(null); g2_end(); g4_begin(base_expa); - g4_set_pipeline(base_pipe_merge); - g4_set_tex(base_tex0, l1.texpaint); - g4_set_tex(base_tex1, empty); - g4_set_tex(base_texmask, mask); - g4_set_tex(base_texa, base_temp_image); - g4_set_float(base_opac, slot_layer_get_opacity(l1)); - g4_set_int(base_blending, layers.length > 1 ? l1.blending : 0); + g4_set_pipeline(pipes_merge); + g4_set_tex(pipes_tex0, l1.texpaint); + g4_set_tex(pipes_tex1, empty); + g4_set_tex(pipes_texmask, mask); + g4_set_tex(pipes_texa, base_temp_image); + g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + g4_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -270,19 +264,19 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ if (l1.paint_nor) { g2_begin(base_temp_image); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(base_expb, 0, 0); g2_set_pipeline(null); g2_end(); g4_begin(base_expb); - g4_set_pipeline(base_pipe_merge); - g4_set_tex(base_tex0, l1.texpaint); - g4_set_tex(base_tex1, l1.texpaint_nor); - g4_set_tex(base_texmask, mask); - g4_set_tex(base_texa, base_temp_image); - g4_set_float(base_opac, slot_layer_get_opacity(l1)); - g4_set_int(base_blending, l1.paint_nor_blend ? -2 : -1); + g4_set_pipeline(pipes_merge); + g4_set_tex(pipes_tex0, l1.texpaint); + g4_set_tex(pipes_tex1, l1.texpaint_nor); + g4_set_tex(pipes_texmask, mask); + g4_set_tex(pipes_texa, base_temp_image); + g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); + g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -291,18 +285,18 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { g2_begin(base_temp_image); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(base_expc, 0, 0); g2_set_pipeline(null); g2_end(); if (l1.paint_occ && l1.paint_rough && l1.paint_met && l1.paint_height) { - base_commands_merge_pack(base_pipe_merge, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? -3 : -1); + base_commands_merge_pack(pipes_merge, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? -3 : -1); } else { - if (l1.paint_occ) base_commands_merge_pack(base_pipe_merge_r, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); - if (l1.paint_rough) base_commands_merge_pack(base_pipe_merge_g, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); - if (l1.paint_met) base_commands_merge_pack(base_pipe_merge_b, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + if (l1.paint_occ) base_commands_merge_pack(pipes_merge_r, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + if (l1.paint_rough) base_commands_merge_pack(pipes_merge_g, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + if (l1.paint_met) base_commands_merge_pack(pipes_merge_b, base_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); } } } diff --git a/base/sources/import_arm.ts b/base/sources/import_arm.ts index a0063dc2c..0f8cf9a0c 100644 --- a/base/sources/import_arm.ts +++ b/base/sources/import_arm.ts @@ -238,22 +238,15 @@ function import_arm_run_project(path: string) { array_push(project_layers, l); if (!is_group) { - if (base_pipe_merge == null) { - base_make_pipe(); - } - let _texpaint: image_t = null; - - ///if is_paint let _texpaint_nor: image_t = null; let _texpaint_pack: image_t = null; - ///end if (is_mask) { _texpaint = image_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4), ld.res, ld.res, tex_format_t.RGBA32); g2_begin(l.texpaint); - // g2_set_pipeline(base_pipe_copy8); - g2_set_pipeline(project.is_bgra ? base_pipe_copy_bgra : base_pipe_copy); // Full bits for undo support, R8 is used + // g2_set_pipeline(pipes_copy8); + g2_set_pipeline(project.is_bgra ? pipes_copy_bgra : pipes_copy); // Full bits for undo support, R8 is used g2_draw_image(_texpaint, 0, 0); g2_set_pipeline(null); g2_end(); @@ -262,7 +255,7 @@ function import_arm_run_project(path: string) { // TODO: create render target from bytes _texpaint = image_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4 * bytes_per_pixel), ld.res, ld.res, format); g2_begin(l.texpaint); - g2_set_pipeline(project.is_bgra ? base_pipe_copy_bgra : base_pipe_copy); + g2_set_pipeline(project.is_bgra ? pipes_copy_bgra : pipes_copy); g2_draw_image(_texpaint, 0, 0); g2_set_pipeline(null); g2_end(); @@ -270,14 +263,14 @@ function import_arm_run_project(path: string) { ///if is_paint _texpaint_nor = image_from_bytes(lz4_decode(ld.texpaint_nor, ld.res * ld.res * 4 * bytes_per_pixel), ld.res, ld.res, format); g2_begin(l.texpaint_nor); - g2_set_pipeline(project.is_bgra ? base_pipe_copy_bgra : base_pipe_copy); + g2_set_pipeline(project.is_bgra ? pipes_copy_bgra : pipes_copy); g2_draw_image(_texpaint_nor, 0, 0); g2_set_pipeline(null); g2_end(); _texpaint_pack = image_from_bytes(lz4_decode(ld.texpaint_pack, ld.res * ld.res * 4 * bytes_per_pixel), ld.res, ld.res, format); g2_begin(l.texpaint_pack); - g2_set_pipeline(project.is_bgra ? base_pipe_copy_bgra : base_pipe_copy); + g2_set_pipeline(project.is_bgra ? pipes_copy_bgra : pipes_copy); g2_draw_image(_texpaint_pack, 0, 0); g2_set_pipeline(null); g2_end(); diff --git a/base/sources/import_envmap.ts b/base/sources/import_envmap.ts index 1aea2438f..a6ae6bb30 100644 --- a/base/sources/import_envmap.ts +++ b/base/sources/import_envmap.ts @@ -32,15 +32,11 @@ function import_envmap_run(path: string, image: image_t) { array_push(import_envmap_mips, image_create_render_target(w, w > 1 ? math_floor(w / 2) : 1, tex_format_t.RGBA128)); w = math_floor(w / 2); } - - if (const_data_screen_aligned_vb == null) { - const_data_create_screen_aligned_data(); - } } // Down-scale to 1024x512 g2_begin(import_envmap_radiance); - g2_set_pipeline(base_pipe_copy128); + g2_set_pipeline(pipes_copy128); g2_draw_scaled_image(image, 0, 0, 1024, 512); g2_set_pipeline(null); g2_end(); diff --git a/base/sources/keymap.ts b/base/sources/keymap.ts index e9f8a57a8..c422d2d96 100644 --- a/base/sources/keymap.ts +++ b/base/sources/keymap.ts @@ -1,5 +1,5 @@ -function config_load_keymap() { +function keymap_load() { config_keymap = keymap_get_default(); if (config_raw.keymap != "default.json") { let blob: buffer_t = data_get_blob("keymap_presets/" + config_raw.keymap); @@ -12,16 +12,16 @@ function config_load_keymap() { } } -function config_save_keymap() { +function keymap_save() { if (config_raw.keymap == "default.json") { return; } let path: string = data_path() + "keymap_presets/" + config_raw.keymap; - let buffer: buffer_t = sys_string_to_buffer(config_keymap_to_json(config_keymap)); + let buffer: buffer_t = sys_string_to_buffer(keymap_to_json(config_keymap)); iron_file_save_bytes(path, buffer, 0); } -function config_keymap_to_json(keymap: map_t): string { +function keymap_to_json(keymap: map_t): string { json_encode_begin(); json_encode_map(keymap); return json_encode_end(); diff --git a/base/sources/pipes.ts b/base/sources/pipes.ts index fac6b5ccf..3919b00f0 100644 --- a/base/sources/pipes.ts +++ b/base/sources/pipes.ts @@ -1,55 +1,56 @@ -let base_pipe_copy: pipeline_t; -let base_pipe_copy8: pipeline_t; -let base_pipe_copy128: pipeline_t; -let base_pipe_copy_bgra: pipeline_t; -let base_pipe_copy_rgb: pipeline_t = null; -let base_pipe_merge: pipeline_t = null; -let base_pipe_merge_r: pipeline_t = null; -let base_pipe_merge_g: pipeline_t = null; -let base_pipe_merge_b: pipeline_t = null; -let base_pipe_merge_a: pipeline_t = null; -let base_pipe_invert8: pipeline_t; -let base_pipe_apply_mask: pipeline_t; -let base_pipe_merge_mask: pipeline_t; -let base_pipe_colorid_to_mask: pipeline_t; -let base_tex0: kinc_tex_unit_t; -let base_tex1: kinc_tex_unit_t; -let base_texmask: kinc_tex_unit_t; -let base_texa: kinc_tex_unit_t; -let base_opac: kinc_const_loc_t; -let base_blending: kinc_const_loc_t; -let base_tex0_mask: kinc_tex_unit_t; -let base_texa_mask: kinc_tex_unit_t; -let base_tex0_merge_mask: kinc_tex_unit_t; -let base_texa_merge_mask: kinc_tex_unit_t; -let base_tex_colorid: kinc_tex_unit_t; -let base_texpaint_colorid: kinc_tex_unit_t; -let base_opac_merge_mask: kinc_const_loc_t; -let base_blending_merge_mask: kinc_const_loc_t; -let base_temp_mask_image: image_t = null; +let pipes_copy: pipeline_t; +let pipes_copy8: pipeline_t; +let pipes_copy128: pipeline_t; +let pipes_copy_bgra: pipeline_t; +let pipes_copy_rgb: pipeline_t = null; +let pipes_copy_r: pipeline_t; +let pipes_copy_g: pipeline_t; +let pipes_copy_a: pipeline_t; +let pipes_copy_a_tex: kinc_tex_unit_t; -let base_pipe_copy_r: pipeline_t; -let base_pipe_copy_g: pipeline_t; -let base_pipe_copy_b: pipeline_t; -let base_pipe_copy_a: pipeline_t; -let base_pipe_copy_a_tex: kinc_tex_unit_t; -let base_pipe_inpaint_preview: pipeline_t; -let base_tex0_inpaint_preview: kinc_tex_unit_t; -let base_texa_inpaint_preview: kinc_tex_unit_t; +let pipes_merge: pipeline_t = null; +let pipes_merge_r: pipeline_t = null; +let pipes_merge_g: pipeline_t = null; +let pipes_merge_b: pipeline_t = null; +let pipes_merge_mask: pipeline_t; -let base_pipe_cursor: pipeline_t; -let base_cursor_vp: kinc_const_loc_t; -let base_cursor_inv_vp: kinc_const_loc_t; -let base_cursor_mouse: kinc_const_loc_t; -let base_cursor_tex_step: kinc_const_loc_t; -let base_cursor_radius: kinc_const_loc_t; -let base_cursor_camera_right: kinc_const_loc_t; -let base_cursor_tint: kinc_const_loc_t; -let base_cursor_tex: kinc_tex_unit_t; -let base_cursor_gbufferd: kinc_tex_unit_t; +let pipes_invert8: pipeline_t; +let pipes_apply_mask: pipeline_t; +let pipes_colorid_to_mask: pipeline_t; -function base_make_merge_pipe(red: bool, green: bool, blue: bool, alpha: bool): pipeline_t { +let pipes_tex0: kinc_tex_unit_t; +let pipes_tex1: kinc_tex_unit_t; +let pipes_texmask: kinc_tex_unit_t; +let pipes_texa: kinc_tex_unit_t; +let pipes_opac: kinc_const_loc_t; +let pipes_blending: kinc_const_loc_t; +let pipes_tex0_mask: kinc_tex_unit_t; +let pipes_texa_mask: kinc_tex_unit_t; +let pipes_tex0_merge_mask: kinc_tex_unit_t; +let pipes_texa_merge_mask: kinc_tex_unit_t; +let pipes_tex_colorid: kinc_tex_unit_t; +let pipes_texpaint_colorid: kinc_tex_unit_t; +let pipes_opac_merge_mask: kinc_const_loc_t; +let pipes_blending_merge_mask: kinc_const_loc_t; +let pipes_temp_mask_image: image_t = null; + +let pipes_inpaint_preview: pipeline_t; +let pipes_tex0_inpaint_preview: kinc_tex_unit_t; +let pipes_texa_inpaint_preview: kinc_tex_unit_t; + +let pipes_cursor: pipeline_t; +let pipes_cursor_vp: kinc_const_loc_t; +let pipes_cursor_inv_vp: kinc_const_loc_t; +let pipes_cursor_mouse: kinc_const_loc_t; +let pipes_cursor_tex_step: kinc_const_loc_t; +let pipes_cursor_radius: kinc_const_loc_t; +let pipes_cursor_camera_right: kinc_const_loc_t; +let pipes_cursor_tint: kinc_const_loc_t; +let pipes_cursor_tex: kinc_tex_unit_t; +let pipes_cursor_gbufferd: kinc_tex_unit_t; + +function _pipes_make_merge(red: bool, green: bool, blue: bool, alpha: bool): pipeline_t { let pipe: pipeline_t = g4_pipeline_create(); pipe.vertex_shader = sys_get_shader("pass.vert"); pipe.fragment_shader = sys_get_shader("layer_merge.frag"); @@ -64,244 +65,228 @@ function base_make_merge_pipe(red: bool, green: bool, blue: bool, alpha: bool): return pipe; } -function base_make_pipe() { +function pipes_init() { ///if (is_paint || is_sculpt) - base_pipe_merge = base_make_merge_pipe(true, true, true, true); - base_pipe_merge_r = base_make_merge_pipe(true, false, false, false); - base_pipe_merge_g = base_make_merge_pipe(false, true, false, false); - base_pipe_merge_b = base_make_merge_pipe(false, false, true, false); - base_pipe_merge_a = base_make_merge_pipe(false, false, false, true); - base_tex0 = g4_pipeline_get_tex_unit(base_pipe_merge, "tex0"); // Always binding texpaint.a for blending - base_tex1 = g4_pipeline_get_tex_unit(base_pipe_merge, "tex1"); - base_texmask = g4_pipeline_get_tex_unit(base_pipe_merge, "texmask"); - base_texa = g4_pipeline_get_tex_unit(base_pipe_merge, "texa"); - base_opac = g4_pipeline_get_const_loc(base_pipe_merge, "opac"); - base_blending = g4_pipeline_get_const_loc(base_pipe_merge, "blending"); + pipes_merge = _pipes_make_merge(true, true, true, true); + pipes_merge_r = _pipes_make_merge(true, false, false, false); + pipes_merge_g = _pipes_make_merge(false, true, false, false); + pipes_merge_b = _pipes_make_merge(false, false, true, false); + pipes_tex0 = g4_pipeline_get_tex_unit(pipes_merge, "tex0"); // Always binding texpaint.a for blending + pipes_tex1 = g4_pipeline_get_tex_unit(pipes_merge, "tex1"); + pipes_texmask = g4_pipeline_get_tex_unit(pipes_merge, "texmask"); + pipes_texa = g4_pipeline_get_tex_unit(pipes_merge, "texa"); + pipes_opac = g4_pipeline_get_const_loc(pipes_merge, "opac"); + pipes_blending = g4_pipeline_get_const_loc(pipes_merge, "blending"); ///end { - base_pipe_copy = g4_pipeline_create(); - base_pipe_copy.vertex_shader = sys_get_shader("layer_view.vert"); - base_pipe_copy.fragment_shader = sys_get_shader("layer_copy.frag"); + pipes_copy = g4_pipeline_create(); + pipes_copy.vertex_shader = sys_get_shader("layer_view.vert"); + pipes_copy.fragment_shader = sys_get_shader("layer_copy.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - base_pipe_copy.input_layout = [vs]; - g4_pipeline_compile(base_pipe_copy); + pipes_copy.input_layout = [vs]; + g4_pipeline_compile(pipes_copy); } { - base_pipe_copy_bgra = g4_pipeline_create(); - base_pipe_copy_bgra.vertex_shader = sys_get_shader("layer_view.vert"); - base_pipe_copy_bgra.fragment_shader = sys_get_shader("layer_copy_bgra.frag"); + pipes_copy_bgra = g4_pipeline_create(); + pipes_copy_bgra.vertex_shader = sys_get_shader("layer_view.vert"); + pipes_copy_bgra.fragment_shader = sys_get_shader("layer_copy_bgra.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - base_pipe_copy_bgra.input_layout = [vs]; - g4_pipeline_compile(base_pipe_copy_bgra); + pipes_copy_bgra.input_layout = [vs]; + g4_pipeline_compile(pipes_copy_bgra); } ///if (arm_metal || arm_vulkan || arm_direct3d12) { - base_pipe_copy8 = g4_pipeline_create(); - base_pipe_copy8.vertex_shader = sys_get_shader("layer_view.vert"); - base_pipe_copy8.fragment_shader = sys_get_shader("layer_copy.frag"); + pipes_copy8 = g4_pipeline_create(); + pipes_copy8.vertex_shader = sys_get_shader("layer_view.vert"); + pipes_copy8.fragment_shader = sys_get_shader("layer_copy.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - base_pipe_copy8.input_layout = [vs]; - base_pipe_copy8.color_attachment_count = 1; - base_pipe_copy8.color_attachments[0] = tex_format_t.R8; - g4_pipeline_compile(base_pipe_copy8); + pipes_copy8.input_layout = [vs]; + pipes_copy8.color_attachment_count = 1; + pipes_copy8.color_attachments[0] = tex_format_t.R8; + g4_pipeline_compile(pipes_copy8); } { - base_pipe_copy128 = g4_pipeline_create(); - base_pipe_copy128.vertex_shader = sys_get_shader("layer_view.vert"); - base_pipe_copy128.fragment_shader = sys_get_shader("layer_copy.frag"); + pipes_copy128 = g4_pipeline_create(); + pipes_copy128.vertex_shader = sys_get_shader("layer_view.vert"); + pipes_copy128.fragment_shader = sys_get_shader("layer_copy.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - base_pipe_copy128.input_layout = [vs]; - base_pipe_copy128.color_attachment_count = 1; - base_pipe_copy128.color_attachments[0] = tex_format_t.RGBA128; - g4_pipeline_compile(base_pipe_copy128); + pipes_copy128.input_layout = [vs]; + pipes_copy128.color_attachment_count = 1; + pipes_copy128.color_attachments[0] = tex_format_t.RGBA128; + g4_pipeline_compile(pipes_copy128); } ///else - base_pipe_copy8 = base_pipe_copy; - base_pipe_copy128 = base_pipe_copy; + pipes_copy8 = pipes_copy; + pipes_copy128 = pipes_copy; ///end ///if (is_paint || is_sculpt) { - base_pipe_invert8 = g4_pipeline_create(); - base_pipe_invert8.vertex_shader = sys_get_shader("layer_view.vert"); - base_pipe_invert8.fragment_shader = sys_get_shader("layer_invert.frag"); + pipes_invert8 = g4_pipeline_create(); + pipes_invert8.vertex_shader = sys_get_shader("layer_view.vert"); + pipes_invert8.fragment_shader = sys_get_shader("layer_invert.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - base_pipe_invert8.input_layout = [vs]; - base_pipe_invert8.color_attachment_count = 1; - base_pipe_invert8.color_attachments[0] = tex_format_t.R8; - g4_pipeline_compile(base_pipe_invert8); + pipes_invert8.input_layout = [vs]; + pipes_invert8.color_attachment_count = 1; + pipes_invert8.color_attachments[0] = tex_format_t.R8; + g4_pipeline_compile(pipes_invert8); } { - base_pipe_apply_mask = g4_pipeline_create(); - base_pipe_apply_mask.vertex_shader = sys_get_shader("pass.vert"); - base_pipe_apply_mask.fragment_shader = sys_get_shader("mask_apply.frag"); + pipes_apply_mask = g4_pipeline_create(); + pipes_apply_mask.vertex_shader = sys_get_shader("pass.vert"); + pipes_apply_mask.fragment_shader = sys_get_shader("mask_apply.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - base_pipe_apply_mask.input_layout = [vs]; - g4_pipeline_compile(base_pipe_apply_mask); - base_tex0_mask = g4_pipeline_get_tex_unit(base_pipe_apply_mask, "tex0"); - base_texa_mask = g4_pipeline_get_tex_unit(base_pipe_apply_mask, "texa"); + pipes_apply_mask.input_layout = [vs]; + g4_pipeline_compile(pipes_apply_mask); + pipes_tex0_mask = g4_pipeline_get_tex_unit(pipes_apply_mask, "tex0"); + pipes_texa_mask = g4_pipeline_get_tex_unit(pipes_apply_mask, "texa"); } { - base_pipe_merge_mask = g4_pipeline_create(); - base_pipe_merge_mask.vertex_shader = sys_get_shader("pass.vert"); - base_pipe_merge_mask.fragment_shader = sys_get_shader("mask_merge.frag"); + pipes_merge_mask = g4_pipeline_create(); + pipes_merge_mask.vertex_shader = sys_get_shader("pass.vert"); + pipes_merge_mask.fragment_shader = sys_get_shader("mask_merge.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - base_pipe_merge_mask.input_layout = [vs]; - g4_pipeline_compile(base_pipe_merge_mask); - base_tex0_merge_mask = g4_pipeline_get_tex_unit(base_pipe_merge_mask, "tex0"); - base_texa_merge_mask = g4_pipeline_get_tex_unit(base_pipe_merge_mask, "texa"); - base_opac_merge_mask = g4_pipeline_get_const_loc(base_pipe_merge_mask, "opac"); - base_blending_merge_mask = g4_pipeline_get_const_loc(base_pipe_merge_mask, "blending"); + pipes_merge_mask.input_layout = [vs]; + g4_pipeline_compile(pipes_merge_mask); + pipes_tex0_merge_mask = g4_pipeline_get_tex_unit(pipes_merge_mask, "tex0"); + pipes_texa_merge_mask = g4_pipeline_get_tex_unit(pipes_merge_mask, "texa"); + pipes_opac_merge_mask = g4_pipeline_get_const_loc(pipes_merge_mask, "opac"); + pipes_blending_merge_mask = g4_pipeline_get_const_loc(pipes_merge_mask, "blending"); } { - base_pipe_colorid_to_mask = g4_pipeline_create(); - base_pipe_colorid_to_mask.vertex_shader = sys_get_shader("pass.vert"); - base_pipe_colorid_to_mask.fragment_shader = sys_get_shader("mask_colorid.frag"); + pipes_colorid_to_mask = g4_pipeline_create(); + pipes_colorid_to_mask.vertex_shader = sys_get_shader("pass.vert"); + pipes_colorid_to_mask.fragment_shader = sys_get_shader("mask_colorid.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - base_pipe_colorid_to_mask.input_layout = [vs]; - g4_pipeline_compile(base_pipe_colorid_to_mask); - base_texpaint_colorid = g4_pipeline_get_tex_unit(base_pipe_colorid_to_mask, "texpaint_colorid"); - base_tex_colorid = g4_pipeline_get_tex_unit(base_pipe_colorid_to_mask, "texcolorid"); + pipes_colorid_to_mask.input_layout = [vs]; + g4_pipeline_compile(pipes_colorid_to_mask); + pipes_texpaint_colorid = g4_pipeline_get_tex_unit(pipes_colorid_to_mask, "texpaint_colorid"); + pipes_tex_colorid = g4_pipeline_get_tex_unit(pipes_colorid_to_mask, "texcolorid"); } ///end ///if is_lab { - base_pipe_copy_r = g4_pipeline_create(); - base_pipe_copy_r.vertex_shader = sys_get_shader("layer_view.vert"); - base_pipe_copy_r.fragment_shader = sys_get_shader("layer_copy.frag"); + pipes_copy_r = g4_pipeline_create(); + pipes_copy_r.vertex_shader = sys_get_shader("layer_view.vert"); + pipes_copy_r.fragment_shader = sys_get_shader("layer_copy.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - base_pipe_copy_r.input_layout = [vs]; - base_pipe_copy_r.color_write_masks_green = [false]; - base_pipe_copy_r.color_write_masks_blue = [false]; - base_pipe_copy_r.color_write_masks_alpha = [false]; - g4_pipeline_compile(base_pipe_copy_r); + pipes_copy_r.input_layout = [vs]; + pipes_copy_r.color_write_masks_green = [false]; + pipes_copy_r.color_write_masks_blue = [false]; + pipes_copy_r.color_write_masks_alpha = [false]; + g4_pipeline_compile(pipes_copy_r); } { - base_pipe_copy_g = g4_pipeline_create(); - base_pipe_copy_g.vertex_shader = sys_get_shader("layer_view.vert"); - base_pipe_copy_g.fragment_shader = sys_get_shader("layer_copy.frag"); + pipes_copy_g = g4_pipeline_create(); + pipes_copy_g.vertex_shader = sys_get_shader("layer_view.vert"); + pipes_copy_g.fragment_shader = sys_get_shader("layer_copy.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - base_pipe_copy_g.input_layout = [vs]; - base_pipe_copy_g.color_write_masks_red = [false]; - base_pipe_copy_g.color_write_masks_blue = [false]; - base_pipe_copy_g.color_write_masks_alpha = [false]; - g4_pipeline_compile(base_pipe_copy_g); + pipes_copy_g.input_layout = [vs]; + pipes_copy_g.color_write_masks_red = [false]; + pipes_copy_g.color_write_masks_blue = [false]; + pipes_copy_g.color_write_masks_alpha = [false]; + g4_pipeline_compile(pipes_copy_g); } { - base_pipe_copy_b = g4_pipeline_create(); - base_pipe_copy_b.vertex_shader = sys_get_shader("layer_view.vert"); - base_pipe_copy_b.fragment_shader = sys_get_shader("layer_copy.frag"); + pipes_inpaint_preview = g4_pipeline_create(); + pipes_inpaint_preview.vertex_shader = sys_get_shader("pass.vert"); + pipes_inpaint_preview.fragment_shader = sys_get_shader("inpaint_preview.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - base_pipe_copy_b.input_layout = [vs]; - base_pipe_copy_b.color_write_masks_red = [false]; - base_pipe_copy_b.color_write_masks_green = [false]; - base_pipe_copy_b.color_write_masks_alpha = [false]; - g4_pipeline_compile(base_pipe_copy_b); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + pipes_inpaint_preview.input_layout = [vs]; + g4_pipeline_compile(pipes_inpaint_preview); + pipes_tex0_inpaint_preview = g4_pipeline_get_tex_unit(pipes_inpaint_preview, "tex0"); + pipes_texa_inpaint_preview = g4_pipeline_get_tex_unit(pipes_inpaint_preview, "texa"); } { - base_pipe_inpaint_preview = g4_pipeline_create(); - base_pipe_inpaint_preview.vertex_shader = sys_get_shader("pass.vert"); - base_pipe_inpaint_preview.fragment_shader = sys_get_shader("inpaint_preview.frag"); + pipes_copy_a = g4_pipeline_create(); + pipes_copy_a.vertex_shader = sys_get_shader("pass.vert"); + pipes_copy_a.fragment_shader = sys_get_shader("layer_copy_rrrr.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - base_pipe_inpaint_preview.input_layout = [vs]; - g4_pipeline_compile(base_pipe_inpaint_preview); - base_tex0_inpaint_preview = g4_pipeline_get_tex_unit(base_pipe_inpaint_preview, "tex0"); - base_texa_inpaint_preview = g4_pipeline_get_tex_unit(base_pipe_inpaint_preview, "texa"); + pipes_copy_a.input_layout = [vs]; + pipes_copy_a.color_write_masks_red = [false]; + pipes_copy_a.color_write_masks_green = [false]; + pipes_copy_a.color_write_masks_blue = [false]; + g4_pipeline_compile(pipes_copy_a); + pipes_copy_a_tex = g4_pipeline_get_tex_unit(pipes_copy_a, "tex"); } ///end -} - -function base_make_pipe_copy_rgb() { - base_pipe_copy_rgb = g4_pipeline_create(); - base_pipe_copy_rgb.vertex_shader = sys_get_shader("layer_view.vert"); - base_pipe_copy_rgb.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: vertex_struct_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - base_pipe_copy_rgb.input_layout = [vs]; - base_pipe_copy_rgb.color_write_masks_alpha = [false]; - g4_pipeline_compile(base_pipe_copy_rgb); -} -function base_make_pipe_copy_a() { - base_pipe_copy_a = g4_pipeline_create(); - base_pipe_copy_a.vertex_shader = sys_get_shader("pass.vert"); - base_pipe_copy_a.fragment_shader = sys_get_shader("layer_copy_rrrr.frag"); - let vs: vertex_struct_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - base_pipe_copy_a.input_layout = [vs]; - base_pipe_copy_a.color_write_masks_red = [false]; - base_pipe_copy_a.color_write_masks_green = [false]; - base_pipe_copy_a.color_write_masks_blue = [false]; - g4_pipeline_compile(base_pipe_copy_a); - base_pipe_copy_a_tex = g4_pipeline_get_tex_unit(base_pipe_copy_a, "tex"); -} + { + pipes_copy_rgb = g4_pipeline_create(); + pipes_copy_rgb.vertex_shader = sys_get_shader("layer_view.vert"); + pipes_copy_rgb.fragment_shader = sys_get_shader("layer_copy.frag"); + let vs: vertex_struct_t = g4_vertex_struct_create(); + g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + pipes_copy_rgb.input_layout = [vs]; + pipes_copy_rgb.color_write_masks_alpha = [false]; + g4_pipeline_compile(pipes_copy_rgb); + } -function base_make_cursor_pipe() { - base_pipe_cursor = g4_pipeline_create(); - base_pipe_cursor.vertex_shader = sys_get_shader("cursor.vert"); - base_pipe_cursor.fragment_shader = sys_get_shader("cursor.frag"); - let vs: vertex_struct_t = g4_vertex_struct_create(); - ///if (arm_metal || arm_vulkan) - g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); - ///else - g4_vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); - g4_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); - g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); - ///end - base_pipe_cursor.input_layout = [vs]; - base_pipe_cursor.blend_source = blend_factor_t.SOURCE_ALPHA; - base_pipe_cursor.blend_dest = blend_factor_t.INV_SOURCE_ALPHA; - base_pipe_cursor.depth_write = false; - base_pipe_cursor.depth_mode = compare_mode_t.ALWAYS; - g4_pipeline_compile(base_pipe_cursor); - base_cursor_vp = g4_pipeline_get_const_loc(base_pipe_cursor, "VP"); - base_cursor_inv_vp = g4_pipeline_get_const_loc(base_pipe_cursor, "invVP"); - base_cursor_mouse = g4_pipeline_get_const_loc(base_pipe_cursor, "mouse"); - base_cursor_tex_step = g4_pipeline_get_const_loc(base_pipe_cursor, "tex_step"); - base_cursor_radius = g4_pipeline_get_const_loc(base_pipe_cursor, "radius"); - base_cursor_camera_right = g4_pipeline_get_const_loc(base_pipe_cursor, "camera_right"); - base_cursor_tint = g4_pipeline_get_const_loc(base_pipe_cursor, "tint"); - base_cursor_gbufferd = g4_pipeline_get_tex_unit(base_pipe_cursor, "gbufferD"); - base_cursor_tex = g4_pipeline_get_tex_unit(base_pipe_cursor, "tex"); + { + pipes_cursor = g4_pipeline_create(); + pipes_cursor.vertex_shader = sys_get_shader("cursor.vert"); + pipes_cursor.fragment_shader = sys_get_shader("cursor.frag"); + let vs: vertex_struct_t = g4_vertex_struct_create(); + ///if (arm_metal || arm_vulkan) + g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + ///else + g4_vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); + g4_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); + g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + ///end + pipes_cursor.input_layout = [vs]; + pipes_cursor.blend_source = blend_factor_t.SOURCE_ALPHA; + pipes_cursor.blend_dest = blend_factor_t.INV_SOURCE_ALPHA; + pipes_cursor.depth_write = false; + pipes_cursor.depth_mode = compare_mode_t.ALWAYS; + g4_pipeline_compile(pipes_cursor); + pipes_cursor_vp = g4_pipeline_get_const_loc(pipes_cursor, "VP"); + pipes_cursor_inv_vp = g4_pipeline_get_const_loc(pipes_cursor, "invVP"); + pipes_cursor_mouse = g4_pipeline_get_const_loc(pipes_cursor, "mouse"); + pipes_cursor_tex_step = g4_pipeline_get_const_loc(pipes_cursor, "tex_step"); + pipes_cursor_radius = g4_pipeline_get_const_loc(pipes_cursor, "radius"); + pipes_cursor_camera_right = g4_pipeline_get_const_loc(pipes_cursor, "camera_right"); + pipes_cursor_tint = g4_pipeline_get_const_loc(pipes_cursor, "tint"); + pipes_cursor_gbufferd = g4_pipeline_get_tex_unit(pipes_cursor, "gbufferD"); + pipes_cursor_tex = g4_pipeline_get_tex_unit(pipes_cursor, "tex"); + } } diff --git a/base/sources/render_path_base.ts b/base/sources/render_path_base.ts index 0f6f262f7..d255d3ce5 100644 --- a/base/sources/render_path_base.ts +++ b/base/sources/render_path_base.ts @@ -12,6 +12,8 @@ let render_path_base_voxels_created: bool = false; ///end function render_path_base_init() { + pipes_init(); + const_data_create_screen_aligned_data(); render_path_base_super_sample = config_raw.rp_supersample; } @@ -110,7 +112,7 @@ function render_path_base_begin() { camera_views[context_raw.view_index_last].v = mat4_clone(cam.base.transform.local); } - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); if (context_raw.view_index_last != context_raw.view_index || decal || !config_raw.brush_3d) { // Redraw on current viewport change diff --git a/base/sources/slot_layer.ts b/base/sources/slot_layer.ts index b221d4ddc..c31d25d71 100644 --- a/base/sources/slot_layer.ts +++ b/base/sources/slot_layer.ts @@ -267,12 +267,9 @@ function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_ } function slot_layer_invert_mask(raw: slot_layer_t) { - if (base_pipe_invert8 == null) { - base_make_pipe(); - } let inverted: image_t = image_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32); g2_begin(inverted); - g2_set_pipeline(base_pipe_invert8); + g2_set_pipeline(pipes_invert8); g2_draw_image(raw.texpaint, 0, 0); g2_set_pipeline(null); g2_end(); @@ -308,19 +305,16 @@ function slot_layer_duplicate(raw: slot_layer_t): slot_layer_t { let l: slot_layer_t = slot_layer_create("", slot_layer_is_layer(raw) ? layer_slot_type_t.LAYER : slot_layer_is_mask(raw) ? layer_slot_type_t.MASK : layer_slot_type_t.GROUP, raw.parent); array_insert(layers, i, l); - if (base_pipe_merge == null) { - base_make_pipe(); - } if (slot_layer_is_layer(raw)) { g2_begin(l.texpaint); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(raw.texpaint, 0, 0); g2_set_pipeline(null); g2_end(); if (l.texpaint_nor != null) { g2_begin(l.texpaint_nor); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(raw.texpaint_nor, 0, 0); g2_set_pipeline(null); g2_end(); @@ -328,7 +322,7 @@ function slot_layer_duplicate(raw: slot_layer_t): slot_layer_t { if (l.texpaint_pack != null) { g2_begin(l.texpaint_pack); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_image(raw.texpaint_pack, 0, 0); g2_set_pipeline(null); g2_end(); @@ -336,7 +330,7 @@ function slot_layer_duplicate(raw: slot_layer_t): slot_layer_t { } else if (slot_layer_is_mask(raw)) { g2_begin(l.texpaint); - g2_set_pipeline(base_pipe_copy8); + g2_set_pipeline(pipes_copy8); g2_draw_image(raw.texpaint, 0, 0); g2_set_pipeline(null); g2_end(); @@ -345,7 +339,7 @@ function slot_layer_duplicate(raw: slot_layer_t): slot_layer_t { if (l.texpaint_preview != null) { g2_begin(l.texpaint_preview); g2_clear(0x00000000); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_scaled_image(raw.texpaint_preview, 0, 0, raw.texpaint_preview.width, raw.texpaint_preview.height); g2_set_pipeline(null); g2_end(); @@ -378,9 +372,6 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { let res_x: i32 = config_get_texture_res_x(); let res_y: i32 = config_get_texture_res_y(); let rts: map_t = render_path_render_targets; - if (base_pipe_merge == null) { - base_make_pipe(); - } if (slot_layer_is_layer(raw)) { let format: tex_format_t = @@ -395,7 +386,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { let _texpaint: image_t = raw.texpaint; raw.texpaint = image_create_render_target(res_x, res_y, format); g2_begin(raw.texpaint); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_scaled_image(_texpaint, 0, 0, res_x, res_y); g2_set_pipeline(null); g2_end(); @@ -405,7 +396,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { raw.texpaint_nor = image_create_render_target(res_x, res_y, format); g2_begin(raw.texpaint_nor); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_scaled_image(_texpaint_nor, 0, 0, res_x, res_y); g2_set_pipeline(null); g2_end(); @@ -416,7 +407,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { raw.texpaint_pack = image_create_render_target(res_x, res_y, format); g2_begin(raw.texpaint_pack); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_scaled_image(_texpaint_pack, 0, 0, res_x, res_y); g2_set_pipeline(null); g2_end(); @@ -456,7 +447,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { raw.texpaint = image_create_render_target(res_x, res_y, tex_format_t.RGBA32); g2_begin(raw.texpaint); - g2_set_pipeline(base_pipe_copy8); + g2_set_pipeline(pipes_copy8); g2_draw_scaled_image(_texpaint, 0, 0, res_x, res_y); g2_set_pipeline(null); g2_end(); diff --git a/base/sources/tab_materials.ts b/base/sources/tab_materials.ts index ada3d8d10..7f10d8e77 100644 --- a/base/sources/tab_materials.ts +++ b/base/sources/tab_materials.ts @@ -322,7 +322,7 @@ function tab_materials_update_material() { ui_nodes_group_stack = []; make_material_parse_paint_material(); util_render_make_material_preview(); - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); if (decal) { util_render_make_decal_preview(); } diff --git a/base/sources/tab_textures.ts b/base/sources/tab_textures.ts index 76987bfba..a9da2cbf9 100644 --- a/base/sources/tab_textures.ts +++ b/base/sources/tab_textures.ts @@ -138,17 +138,9 @@ function tab_textures_draw(htab: ui_handle_t) { app_notify_on_next_frame(function () { let img: image_t = _tab_textures_draw_img; - - ///if (is_paint || is_sculpt) - if (base_pipe_merge == null) base_make_pipe(); - ///end - ///if is_lab - if (base_pipe_copy == null) base_make_pipe(); - ///end - let target: image_t = image_create_render_target(tab_textures_to_pow2(img.width), tab_textures_to_pow2(img.height)); g2_begin(target); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_scaled_image(img, 0, 0, target.width, target.height); g2_set_pipeline(null); g2_end(); diff --git a/base/sources/ui_base.ts b/base/sources/ui_base.ts index 48ae002ad..b9a9be648 100644 --- a/base/sources/ui_base.ts +++ b/base/sources/ui_base.ts @@ -365,8 +365,8 @@ function ui_base_update() { ///end ///if (is_paint || is_sculpt) - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; - let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask"), shortcut_type_t.DOWN); + let decal: bool = context_is_decal(); + let decal_mask: bool = context_is_decal_mask(); if ((context_raw.brush_can_lock || context_raw.brush_locked) && mouse_moved) { if (operator_shortcut(map_get(config_keymap, "brush_radius"), shortcut_type_t.DOWN) || @@ -1031,8 +1031,8 @@ function ui_base_update_ui() { let set_clone_source: bool = context_raw.tool == workspace_tool_t.CLONE && operator_shortcut(map_get(config_keymap, "set_clone_source") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; - let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); + let decal: bool = context_is_decal(); + let decal_mask: bool = context_is_decal_mask_paint(); ///if (is_paint || is_sculpt) let down: bool = operator_shortcut(map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN) || @@ -1166,9 +1166,6 @@ function ui_base_update_ui() { context_raw.layers_preview_dirty = false; context_raw.layer_preview_dirty = false; context_raw.mask_preview_last = null; - if (base_pipe_merge == null) { - base_make_pipe(); - } // Update all layer previews for (let i: i32 = 0; i < project_layers.length; ++i) { let l: slot_layer_t = project_layers[i]; @@ -1184,20 +1181,17 @@ function ui_base_update_ui() { let source: image_t = l.texpaint; g2_begin(target); g2_clear(0x00000000); - // g2_set_pipeline(l.isMask() ? base_pipe_copy8 : base_pipe_copy); - g2_set_pipeline(base_pipe_copy); // texpaint_preview is always RGBA32 for now + // g2_set_pipeline(l.is_mask() ? pipes_copy8 : pipes_copy); + g2_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now g2_draw_scaled_image(source, 0, 0, target.width, target.height); g2_set_pipeline(null); g2_end(); } ui_base_hwnds[tab_area_t.SIDEBAR0].redraws = 2; } - if (context_raw.layer_preview_dirty && !slot_layer_is_group(context_raw.layer)) { + if (context_raw.layer != null && context_raw.layer_preview_dirty && !slot_layer_is_group(context_raw.layer)) { context_raw.layer_preview_dirty = false; context_raw.mask_preview_last = null; - if (base_pipe_merge == null) { - base_make_pipe(); - } // Update layer preview let l: slot_layer_t = context_raw.layer; @@ -1207,8 +1201,8 @@ function ui_base_update_ui() { let source: image_t = l.texpaint; g2_begin(target); g2_clear(0x00000000); - // g2_set_pipeline(raw.layer.isMask() ? base_pipe_copy8 : base_pipe_copy); - g2_set_pipeline(base_pipe_copy); // texpaint_preview is always RGBA32 for now + // g2_set_pipeline(raw.layer.is_mask() ? pipes_copy8 : pipes_copy); + g2_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now g2_draw_scaled_image(source, 0, 0, target.width, target.height); g2_set_pipeline(null); g2_end(); @@ -1458,10 +1452,10 @@ function ui_base_render_cursor() { g2_set_color(0xffffffff); } - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); if (!config_raw.brush_3d || context_in_2d_view() || decal) { - let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask"), shortcut_type_t.DOWN); + let decal_mask: bool = context_is_decal_mask(); if (decal && !context_in_nodes()) { let decal_alpha: f32 = 0.5; if (!decal_mask) { diff --git a/base/sources/ui_files.ts b/base/sources/ui_files.ts index c1bd56358..996e5dc60 100644 --- a/base/sources/ui_files.ts +++ b/base/sources/ui_files.ts @@ -207,9 +207,6 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let data: draw_cloud_icon_data_t = make_draw_cloud_icon_data(_ui_files_file_browser_f, image); app_notify_on_init(function (data: draw_cloud_icon_data_t) { - if (base_pipe_copy_rgb == null) { - base_make_pipe_copy_rgb(); - } let icon: image_t = image_create_render_target(data.image.width, data.image.height); if (ends_with(data.f, ".arm")) { // Used for material sphere alpha cutout g2_begin(icon); @@ -222,7 +219,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = g2_begin(icon); g2_clear(0xffffffff); } - g2_set_pipeline(base_pipe_copy_rgb); + g2_set_pipeline(pipes_copy_rgb); g2_draw_image(data.image, 0, 0); g2_set_pipeline(null); g2_end(); @@ -432,9 +429,6 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = } function ui_files_make_icon (args: ui_files_make_icon_t) { - if (base_pipe_copy_rgb == null) { - base_make_pipe_copy_rgb(); - } let w: i32 = args.w; let image: image_t = args.image; let sw: i32 = image.width > image.height ? w : math_floor(1.0 * image.width / image.height * w); @@ -442,7 +436,7 @@ function ui_files_make_icon (args: ui_files_make_icon_t) { let icon: image_t = image_create_render_target(sw, sh); g2_begin(icon); g2_clear(0xffffffff); - g2_set_pipeline(base_pipe_copy_rgb); + g2_set_pipeline(pipes_copy_rgb); g2_draw_scaled_image(image, 0, 0, sw, sh); g2_set_pipeline(null); g2_end(); diff --git a/base/sources/ui_header.ts b/base/sources/ui_header.ts index 29550a08b..859d12817 100644 --- a/base/sources/ui_header.ts +++ b/base/sources/ui_header.ts @@ -90,17 +90,11 @@ function ui_header_draw_tool_properties(ui: ui_t) { } let m: slot_layer_t = base_new_mask(false, context_raw.layer); app_notify_on_next_frame(function (m: slot_layer_t) { - if (base_pipe_merge == null) { - base_make_pipe(); - } - if (const_data_screen_aligned_vb == null) { - const_data_create_screen_aligned_data(); - } g4_begin(m.texpaint); - g4_set_pipeline(base_pipe_colorid_to_mask); + g4_set_pipeline(pipes_colorid_to_mask); let rt: render_target_t = map_get(render_path_render_targets, "texpaint_colorid"); - g4_set_tex(base_texpaint_colorid, rt._image); - g4_set_tex(base_tex_colorid, project_get_image(project_assets[context_raw.colorid_handle.position])); + g4_set_tex(pipes_texpaint_colorid, rt._image); + g4_set_tex(pipes_tex_colorid, project_get_image(project_assets[context_raw.colorid_handle.position])); g4_set_vertex_buffer(const_data_screen_aligned_vb); g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -354,8 +348,8 @@ function ui_header_draw_tool_properties(ui: ui_t) { context_raw.tool == workspace_tool_t.SMUDGE || context_raw.tool == workspace_tool_t.PARTICLE) { - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; - let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask"), shortcut_type_t.DOWN); + let decal: bool = context_is_decal(); + let decal_mask: bool = context_is_decal_mask(); if (context_raw.tool != workspace_tool_t.FILL) { if (decal_mask) { context_raw.brush_decal_mask_radius = ui_slider(context_raw.brush_decal_mask_radius_handle, tr("Radius"), 0.01, 2.0, true); diff --git a/base/sources/ui_nodes.ts b/base/sources/ui_nodes.ts index 141400a43..4fb94bfb4 100644 --- a/base/sources/ui_nodes.ts +++ b/base/sources/ui_nodes.ts @@ -780,7 +780,7 @@ function ui_nodes_render() { util_render_make_material_preview(); } - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); if (decal) { util_render_make_decal_preview(); } diff --git a/base/sources/ui_view2d.ts b/base/sources/ui_view2d.ts index a2bd05bce..58bca624a 100644 --- a/base/sources/ui_view2d.ts +++ b/base/sources/ui_view2d.ts @@ -464,8 +464,8 @@ function ui_view2d_update() { } ///if (is_paint || is_sculpt) - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; - let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); + let decal: bool = context_is_decal(); + let decal_mask: bool = context_is_decal_mask_paint(); let set_clone_source: bool = context_raw.tool == workspace_tool_t.CLONE && operator_shortcut(map_get(config_keymap, "set_clone_source") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); if (ui_view2d_type == view_2d_type_t.LAYER && diff --git a/base/sources/uniforms_ext.ts b/base/sources/uniforms_ext.ts index d7c4377bc..f4af3253c 100644 --- a/base/sources/uniforms_ext.ts +++ b/base/sources/uniforms_ext.ts @@ -21,7 +21,7 @@ function uniforms_ext_i32_link(object: object_t, mat: material_data_t, link: str function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: string): f32 { if (link == "_brush_radius") { ///if (is_paint || is_sculpt) - let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; + let decal: bool = context_is_decal(); let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); let brush_decal_mask_radius: f32 = context_raw.brush_decal_mask_radius; if (config_raw.brush_3d) { @@ -79,7 +79,7 @@ function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: str return val; } else if (link == "_brush_hardness") { - let decal_mask: bool = operator_shortcut(map_get(config_keymap, "decal_mask") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); + let decal_mask: bool = context_is_decal_mask_paint(); if (context_raw.tool != workspace_tool_t.BRUSH && context_raw.tool != workspace_tool_t.ERASER && context_raw.tool != workspace_tool_t.CLONE && !decal_mask) { return 1.0; } @@ -277,7 +277,7 @@ function uniforms_ext_vec4_link(object: object_t, mat: material_data_t, link: st return v; } else if (link == "_decal_mask") { - let decal_mask: bool = operator_shortcut(map_get(config_keymap, "decal_mask") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); + let decal_mask: bool = context_is_decal_mask_paint(); let val: f32 = (context_raw.brush_radius * context_raw.brush_nodes_radius) / 15.0; let scale2d: f32 = (900 / base_h()) * config_raw.window_scale; val *= scale2d; // Projection ratio diff --git a/base/sources/util_render.ts b/base/sources/util_render.ts index 0c6eb60fb..a02af773a 100644 --- a/base/sources/util_render.ts +++ b/base/sources/util_render.ts @@ -350,14 +350,11 @@ function util_render_make_brush_preview() { camera_object_build_mat(scene_camera); // Scale layer down to to image preview - if (base_pipe_merge == null) { - base_make_pipe(); - } l = render_path_paint_live_layer; let target: image_t = context_raw.brush.image; g2_begin(target); g2_clear(0x00000000); - g2_set_pipeline(base_pipe_copy); + g2_set_pipeline(pipes_copy); g2_draw_scaled_image(l.texpaint, 0, 0, target.width, target.height); g2_set_pipeline(null); g2_end();