diff --git a/paint/sources/box_export.ts b/paint/sources/box_export.ts index 598106c0..ad9d984a 100644 --- a/paint/sources/box_export.ts +++ b/paint/sources/box_export.ts @@ -2,7 +2,6 @@ let box_export_htab: ui_handle_t = ui_handle_create(); let box_export_files: string[] = null; let box_export_mesh_handle: ui_handle_t = ui_handle_create(); - let box_export_hpreset: ui_handle_t = ui_handle_create(); let box_export_preset: export_preset_t = null; let box_export_channels: string[] = [ @@ -28,7 +27,6 @@ let box_export_color_spaces: string[] = [ "linear", "srgb" ]; - let _box_export_bake_material: bool; let _box_export_t: export_preset_texture_t; let _box_export_apply_displacement: bool; diff --git a/paint/sources/box_preferences.ts b/paint/sources/box_preferences.ts index 9aefffd1..1355f743 100644 --- a/paint/sources/box_preferences.ts +++ b/paint/sources/box_preferences.ts @@ -10,728 +10,717 @@ let _box_preferences_f: string; let _box_preferences_h: ui_handle_t; let _box_preferences_i: i32; -function box_preferences_show() { - ui_box_show_custom(function () { - if (ui_tab(box_preferences_htab, tr("Interface"), true)) { +function box_preferences_interface_tab() { + if (box_preferences_locales == null) { + box_preferences_locales = translator_get_supported_locales(); + } - if (box_preferences_locales == null) { - box_preferences_locales = translator_get_supported_locales(); - } + let locale_handle: ui_handle_t = ui_handle(__ID__); + if (locale_handle.init) { + locale_handle.i = array_index_of(box_preferences_locales, config_raw.locale); + } + ui_combo(locale_handle, box_preferences_locales, tr("Language"), true); + if (locale_handle.changed) { + let locale_code: string = box_preferences_locales[locale_handle.i]; + config_raw.locale = locale_code; + translator_load_translations(locale_code); + base_redraw_ui(); + } - let locale_handle: ui_handle_t = ui_handle(__ID__); - if (locale_handle.init) { - locale_handle.i = array_index_of(box_preferences_locales, config_raw.locale); - } - ui_combo(locale_handle, box_preferences_locales, tr("Language"), true); - if (locale_handle.changed) { - let locale_code: string = box_preferences_locales[locale_handle.i]; - config_raw.locale = locale_code; - translator_load_translations(locale_code); - base_redraw_ui(); - } - - let hscale: ui_handle_t = ui_handle(__ID__); - if (hscale.init) { - hscale.f = config_raw.window_scale; - } - ui_slider(hscale, tr("UI Scale"), 1.0, 4.0, true, 10); - if (context_raw.hscale_was_changed && !ui.input_down) { - context_raw.hscale_was_changed = false; - if (hscale.f == 0.0) { - hscale.f = 1.0; - } - config_raw.window_scale = hscale.f; - box_preferences_set_scale(); - } - if (hscale.changed) { - context_raw.hscale_was_changed = true; - } - - let h_node_previews: ui_handle_t = ui_handle(__ID__); - if (h_node_previews.init) { - h_node_previews.b = config_raw.node_previews; - } - config_raw.node_previews = ui_check(h_node_previews, tr("Node Previews")); - if (h_node_previews.changed) { - for (let i: i32 = 0; i < project_materials.length; ++i) { - let c: ui_node_canvas_t = project_materials[i].canvas; - for (let j: i32 = 0; j < c.nodes.length; ++j) { - let n: ui_node_t = c.nodes[j]; - if (config_raw.node_previews) { - n.flags |= _ui_node_flag_t.PREVIEW; - } - else { - n.flags &= ~_ui_node_flag_t.PREVIEW; - } - } - } - ui_nodes_hwnd.redraws = 2; - } - if (ui.is_hovered) { - ui_tooltip(tr("Show node preview on each node by default")); - } - - let h_wrap_mouse: ui_handle_t = ui_handle(__ID__); - if (h_wrap_mouse.init) { - h_wrap_mouse.b = config_raw.wrap_mouse; - } - config_raw.wrap_mouse = ui_check(h_wrap_mouse, tr("Wrap Mouse")); - if (ui.is_hovered) { - ui_tooltip(tr("Wrap mouse around view boundaries during camera control")); - } - - ui.changed = false; - let h_show_asset_names: ui_handle_t = ui_handle(__ID__); - if (h_show_asset_names.init) { - h_show_asset_names.b = config_raw.show_asset_names; - } - config_raw.show_asset_names = ui_check(h_show_asset_names, tr("Show Asset Names")); - if (ui.changed) { - base_redraw_ui(); - } - - ///if !(arm_android || arm_ios) - ui.changed = false; - let h_touch_ui: ui_handle_t = ui_handle(__ID__); - if (h_touch_ui.init) { - h_touch_ui.b = config_raw.touch_ui; - } - config_raw.touch_ui = ui_check(h_touch_ui, tr("Touch UI")); - if (ui.changed) { - ui_touch_scroll = config_raw.touch_ui; - ui_touch_hold = config_raw.touch_ui; - ui_touch_tooltip = config_raw.touch_ui; - config_load_theme(config_raw.theme); - box_preferences_set_scale(); - base_redraw_ui(); - } - ///end - - let h_splash_screen: ui_handle_t = ui_handle(__ID__); - if (h_splash_screen.init) { - h_splash_screen.b = config_raw.splash_screen; - } - config_raw.splash_screen = ui_check(h_splash_screen, tr("Splash Screen")); - - let h_grid_snap: ui_handle_t = ui_handle(__ID__); - if (h_grid_snap.init) { - h_grid_snap.b = config_raw.grid_snap; - } - config_raw.grid_snap = ui_check(h_grid_snap, tr("Grid Snap")); - ui_nodes_grid_snap = config_raw.grid_snap; - - ui_end_element(); - - ui_row2(); - if (ui_button(tr("Restore")) && !ui_menu_show) { - ui_menu_draw(function () { - if (ui_menu_button(tr("Confirm"))) { - sys_notify_on_next_frame(function () { - ui.ops.theme.ELEMENT_H = base_default_element_h; - config_restore(); - box_preferences_set_scale(); - if (config_raw.plugins != null) { - for (let i: i32 = 0; i < config_raw.plugins.length; ++i) { - let f: string = config_raw.plugins[i]; - plugin_stop(f); - } - } - box_preferences_files_plugin = null; - box_preferences_files_keymap = null; - make_material_parse_mesh_material(); - make_material_parse_paint_material(); - ui_base_set_viewport_col(ui.ops.theme.VIEWPORT_COL); - }); - } - if (ui_menu_button(tr("Import..."))) { - ui_files_show("json", false, false, function (path: string) { - let b: buffer_t = data_get_blob(path); - let raw: config_t = json_parse(sys_buffer_to_string(b)); - sys_notify_on_next_frame(function (raw: config_t) { - ui.ops.theme.ELEMENT_H = base_default_element_h; - config_import_from(raw); - box_preferences_set_scale(); - make_material_parse_mesh_material(); - make_material_parse_paint_material(); - }, raw); - }); - } - }); - } - if (ui_button(tr("Reset Layout")) && !ui_menu_show) { - ui_menu_draw(function () { - if (ui_menu_button(tr("Confirm"))) { - base_init_layout(); - config_save(); - } - }); - } + let hscale: ui_handle_t = ui_handle(__ID__); + if (hscale.init) { + hscale.f = config_raw.window_scale; + } + ui_slider(hscale, tr("UI Scale"), 1.0, 4.0, true, 10); + if (context_raw.hscale_was_changed && !ui.input_down) { + context_raw.hscale_was_changed = false; + if (hscale.f == 0.0) { + hscale.f = 1.0; } + config_raw.window_scale = hscale.f; + box_preferences_set_scale(); + } + if (hscale.changed) { + context_raw.hscale_was_changed = true; + } - if (ui_tab(box_preferences_htab, tr("Theme"), true)) { - - if (box_preferences_themes == null) { - box_preferences_fetch_themes(); - } - box_preferences_theme_handle = ui_handle(__ID__); - if (box_preferences_theme_handle.init) { - box_preferences_theme_handle.i = box_preferences_get_theme_index(); - } - - ui_begin_sticky(); - ui_row4(); - - ui_combo(box_preferences_theme_handle, box_preferences_themes, tr("Theme")); - if (box_preferences_theme_handle.changed) { - config_raw.theme = box_preferences_themes[box_preferences_theme_handle.i] + ".json"; - config_load_theme(config_raw.theme); - } - - if (ui_button(tr("New"))) { - ui_box_show_custom(function () { - if (ui_tab(ui_handle(__ID__), tr("New Theme"))) { - ui_row2(); - let h: ui_handle_t = ui_handle(__ID__); - if (h.init) { - h.text = "new_theme"; - } - let theme_name: string = ui_text_input(h, tr("Name")); - if (ui_button(tr("OK")) || ui.is_return_down) { - let template: string = box_preferences_theme_to_json(base_theme); - if (!ends_with(theme_name, ".json")) { - theme_name += ".json"; - } - let path: string = path_data() + path_sep + "themes" + path_sep + theme_name; - iron_file_save_bytes(path, sys_string_to_buffer(template), 0); - box_preferences_fetch_themes(); // Refresh file list - config_raw.theme = theme_name; - box_preferences_theme_handle.i = box_preferences_get_theme_index(); - ui_box_hide(); - box_preferences_htab.i = 1; // Themes - box_preferences_show(); - } - } - }); - } - - if (ui_button(tr("Import"))) { - ui_files_show("json", false, false, function (path: string) { - import_theme_run(path); - }); - } - - if (ui_button(tr("Export"))) { - ui_files_show("json", true, false, function (path: string) { - path += path_sep; - path += ui_files_filename; - if (!ends_with(path, ".json")) { - path += ".json"; - } - iron_file_save_bytes(path, sys_string_to_buffer(box_preferences_theme_to_json(base_theme)), 0); - }); - } - - ui_end_sticky(); - - // Theme fields - let hlist: ui_handle_t = ui_handle(__ID__); - let u32_theme: u32_ptr = base_theme; - ui.input_enabled = !ui_menu_show; - for (let i: i32 = 0; i < ui_theme_keys_count; ++i) { - let key: string = ARRAY_ACCESS(ui_theme_keys, i); - let h: ui_handle_t = ui_nest(hlist, i); - let val: u32 = DEREFERENCE(u32_theme + i); - let is_hex: bool = ends_with(key, "_COL"); - - if (is_hex) { - let row: f32[] = [1 / 8, 7 / 8]; - ui_row(row); - ui_text("", 0, val); - if (ui.is_hovered && ui.input_released) { - h.color = val; - _box_preferences_h = h; - _box_preferences_i = i; - ui_menu_draw(function () { - ui.changed = false; - let color: i32 = ui_color_wheel(_box_preferences_h, false, -1, 11 * ui.ops.theme.ELEMENT_H * UI_SCALE(), true); - let u32_theme: u32_ptr = base_theme; - DEREFERENCE(u32_theme + _box_preferences_i) = color; - if (ui.changed) { - ui_menu_keep_open = true; - } - }); - } - - if (key == "VIEWPORT_COL" && ui_base_viewport_col != val) { - ui_base_set_viewport_col(val); - } - } - - ui.changed = false; - - if (key == "FILL_WINDOW_BG" || - key == "FILL_BUTTON_BG" || - key == "FULL_TABS" || - key == "ROUND_CORNERS" || - key == "SHADOWS") { - h.b = val > 0; - let b: bool = ui_check(h, key); - DEREFERENCE(u32_theme + i) = b; - } - else if (key == "LINK_STYLE") { - let styles: string[] = [tr("Straight"), tr("Curved")]; - h.i = val; - let pos: i32 = ui_combo(h, styles, key, true); - DEREFERENCE(u32_theme + i) = pos; + let h_node_previews: ui_handle_t = ui_handle(__ID__); + if (h_node_previews.init) { + h_node_previews.b = config_raw.node_previews; + } + config_raw.node_previews = ui_check(h_node_previews, tr("Node Previews")); + if (h_node_previews.changed) { + for (let i: i32 = 0; i < project_materials.length; ++i) { + let c: ui_node_canvas_t = project_materials[i].canvas; + for (let j: i32 = 0; j < c.nodes.length; ++j) { + let n: ui_node_t = c.nodes[j]; + if (config_raw.node_previews) { + n.flags |= _ui_node_flag_t.PREVIEW; } else { - h.text = is_hex ? i32_to_string_hex(val) : i32_to_string(val); - ui_text_input(h, key); - if (is_hex) { - DEREFERENCE(u32_theme + i) = parse_int_hex(h.text); - } - else { - DEREFERENCE(u32_theme + i) = parse_int(h.text); - } - } - - if (ui.changed) { - ui.elements_baked = false; + n.flags &= ~_ui_node_flag_t.PREVIEW; } } - ui.input_enabled = true; } + ui_nodes_hwnd.redraws = 2; + } + if (ui.is_hovered) { + ui_tooltip(tr("Show node preview on each node by default")); + } - if (ui_tab(box_preferences_htab, tr("Usage"), true)) { - context_raw.undo_handle = ui_handle(__ID__); - if (context_raw.undo_handle.init) { - context_raw.undo_handle.f = config_raw.undo_steps; - } - config_raw.undo_steps = math_floor(ui_slider(context_raw.undo_handle, tr("Undo Steps"), 1, 64, false, 1)); - if (config_raw.undo_steps < 1) { - config_raw.undo_steps = context_raw.undo_handle.f = 1; - } - if (context_raw.undo_handle.changed) { - let current: gpu_texture_t = _draw_current; - draw_end(); + let h_wrap_mouse: ui_handle_t = ui_handle(__ID__); + if (h_wrap_mouse.init) { + h_wrap_mouse.b = config_raw.wrap_mouse; + } + config_raw.wrap_mouse = ui_check(h_wrap_mouse, tr("Wrap Mouse")); + if (ui.is_hovered) { + ui_tooltip(tr("Wrap mouse around view boundaries during camera control")); + } - if (history_undo_layers != null) { - while (history_undo_layers.length < config_raw.undo_steps) { - let len: i32 = history_undo_layers.length; - let l: slot_layer_t = slot_layer_create("_undo" + len); - array_push(history_undo_layers, l); - } - while (history_undo_layers.length > config_raw.undo_steps) { - let l: slot_layer_t = array_pop(history_undo_layers); - slot_layer_unload(l); - } - } + ui.changed = false; + let h_show_asset_names: ui_handle_t = ui_handle(__ID__); + if (h_show_asset_names.init) { + h_show_asset_names.b = config_raw.show_asset_names; + } + config_raw.show_asset_names = ui_check(h_show_asset_names, tr("Show Asset Names")); + if (ui.changed) { + base_redraw_ui(); + } - history_reset(); - draw_begin(current); - } + ///if !(arm_android || arm_ios) + ui.changed = false; + let h_touch_ui: ui_handle_t = ui_handle(__ID__); + if (h_touch_ui.init) { + h_touch_ui.b = config_raw.touch_ui; + } + config_raw.touch_ui = ui_check(h_touch_ui, tr("Touch UI")); + if (ui.changed) { + ui_touch_scroll = config_raw.touch_ui; + ui_touch_hold = config_raw.touch_ui; + ui_touch_tooltip = config_raw.touch_ui; + config_load_theme(config_raw.theme); + box_preferences_set_scale(); + base_redraw_ui(); + } + ///end - let h_dilate_radius: ui_handle_t = ui_handle(__ID__); - if (h_dilate_radius.init) { - h_dilate_radius.f = config_raw.dilate_radius; - } - config_raw.dilate_radius = math_floor(ui_slider(h_dilate_radius, tr("Dilate Radius"), 0.0, 16.0, true, 1)); - if (ui.is_hovered) { - ui_tooltip(tr("Dilate painted textures to prevent seams")); - } + let h_splash_screen: ui_handle_t = ui_handle(__ID__); + if (h_splash_screen.init) { + h_splash_screen.b = config_raw.splash_screen; + } + config_raw.splash_screen = ui_check(h_splash_screen, tr("Splash Screen")); - let camera_controls_handle: ui_handle_t = ui_handle(__ID__); - if (camera_controls_handle.init) { - camera_controls_handle.i = config_raw.camera_controls; - } - let camera_controls_combo: string[] = [tr("Orbit"), tr("Rotate"), tr("Fly")]; - ui_combo(camera_controls_handle, camera_controls_combo, tr("Default Camera Controls"), true); - if (camera_controls_handle.changed) { - config_raw.camera_controls = camera_controls_handle.i; - } + let h_grid_snap: ui_handle_t = ui_handle(__ID__); + if (h_grid_snap.init) { + h_grid_snap.b = config_raw.grid_snap; + } + config_raw.grid_snap = ui_check(h_grid_snap, tr("Grid Snap")); + ui_nodes_grid_snap = config_raw.grid_snap; - let hspeed: ui_handle_t = ui_handle(__ID__); - if (hspeed.init) { - hspeed.f = config_raw.camera_zoom_speed; - } - config_raw.camera_zoom_speed = ui_slider(hspeed, tr("Camera Zoom Speed"), 0.1, 4.0, true); + ui_end_element(); - hspeed = ui_handle(__ID__); - if (hspeed.init) { - hspeed.f = config_raw.camera_rotation_speed; - } - config_raw.camera_rotation_speed = ui_slider(hspeed, tr("Camera Rotation Speed"), 0.1, 4.0, true); - - hspeed = ui_handle(__ID__); - if (hspeed.init) { - hspeed.f = config_raw.camera_pan_speed; - } - config_raw.camera_pan_speed = ui_slider(hspeed, tr("Camera Pan Speed"), 0.1, 4.0, true); - - let zoom_direction_handle: ui_handle_t = ui_handle(__ID__); - if (zoom_direction_handle.init) { - zoom_direction_handle.i = config_raw.zoom_direction; - } - let zoom_direction_combo: string[] = [tr("Vertical"), tr("Vertical Inverted"), tr("Horizontal"), tr("Horizontal Inverted"), tr("Vertical and Horizontal"), tr("Vertical and Horizontal Inverted")]; - ui_combo(zoom_direction_handle, zoom_direction_combo, tr("Direction to Zoom"), true); - if (zoom_direction_handle.changed) { - config_raw.zoom_direction = zoom_direction_handle.i; - } - - let layer_res_handle: ui_handle_t = ui_handle(__ID__); - if (layer_res_handle.init) { - layer_res_handle.i = config_raw.layer_res; - } - - ///if (arm_android || arm_ios) - let res_combo: string[] = ["128", "256", "512", "1K", "2K", "4K"]; - ///else - let res_combo: string[] = ["128", "256", "512", "1K", "2K", "4K", "8K", "16K"]; - ///end - - ui_combo(layer_res_handle, res_combo, tr("Default Layer Resolution"), true); - if (layer_res_handle.changed) { - config_raw.layer_res = layer_res_handle.i; - } - - let scene_atlas_res_handle: ui_handle_t = ui_handle(__ID__); - if (scene_atlas_res_handle.init) { - scene_atlas_res_handle.i = config_raw.scene_atlas_res; - } - - ui_combo(scene_atlas_res_handle, res_combo, tr("Scene Atlas Resolution"), true); - if (scene_atlas_res_handle.changed) { - config_raw.scene_atlas_res = scene_atlas_res_handle.i; - } - - let server_handle: ui_handle_t = ui_handle(__ID__); - if (server_handle.init) { - server_handle.text = config_raw.server; - } - config_raw.server = ui_text_input(server_handle, tr("Cloud Server")); - - let material_live_handle: ui_handle_t = ui_handle(__ID__); - if (material_live_handle.init) { - material_live_handle.b = config_raw.material_live; - } - config_raw.material_live = ui_check(material_live_handle, tr("Live Material Preview")); - if (ui.is_hovered) { - ui_tooltip(tr("Instantly update material preview on node change")); - } - - let brush_live_handle: ui_handle_t = ui_handle(__ID__); - if (brush_live_handle.init) { - brush_live_handle.b = config_raw.brush_live; - } - config_raw.brush_live = ui_check(brush_live_handle, tr("Live Brush Preview")); - if (ui.is_hovered) { - ui_tooltip(tr("Draw live brush preview in viewport")); - } - if (brush_live_handle.changed) { - context_raw.ddirty = 2; - } - - let brush_depth_reject_handle: ui_handle_t = ui_handle(__ID__); - if (brush_depth_reject_handle.init) { - brush_depth_reject_handle.b = config_raw.brush_depth_reject; - } - config_raw.brush_depth_reject = ui_check(brush_depth_reject_handle, tr("Depth Reject")); - if (brush_depth_reject_handle.changed) { - make_material_parse_paint_material(); - } - - ui_row2(); - - let brush_angle_reject_handle: ui_handle_t = ui_handle(__ID__); - if (brush_angle_reject_handle.init) { - brush_angle_reject_handle.b = config_raw.brush_angle_reject; - } - config_raw.brush_angle_reject = ui_check(brush_angle_reject_handle, tr("Angle Reject")); - if (brush_angle_reject_handle.changed) { - make_material_parse_paint_material(); - } - - if (!config_raw.brush_angle_reject) { - ui.enabled = false; - } - let angle_dot_handle: ui_handle_t = ui_handle(__ID__); - if (angle_dot_handle.init) { - angle_dot_handle.f = context_raw.brush_angle_reject_dot; - } - context_raw.brush_angle_reject_dot = ui_slider(angle_dot_handle, tr("Angle"), 0.0, 1.0, true); - if (angle_dot_handle.changed) { - make_material_parse_paint_material(); - } - ui.enabled = true; - - let h_gpu_inference: ui_handle_t = ui_handle(__ID__); - if (h_gpu_inference.init) { - h_gpu_inference.b = config_raw.gpu_inference; - } - config_raw.gpu_inference = ui_check(h_gpu_inference, tr("GPU Inference")); - if (ui.is_hovered) { - ui_tooltip(tr("Use GPU to accelerate neural node processing")); - } - } - - let pen_name: string; - ///if arm_ios - pen_name = tr("Pencil"); - ///else - pen_name = tr("Pen"); - ///end - - if (ui_tab(box_preferences_htab, pen_name, true)) { - ui_text(tr("Pressure controls")); - let h_pressure_radius: ui_handle_t = ui_handle(__ID__); - if (h_pressure_radius.init) { - h_pressure_radius.b = config_raw.pressure_radius; - } - config_raw.pressure_radius = ui_check(h_pressure_radius, tr("Brush Radius")); - - let h_pressure_sensitivity: ui_handle_t = ui_handle(__ID__); - if (h_pressure_sensitivity.init) { - h_pressure_sensitivity.f = config_raw.pressure_sensitivity; - } - config_raw.pressure_sensitivity = ui_slider(h_pressure_sensitivity, tr("Sensitivity"), 0.0, 10.0, true); - - let h_pressure_hardness: ui_handle_t = ui_handle(__ID__); - if (h_pressure_hardness.init) { - h_pressure_hardness.b = config_raw.pressure_hardness; - } - config_raw.pressure_hardness = ui_check(h_pressure_hardness, tr("Brush Hardness")); - - let h_pressure_opacity: ui_handle_t = ui_handle(__ID__); - if (h_pressure_opacity.init) { - h_pressure_opacity.b = config_raw.pressure_opacity; - } - config_raw.pressure_opacity = ui_check(h_pressure_opacity, tr("Brush Opacity")); - - let h_pressure_angle: ui_handle_t = ui_handle(__ID__); - if (h_pressure_angle.init) { - h_pressure_angle.b = config_raw.pressure_angle; - } - config_raw.pressure_angle = ui_check(h_pressure_angle, tr("Brush Angle")); - - ui_end_element(); - let row: f32[] = [0.5]; - ui_row(row); - if (ui_button(tr("Help"))) { - let url: string = "https://github.com/armory3d/"; - let name: string = to_lower_case(manifest_title); - url += name; - url += "_docs#pen"; - iron_load_url(url); - } - } - - context_raw.hssao = ui_handle(__ID__); - if (context_raw.hssao.init) { - context_raw.hssao.b = config_raw.rp_ssao; - } - - context_raw.hbloom = ui_handle(__ID__); - if (context_raw.hbloom.init) { - context_raw.hbloom.b = config_raw.rp_bloom; - } - - context_raw.hsupersample = ui_handle(__ID__); - if (context_raw.hsupersample.init) { - context_raw.hsupersample.i = config_get_super_sample_quality(config_raw.rp_supersample); - } - - if (ui_tab(box_preferences_htab, tr("Viewport"), true)) { - - let mode_handle: ui_handle_t = ui_handle(__ID__); - if (mode_handle.init) { - mode_handle.i = config_raw.viewport_mode; - } - let mode_combo: string[] = [tr("Lit"), tr("Path Traced")]; - ui_combo(mode_handle, mode_combo, tr("Default Mode"), true); - if (mode_handle.changed) { - config_raw.viewport_mode = mode_handle.i; - } - - let hpathtrace_mode: ui_handle_t = ui_handle(__ID__); - if (hpathtrace_mode.init) { - hpathtrace_mode.i = config_raw.pathtrace_mode; - } - let pathtrace_mode_combo: string[] = [tr("Fast"), tr("Quality")]; - config_raw.pathtrace_mode = ui_combo(hpathtrace_mode, pathtrace_mode_combo, tr("Path Tracer"), true); - if (hpathtrace_mode.changed) { - render_path_raytrace_ready = false; - render_path_raytrace_init_shader = true; - context_raw.ddirty = 2; - } - - let hrender_mode: ui_handle_t = ui_handle(__ID__); - if (hrender_mode.init) { - hrender_mode.i = context_raw.render_mode; - } - let render_mode_combo: string[] = [tr("Desktop"), tr("Mobile")]; - context_raw.render_mode = ui_combo(hrender_mode, render_mode_combo, tr("Renderer"), true); - if (hrender_mode.changed) { - context_set_render_path(); - } - - let supersample_combo: string[] = ["0.25x", "0.5x", "1.0x", "1.5x", "2.0x", "4.0x"]; - ui_combo(context_raw.hsupersample, supersample_combo, tr("Super Sample"), true); - if (context_raw.hsupersample.changed) { - config_apply(); - } - - if (context_raw.render_mode == render_mode_t.DEFERRED) { - ui_check(context_raw.hssao, tr("SSAO")); - if (context_raw.hssao.changed) { - config_apply(); - } - ui_check(context_raw.hbloom, tr("Bloom")); - if (context_raw.hbloom.changed) { - config_apply(); - } - } - - let h: ui_handle_t = ui_handle(__ID__); - if (h.init) { - h.f = config_raw.rp_vignette; - } - config_raw.rp_vignette = ui_slider(h, tr("Vignette"), 0.0, 1.0, true); - if (h.changed) { - context_raw.ddirty = 2; - } - - h = ui_handle(__ID__); - if (h.init) { - h.f = config_raw.rp_grain; - } - config_raw.rp_grain = ui_slider(h, tr("Noise Grain"), 0.0, 1.0, true); - if (h.changed) { - context_raw.ddirty = 2; - } - - // let h: ui_handle_t = ui_handle("boxpreferences_46", { f: raw.auto_exposure_strength }); - // raw.auto_exposure_strength = ui_slider(h, "Auto Exposure", 0.0, 2.0, true); - // if (h.changed) raw.ddirty = 2; - - let cam: camera_object_t = scene_camera; - let cam_raw: camera_data_t = cam.data; - let near_handle: ui_handle_t = ui_handle(__ID__); - let far_handle: ui_handle_t = ui_handle(__ID__); - near_handle.f = math_floor(cam_raw.near_plane * 1000) / 1000; - far_handle.f = math_floor(cam_raw.far_plane * 100) / 100; - cam_raw.near_plane = ui_slider(near_handle, tr("Clip Start"), 0.001, 1.0, true); - cam_raw.far_plane = ui_slider(far_handle, tr("Clip End"), 50.0, 100.0, true); - if (near_handle.changed || far_handle.changed) { - camera_object_build_proj(cam); - } - - let disp_handle: ui_handle_t = ui_handle(__ID__); - if (disp_handle.init) { - disp_handle.f = config_raw.displace_strength; - } - config_raw.displace_strength = ui_slider(disp_handle, tr("Displacement Strength"), 0.0, 10.0, true); - if (disp_handle.changed) { - context_raw.ddirty = 2; - make_material_parse_mesh_material(); - } - } - if (ui_tab(box_preferences_htab, tr("Keymap"), true)) { - - if (box_preferences_files_keymap == null) { - box_preferences_fetch_keymaps(); - } - - ui_begin_sticky(); - ui_row4(); - - box_preferences_preset_handle = ui_handle(__ID__); - if (box_preferences_preset_handle.init) { - box_preferences_preset_handle.i = box_preferences_get_preset_index(); - } - ui_combo(box_preferences_preset_handle, box_preferences_files_keymap, tr("Preset")); - if (box_preferences_preset_handle.changed) { - config_raw.keymap = box_preferences_files_keymap[box_preferences_preset_handle.i] + ".json"; - config_apply(); - keymap_load(); - } - - if (ui_button(tr("New"))) { - ui_box_show_custom(function () { - if (ui_tab(ui_handle(__ID__), tr("New Keymap"))) { - ui_row2(); - let h: ui_handle_t = ui_handle(__ID__); - if (h.init) { - h.text = "new_keymap"; - } - let keymap_name: string = ui_text_input(h, tr("Name")); - if (ui_button(tr("OK")) || ui.is_return_down) { - let template: string = keymap_to_json(keymap_get_default()); - if (!ends_with(keymap_name, ".json")) { - keymap_name += ".json"; - } - let path: string = path_data() + path_sep + "keymap_presets" + path_sep + keymap_name; - iron_file_save_bytes(path, sys_string_to_buffer(template), 0); - box_preferences_fetch_keymaps(); // Refresh file list - config_raw.keymap = keymap_name; - box_preferences_preset_handle.i = box_preferences_get_preset_index(); - ui_box_hide(); - box_preferences_htab.i = 5; // Keymap - box_preferences_show(); + ui_row2(); + if (ui_button(tr("Restore")) && !ui_menu_show) { + ui_menu_draw(function () { + if (ui_menu_button(tr("Confirm"))) { + sys_notify_on_next_frame(function () { + ui.ops.theme.ELEMENT_H = base_default_element_h; + config_restore(); + box_preferences_set_scale(); + if (config_raw.plugins != null) { + for (let i: i32 = 0; i < config_raw.plugins.length; ++i) { + let f: string = config_raw.plugins[i]; + plugin_stop(f); } } + box_preferences_files_plugin = null; + box_preferences_files_keymap = null; + make_material_parse_mesh_material(); + make_material_parse_paint_material(); + ui_base_set_viewport_col(ui.ops.theme.VIEWPORT_COL); }); } - - if (ui_button(tr("Import"))) { + if (ui_menu_button(tr("Import..."))) { ui_files_show("json", false, false, function (path: string) { - import_keymap_run(path); + let b: buffer_t = data_get_blob(path); + let raw: config_t = json_parse(sys_buffer_to_string(b)); + sys_notify_on_next_frame(function (raw: config_t) { + ui.ops.theme.ELEMENT_H = base_default_element_h; + config_import_from(raw); + box_preferences_set_scale(); + make_material_parse_mesh_material(); + make_material_parse_paint_material(); + }, raw); }); } - if (ui_button(tr("Export"))) { - ui_files_show("json", true, false, function (dest: string) { - if (!ends_with(ui_files_filename, ".json")) { - ui_files_filename += ".json"; + }); + } + if (ui_button(tr("Reset Layout")) && !ui_menu_show) { + ui_menu_draw(function () { + if (ui_menu_button(tr("Confirm"))) { + base_init_layout(); + config_save(); + } + }); + } +} + +function box_preferences_theme_tab() { + if (box_preferences_themes == null) { + box_preferences_fetch_themes(); + } + box_preferences_theme_handle = ui_handle(__ID__); + if (box_preferences_theme_handle.init) { + box_preferences_theme_handle.i = box_preferences_get_theme_index(); + } + + ui_begin_sticky(); + ui_row4(); + + ui_combo(box_preferences_theme_handle, box_preferences_themes, tr("Theme")); + if (box_preferences_theme_handle.changed) { + config_raw.theme = box_preferences_themes[box_preferences_theme_handle.i] + ".json"; + config_load_theme(config_raw.theme); + } + + if (ui_button(tr("New"))) { + ui_box_show_custom(function () { + if (ui_tab(ui_handle(__ID__), tr("New Theme"))) { + ui_row2(); + let h: ui_handle_t = ui_handle(__ID__); + if (h.init) { + h.text = "new_theme"; + } + let theme_name: string = ui_text_input(h, tr("Name")); + if (ui_button(tr("OK")) || ui.is_return_down) { + let template: string = box_preferences_theme_to_json(base_theme); + if (!ends_with(theme_name, ".json")) { + theme_name += ".json"; + } + let path: string = path_data() + path_sep + "themes" + path_sep + theme_name; + iron_file_save_bytes(path, sys_string_to_buffer(template), 0); + box_preferences_fetch_themes(); // Refresh file list + config_raw.theme = theme_name; + box_preferences_theme_handle.i = box_preferences_get_theme_index(); + ui_box_hide(); + box_preferences_htab.i = 1; // Themes + box_preferences_show(); + } + } + }); + } + + if (ui_button(tr("Import"))) { + ui_files_show("json", false, false, function (path: string) { + import_theme_run(path); + }); + } + + if (ui_button(tr("Export"))) { + ui_files_show("json", true, false, function (path: string) { + path += path_sep; + path += ui_files_filename; + if (!ends_with(path, ".json")) { + path += ".json"; + } + iron_file_save_bytes(path, sys_string_to_buffer(box_preferences_theme_to_json(base_theme)), 0); + }); + } + + ui_end_sticky(); + + // Theme fields + let hlist: ui_handle_t = ui_handle(__ID__); + let u32_theme: u32_ptr = base_theme; + ui.input_enabled = !ui_menu_show; + for (let i: i32 = 0; i < ui_theme_keys_count; ++i) { + let key: string = ARRAY_ACCESS(ui_theme_keys, i); + let h: ui_handle_t = ui_nest(hlist, i); + let val: u32 = DEREFERENCE(u32_theme + i); + let is_hex: bool = ends_with(key, "_COL"); + + if (is_hex) { + let row: f32[] = [1 / 8, 7 / 8]; + ui_row(row); + ui_text("", 0, val); + if (ui.is_hovered && ui.input_released) { + h.color = val; + _box_preferences_h = h; + _box_preferences_i = i; + ui_menu_draw(function () { + ui.changed = false; + let color: i32 = ui_color_wheel(_box_preferences_h, false, -1, 11 * ui.ops.theme.ELEMENT_H * UI_SCALE(), true); + let u32_theme: u32_ptr = base_theme; + DEREFERENCE(u32_theme + _box_preferences_i) = color; + if (ui.changed) { + ui_menu_keep_open = true; } - let path: string = path_data() + path_sep + "keymap_presets" + path_sep + config_raw.keymap; - file_copy(path, dest + path_sep + ui_files_filename); }); } - ui_end_sticky(); - - ui_separator(8, false); - - let index: i32 = 0; - ui.changed = false; - let keys: string[] = map_keys(config_keymap); - array_sort(keys, null); - for (let i: i32 = 0; i < keys.length; ++i) { - let key: string = keys[i]; - let h: ui_handle_t = ui_nest(ui_handle(__ID__), index++); - h.text = map_get(config_keymap, key); - let text: string = ui_text_input(h, key, ui_align_t.LEFT); - map_set(config_keymap, key, text); - } - if (ui.changed) { - config_apply(); - keymap_save(); + if (key == "VIEWPORT_COL" && ui_base_viewport_col != val) { + ui_base_set_viewport_col(val); } } - if (ui_tab(box_preferences_htab, tr("Plugins"), true)) { - ui_begin_sticky(); - let row: f32[] = [1 / 4, 1 / 4]; - ui_row(row); - if (ui_button(tr("New"))) { - ui_box_show_custom(function () { - if (ui_tab(ui_handle(__ID__), tr("New Plugin"))) { - ui_row2(); - let h: ui_handle_t = ui_handle(__ID__); - if (h.init) { - h.text = "new_plugin"; - } - let plugin_name: string = ui_text_input(h, tr("Name")); - if (ui_button(tr("OK")) || ui.is_return_down) { - let template: string = + + ui.changed = false; + + if (key == "FILL_WINDOW_BG" || + key == "FILL_BUTTON_BG" || + key == "FULL_TABS" || + key == "ROUND_CORNERS" || + key == "SHADOWS") { + h.b = val > 0; + let b: bool = ui_check(h, key); + DEREFERENCE(u32_theme + i) = b; + } + else if (key == "LINK_STYLE") { + let styles: string[] = [tr("Straight"), tr("Curved")]; + h.i = val; + let pos: i32 = ui_combo(h, styles, key, true); + DEREFERENCE(u32_theme + i) = pos; + } + else { + h.text = is_hex ? i32_to_string_hex(val) : i32_to_string(val); + ui_text_input(h, key); + if (is_hex) { + DEREFERENCE(u32_theme + i) = parse_int_hex(h.text); + } + else { + DEREFERENCE(u32_theme + i) = parse_int(h.text); + } + } + + if (ui.changed) { + ui.elements_baked = false; + } + } + ui.input_enabled = true; +} + +function box_preferences_usage_tab() { + context_raw.undo_handle = ui_handle(__ID__); + if (context_raw.undo_handle.init) { + context_raw.undo_handle.f = config_raw.undo_steps; + } + config_raw.undo_steps = math_floor(ui_slider(context_raw.undo_handle, tr("Undo Steps"), 1, 64, false, 1)); + if (config_raw.undo_steps < 1) { + config_raw.undo_steps = context_raw.undo_handle.f = 1; + } + if (context_raw.undo_handle.changed) { + let current: gpu_texture_t = _draw_current; + draw_end(); + + if (history_undo_layers != null) { + while (history_undo_layers.length < config_raw.undo_steps) { + let len: i32 = history_undo_layers.length; + let l: slot_layer_t = slot_layer_create("_undo" + len); + array_push(history_undo_layers, l); + } + while (history_undo_layers.length > config_raw.undo_steps) { + let l: slot_layer_t = array_pop(history_undo_layers); + slot_layer_unload(l); + } + } + + history_reset(); + draw_begin(current); + } + + let h_dilate_radius: ui_handle_t = ui_handle(__ID__); + if (h_dilate_radius.init) { + h_dilate_radius.f = config_raw.dilate_radius; + } + config_raw.dilate_radius = math_floor(ui_slider(h_dilate_radius, tr("Dilate Radius"), 0.0, 16.0, true, 1)); + if (ui.is_hovered) { + ui_tooltip(tr("Dilate painted textures to prevent seams")); + } + + let camera_controls_handle: ui_handle_t = ui_handle(__ID__); + if (camera_controls_handle.init) { + camera_controls_handle.i = config_raw.camera_controls; + } + let camera_controls_combo: string[] = [tr("Orbit"), tr("Rotate"), tr("Fly")]; + ui_combo(camera_controls_handle, camera_controls_combo, tr("Default Camera Controls"), true); + if (camera_controls_handle.changed) { + config_raw.camera_controls = camera_controls_handle.i; + } + + let hspeed: ui_handle_t = ui_handle(__ID__); + if (hspeed.init) { + hspeed.f = config_raw.camera_zoom_speed; + } + config_raw.camera_zoom_speed = ui_slider(hspeed, tr("Camera Zoom Speed"), 0.1, 4.0, true); + + hspeed = ui_handle(__ID__); + if (hspeed.init) { + hspeed.f = config_raw.camera_rotation_speed; + } + config_raw.camera_rotation_speed = ui_slider(hspeed, tr("Camera Rotation Speed"), 0.1, 4.0, true); + + hspeed = ui_handle(__ID__); + if (hspeed.init) { + hspeed.f = config_raw.camera_pan_speed; + } + config_raw.camera_pan_speed = ui_slider(hspeed, tr("Camera Pan Speed"), 0.1, 4.0, true); + + let zoom_direction_handle: ui_handle_t = ui_handle(__ID__); + if (zoom_direction_handle.init) { + zoom_direction_handle.i = config_raw.zoom_direction; + } + let zoom_direction_combo: string[] = [tr("Vertical"), tr("Vertical Inverted"), tr("Horizontal"), tr("Horizontal Inverted"), tr("Vertical and Horizontal"), tr("Vertical and Horizontal Inverted")]; + ui_combo(zoom_direction_handle, zoom_direction_combo, tr("Direction to Zoom"), true); + if (zoom_direction_handle.changed) { + config_raw.zoom_direction = zoom_direction_handle.i; + } + + let layer_res_handle: ui_handle_t = ui_handle(__ID__); + if (layer_res_handle.init) { + layer_res_handle.i = config_raw.layer_res; + } + + ///if (arm_android || arm_ios) + let res_combo: string[] = ["128", "256", "512", "1K", "2K", "4K"]; + ///else + let res_combo: string[] = ["128", "256", "512", "1K", "2K", "4K", "8K", "16K"]; + ///end + + ui_combo(layer_res_handle, res_combo, tr("Default Layer Resolution"), true); + if (layer_res_handle.changed) { + config_raw.layer_res = layer_res_handle.i; + } + + let scene_atlas_res_handle: ui_handle_t = ui_handle(__ID__); + if (scene_atlas_res_handle.init) { + scene_atlas_res_handle.i = config_raw.scene_atlas_res; + } + + ui_combo(scene_atlas_res_handle, res_combo, tr("Scene Atlas Resolution"), true); + if (scene_atlas_res_handle.changed) { + config_raw.scene_atlas_res = scene_atlas_res_handle.i; + } + + let server_handle: ui_handle_t = ui_handle(__ID__); + if (server_handle.init) { + server_handle.text = config_raw.server; + } + config_raw.server = ui_text_input(server_handle, tr("Cloud Server")); + + let material_live_handle: ui_handle_t = ui_handle(__ID__); + if (material_live_handle.init) { + material_live_handle.b = config_raw.material_live; + } + config_raw.material_live = ui_check(material_live_handle, tr("Live Material Preview")); + if (ui.is_hovered) { + ui_tooltip(tr("Instantly update material preview on node change")); + } + + let brush_live_handle: ui_handle_t = ui_handle(__ID__); + if (brush_live_handle.init) { + brush_live_handle.b = config_raw.brush_live; + } + config_raw.brush_live = ui_check(brush_live_handle, tr("Live Brush Preview")); + if (ui.is_hovered) { + ui_tooltip(tr("Draw live brush preview in viewport")); + } + if (brush_live_handle.changed) { + context_raw.ddirty = 2; + } + + let brush_depth_reject_handle: ui_handle_t = ui_handle(__ID__); + if (brush_depth_reject_handle.init) { + brush_depth_reject_handle.b = config_raw.brush_depth_reject; + } + config_raw.brush_depth_reject = ui_check(brush_depth_reject_handle, tr("Depth Reject")); + if (brush_depth_reject_handle.changed) { + make_material_parse_paint_material(); + } + + ui_row2(); + + let brush_angle_reject_handle: ui_handle_t = ui_handle(__ID__); + if (brush_angle_reject_handle.init) { + brush_angle_reject_handle.b = config_raw.brush_angle_reject; + } + config_raw.brush_angle_reject = ui_check(brush_angle_reject_handle, tr("Angle Reject")); + if (brush_angle_reject_handle.changed) { + make_material_parse_paint_material(); + } + + if (!config_raw.brush_angle_reject) { + ui.enabled = false; + } + let angle_dot_handle: ui_handle_t = ui_handle(__ID__); + if (angle_dot_handle.init) { + angle_dot_handle.f = context_raw.brush_angle_reject_dot; + } + context_raw.brush_angle_reject_dot = ui_slider(angle_dot_handle, tr("Angle"), 0.0, 1.0, true); + if (angle_dot_handle.changed) { + make_material_parse_paint_material(); + } + ui.enabled = true; + + let h_gpu_inference: ui_handle_t = ui_handle(__ID__); + if (h_gpu_inference.init) { + h_gpu_inference.b = config_raw.gpu_inference; + } + config_raw.gpu_inference = ui_check(h_gpu_inference, tr("GPU Inference")); + if (ui.is_hovered) { + ui_tooltip(tr("Use GPU to accelerate neural node processing")); + } +} + +function box_preferences_pen_tab() { + ui_text(tr("Pressure controls")); + let h_pressure_radius: ui_handle_t = ui_handle(__ID__); + if (h_pressure_radius.init) { + h_pressure_radius.b = config_raw.pressure_radius; + } + config_raw.pressure_radius = ui_check(h_pressure_radius, tr("Brush Radius")); + + let h_pressure_sensitivity: ui_handle_t = ui_handle(__ID__); + if (h_pressure_sensitivity.init) { + h_pressure_sensitivity.f = config_raw.pressure_sensitivity; + } + config_raw.pressure_sensitivity = ui_slider(h_pressure_sensitivity, tr("Sensitivity"), 0.0, 10.0, true); + + let h_pressure_hardness: ui_handle_t = ui_handle(__ID__); + if (h_pressure_hardness.init) { + h_pressure_hardness.b = config_raw.pressure_hardness; + } + config_raw.pressure_hardness = ui_check(h_pressure_hardness, tr("Brush Hardness")); + + let h_pressure_opacity: ui_handle_t = ui_handle(__ID__); + if (h_pressure_opacity.init) { + h_pressure_opacity.b = config_raw.pressure_opacity; + } + config_raw.pressure_opacity = ui_check(h_pressure_opacity, tr("Brush Opacity")); + + let h_pressure_angle: ui_handle_t = ui_handle(__ID__); + if (h_pressure_angle.init) { + h_pressure_angle.b = config_raw.pressure_angle; + } + config_raw.pressure_angle = ui_check(h_pressure_angle, tr("Brush Angle")); + + ui_end_element(); + let row: f32[] = [0.5]; + ui_row(row); + if (ui_button(tr("Help"))) { + let url: string = "https://github.com/armory3d/"; + let name: string = to_lower_case(manifest_title); + url += name; + url += "_docs#pen"; + iron_load_url(url); + } +} + +function box_preferences_viewport_tab() { + context_raw.hssao = ui_handle(__ID__); + if (context_raw.hssao.init) { + context_raw.hssao.b = config_raw.rp_ssao; + } + + context_raw.hbloom = ui_handle(__ID__); + if (context_raw.hbloom.init) { + context_raw.hbloom.b = config_raw.rp_bloom; + } + + context_raw.hsupersample = ui_handle(__ID__); + if (context_raw.hsupersample.init) { + context_raw.hsupersample.i = config_get_super_sample_quality(config_raw.rp_supersample); + } + + let mode_handle: ui_handle_t = ui_handle(__ID__); + if (mode_handle.init) { + mode_handle.i = config_raw.viewport_mode; + } + let mode_combo: string[] = [tr("Lit"), tr("Path Traced")]; + ui_combo(mode_handle, mode_combo, tr("Default Mode"), true); + if (mode_handle.changed) { + config_raw.viewport_mode = mode_handle.i; + } + + let hpathtrace_mode: ui_handle_t = ui_handle(__ID__); + if (hpathtrace_mode.init) { + hpathtrace_mode.i = config_raw.pathtrace_mode; + } + let pathtrace_mode_combo: string[] = [tr("Fast"), tr("Quality")]; + config_raw.pathtrace_mode = ui_combo(hpathtrace_mode, pathtrace_mode_combo, tr("Path Tracer"), true); + if (hpathtrace_mode.changed) { + render_path_raytrace_ready = false; + render_path_raytrace_init_shader = true; + context_raw.ddirty = 2; + } + + let hrender_mode: ui_handle_t = ui_handle(__ID__); + if (hrender_mode.init) { + hrender_mode.i = context_raw.render_mode; + } + let render_mode_combo: string[] = [tr("Desktop"), tr("Mobile")]; + context_raw.render_mode = ui_combo(hrender_mode, render_mode_combo, tr("Renderer"), true); + if (hrender_mode.changed) { + context_set_render_path(); + } + + let supersample_combo: string[] = ["0.25x", "0.5x", "1.0x", "1.5x", "2.0x", "4.0x"]; + ui_combo(context_raw.hsupersample, supersample_combo, tr("Super Sample"), true); + if (context_raw.hsupersample.changed) { + config_apply(); + } + + if (context_raw.render_mode == render_mode_t.DEFERRED) { + ui_check(context_raw.hssao, tr("SSAO")); + if (context_raw.hssao.changed) { + config_apply(); + } + ui_check(context_raw.hbloom, tr("Bloom")); + if (context_raw.hbloom.changed) { + config_apply(); + } + } + + let h: ui_handle_t = ui_handle(__ID__); + if (h.init) { + h.f = config_raw.rp_vignette; + } + config_raw.rp_vignette = ui_slider(h, tr("Vignette"), 0.0, 1.0, true); + if (h.changed) { + context_raw.ddirty = 2; + } + + h = ui_handle(__ID__); + if (h.init) { + h.f = config_raw.rp_grain; + } + config_raw.rp_grain = ui_slider(h, tr("Noise Grain"), 0.0, 1.0, true); + if (h.changed) { + context_raw.ddirty = 2; + } + + // let h: ui_handle_t = ui_handle("boxpreferences_46", { f: raw.auto_exposure_strength }); + // raw.auto_exposure_strength = ui_slider(h, "Auto Exposure", 0.0, 2.0, true); + // if (h.changed) raw.ddirty = 2; + + let cam: camera_object_t = scene_camera; + let cam_raw: camera_data_t = cam.data; + let near_handle: ui_handle_t = ui_handle(__ID__); + let far_handle: ui_handle_t = ui_handle(__ID__); + near_handle.f = math_floor(cam_raw.near_plane * 1000) / 1000; + far_handle.f = math_floor(cam_raw.far_plane * 100) / 100; + cam_raw.near_plane = ui_slider(near_handle, tr("Clip Start"), 0.001, 1.0, true); + cam_raw.far_plane = ui_slider(far_handle, tr("Clip End"), 50.0, 100.0, true); + if (near_handle.changed || far_handle.changed) { + camera_object_build_proj(cam); + } + + let disp_handle: ui_handle_t = ui_handle(__ID__); + if (disp_handle.init) { + disp_handle.f = config_raw.displace_strength; + } + config_raw.displace_strength = ui_slider(disp_handle, tr("Displacement Strength"), 0.0, 10.0, true); + if (disp_handle.changed) { + context_raw.ddirty = 2; + make_material_parse_mesh_material(); + } +} + +function box_preferences_keymap_tab() { + if (box_preferences_files_keymap == null) { + box_preferences_fetch_keymaps(); + } + + ui_begin_sticky(); + ui_row4(); + + box_preferences_preset_handle = ui_handle(__ID__); + if (box_preferences_preset_handle.init) { + box_preferences_preset_handle.i = box_preferences_get_preset_index(); + } + ui_combo(box_preferences_preset_handle, box_preferences_files_keymap, tr("Preset")); + if (box_preferences_preset_handle.changed) { + config_raw.keymap = box_preferences_files_keymap[box_preferences_preset_handle.i] + ".json"; + config_apply(); + keymap_load(); + } + + if (ui_button(tr("New"))) { + ui_box_show_custom(function () { + if (ui_tab(ui_handle(__ID__), tr("New Keymap"))) { + ui_row2(); + let h: ui_handle_t = ui_handle(__ID__); + if (h.init) { + h.text = "new_keymap"; + } + let keymap_name: string = ui_text_input(h, tr("Name")); + if (ui_button(tr("OK")) || ui.is_return_down) { + let template: string = keymap_to_json(keymap_get_default()); + if (!ends_with(keymap_name, ".json")) { + keymap_name += ".json"; + } + let path: string = path_data() + path_sep + "keymap_presets" + path_sep + keymap_name; + iron_file_save_bytes(path, sys_string_to_buffer(template), 0); + box_preferences_fetch_keymaps(); // Refresh file list + config_raw.keymap = keymap_name; + box_preferences_preset_handle.i = box_preferences_get_preset_index(); + ui_box_hide(); + box_preferences_htab.i = 5; // Keymap + box_preferences_show(); + } + } + }); + } + + if (ui_button(tr("Import"))) { + ui_files_show("json", false, false, function (path: string) { + import_keymap_run(path); + }); + } + if (ui_button(tr("Export"))) { + ui_files_show("json", true, false, function (dest: string) { + if (!ends_with(ui_files_filename, ".json")) { + ui_files_filename += ".json"; + } + let path: string = path_data() + path_sep + "keymap_presets" + path_sep + config_raw.keymap; + file_copy(path, dest + path_sep + ui_files_filename); + }); + } + + ui_end_sticky(); + + ui_separator(8, false); + + let index: i32 = 0; + ui.changed = false; + let keys: string[] = map_keys(config_keymap); + array_sort(keys, null); + for (let i: i32 = 0; i < keys.length; ++i) { + let key: string = keys[i]; + let h: ui_handle_t = ui_nest(ui_handle(__ID__), index++); + h.text = map_get(config_keymap, key); + let text: string = ui_text_input(h, key, ui_align_t.LEFT); + map_set(config_keymap, key, text); + } + if (ui.changed) { + config_apply(); + keymap_save(); + } +} + +function box_preferences_plugins_tab() { + ui_begin_sticky(); + let row: f32[] = [1 / 4, 1 / 4]; + ui_row(row); + if (ui_button(tr("New"))) { + ui_box_show_custom(function () { + if (ui_tab(ui_handle(__ID__), tr("New Plugin"))) { + ui_row2(); + let h: ui_handle_t = ui_handle(__ID__); + if (h.init) { + h.text = "new_plugin"; + } + let plugin_name: string = ui_text_input(h, tr("Name")); + if (ui_button(tr("OK")) || ui.is_return_down) { + let template: string = "let plugin = plugin_create();\ let h1 = ui_handle_create();\ plugin_notify_on_ui(plugin, function() {\ @@ -742,84 +731,115 @@ plugin_notify_on_ui(plugin, function() {\ }\ });\ "; - if (!ends_with(plugin_name, ".js")) { - plugin_name += ".js"; - } - let path: string = path_data() + path_sep + "plugins" + path_sep + plugin_name; - iron_file_save_bytes(path, sys_string_to_buffer(template), 0); - box_preferences_files_plugin = null; // Refresh file list - ui_box_hide(); - box_preferences_htab.i = 6; // Plugins - box_preferences_show(); - } + if (!ends_with(plugin_name, ".js")) { + plugin_name += ".js"; } - }); - } - if (ui_button(tr("Import"))) { - ui_files_show("js,zip", false, false, function (path: string) { - import_plugin_run(path); - }); - } - ui_end_sticky(); - - if (box_preferences_files_plugin == null) { - box_preferences_fetch_plugins(); - } - - if (config_raw.plugins == null) { - config_raw.plugins = []; - } - let h: ui_handle_t = ui_handle(__ID__); - if (h.init) { - h.b = false; - } - for (let i: i32 = 0; i < box_preferences_files_plugin.length; ++i) { - let f: string = box_preferences_files_plugin[i]; - let is_js: bool = ends_with(f, ".js"); - if (!is_js) { - continue; + let path: string = path_data() + path_sep + "plugins" + path_sep + plugin_name; + iron_file_save_bytes(path, sys_string_to_buffer(template), 0); + box_preferences_files_plugin = null; // Refresh file list + ui_box_hide(); + box_preferences_htab.i = 6; // Plugins + box_preferences_show(); } - let enabled: bool = array_index_of(config_raw.plugins, f) >= 0; - h.b = enabled; - let tag: string = is_js ? string_split(f, ".")[0] : f; - ui_check(h, tag); - if (h.changed && h.b != enabled) { - h.b ? config_enable_plugin(f) : config_disable_plugin(f); - base_redraw_ui(); + } + }); + } + if (ui_button(tr("Import"))) { + ui_files_show("js,zip", false, false, function (path: string) { + import_plugin_run(path); + }); + } + ui_end_sticky(); + + if (box_preferences_files_plugin == null) { + box_preferences_fetch_plugins(); + } + + if (config_raw.plugins == null) { + config_raw.plugins = []; + } + let h: ui_handle_t = ui_handle(__ID__); + if (h.init) { + h.b = false; + } + for (let i: i32 = 0; i < box_preferences_files_plugin.length; ++i) { + let f: string = box_preferences_files_plugin[i]; + let is_js: bool = ends_with(f, ".js"); + if (!is_js) { + continue; + } + let enabled: bool = array_index_of(config_raw.plugins, f) >= 0; + h.b = enabled; + let tag: string = is_js ? string_split(f, ".")[0] : f; + ui_check(h, tag); + if (h.changed && h.b != enabled) { + h.b ? config_enable_plugin(f) : config_disable_plugin(f); + base_redraw_ui(); + } + if (ui.is_hovered && ui.input_released_r) { + _box_preferences_f = f; + ui_menu_draw(function () { + let path: string = path_data() + path_sep + "plugins" + path_sep + _box_preferences_f; + if (ui_menu_button(tr("Edit in Text Editor"))) { + file_start(path); } - if (ui.is_hovered && ui.input_released_r) { - _box_preferences_f = f; - ui_menu_draw(function () { + if (ui_menu_button(tr("Edit in Script Tab"))) { + let blob: buffer_t = data_get_blob("plugins/" + _box_preferences_f); + tab_scripts_hscript.text = sys_buffer_to_string(blob); + data_delete_blob("plugins/" + _box_preferences_f); + console_info(tr("Script opened")); + } + if (ui_menu_button(tr("Export"))) { + ui_files_show("js", true, false, function (dest: string) { + if (!ends_with(ui_files_filename, ".js")) { + ui_files_filename += ".js"; + } let path: string = path_data() + path_sep + "plugins" + path_sep + _box_preferences_f; - if (ui_menu_button(tr("Edit in Text Editor"))) { - file_start(path); - } - if (ui_menu_button(tr("Edit in Script Tab"))) { - let blob: buffer_t = data_get_blob("plugins/" + _box_preferences_f); - tab_scripts_hscript.text = sys_buffer_to_string(blob); - data_delete_blob("plugins/" + _box_preferences_f); - console_info(tr("Script opened")); - } - if (ui_menu_button(tr("Export"))) { - ui_files_show("js", true, false, function (dest: string) { - if (!ends_with(ui_files_filename, ".js")) { - ui_files_filename += ".js"; - } - let path: string = path_data() + path_sep + "plugins" + path_sep + _box_preferences_f; - file_copy(path, dest + path_sep + ui_files_filename); - }); - } - if (ui_menu_button(tr("Delete"))) { - if (array_index_of(config_raw.plugins, _box_preferences_f) >= 0) { - array_remove(config_raw.plugins, _box_preferences_f); - plugin_stop(_box_preferences_f); - } - array_remove(box_preferences_files_plugin, _box_preferences_f); - iron_delete_file(path); - } + file_copy(path, dest + path_sep + ui_files_filename); }); } - } + if (ui_menu_button(tr("Delete"))) { + if (array_index_of(config_raw.plugins, _box_preferences_f) >= 0) { + array_remove(config_raw.plugins, _box_preferences_f); + plugin_stop(_box_preferences_f); + } + array_remove(box_preferences_files_plugin, _box_preferences_f); + iron_delete_file(path); + } + }); + } + } +} + +function box_preferences_show() { + ui_box_show_custom(function () { + if (ui_tab(box_preferences_htab, tr("Interface"), true)) { + box_preferences_interface_tab(); + } + if (ui_tab(box_preferences_htab, tr("Theme"), true)) { + box_preferences_theme_tab(); + } + if (ui_tab(box_preferences_htab, tr("Usage"), true)) { + box_preferences_usage_tab(); + } + + ///if arm_ios + let pen_name: string = tr("Pencil"); + ///else + let pen_name: string = tr("Pen"); + ///end + if (ui_tab(box_preferences_htab, pen_name, true)) { + box_preferences_pen_tab(); + } + + if (ui_tab(box_preferences_htab, tr("Viewport"), true)) { + box_preferences_viewport_tab(); + } + if (ui_tab(box_preferences_htab, tr("Keymap"), true)) { + box_preferences_keymap_tab(); + } + if (ui_tab(box_preferences_htab, tr("Plugins"), true)) { + box_preferences_plugins_tab(); } }, 620, config_raw.touch_ui ? 510 : 420, function () { diff --git a/paint/sources/box_projects.ts b/paint/sources/box_projects.ts index 8c28fe7e..32cefc70 100644 --- a/paint/sources/box_projects.ts +++ b/paint/sources/box_projects.ts @@ -2,7 +2,6 @@ let box_projects_htab: ui_handle_t = ui_handle_create(); let box_projects_hsearch: ui_handle_t = ui_handle_create(); let box_projects_icon_map: map_t = null; - let _box_projects_path: string; let _box_projects_icon_path: string; let _box_projects_i: i32; diff --git a/paint/sources/context.ts b/paint/sources/context.ts index d08132fa..a0ee12fa 100644 --- a/paint/sources/context.ts +++ b/paint/sources/context.ts @@ -437,7 +437,11 @@ function context_create(): context_t { function context_init() { context_raw = context_create(); - context_ext_init(context_raw); + context_raw.tool = tool_type_t.BRUSH; + context_raw.color_picker_previous_tool = tool_type_t.BRUSH; + context_raw.brush_radius = 0.5; + context_raw.brush_radius_handle.f = 0.5; + context_raw.brush_hardness = 0.8; } function context_use_deferred(): bool { @@ -571,7 +575,29 @@ function context_init_tool() { } function context_select_paint_object(o: mesh_object_t) { - context_ext_select_paint_object(o); + ui_header_handle.redraws = 2; + for (let i: i32 = 0; i < project_paint_objects.length; ++i) { + let p: mesh_object_t = project_paint_objects[i]; + p.skip_context = "paint"; + } + + ///if_forge + context_raw.paint_object.skip_context = ""; + ///end + + context_raw.paint_object = o; + + let mask: i32 = slot_layer_get_object_mask(context_raw.layer); + if (context_layer_filter_used()) { + mask = context_raw.layer_filter; + } + + if (context_raw.merged_object == null || mask > 0) { + context_raw.paint_object.skip_context = ""; + } + util_uv_uvmap_cached = false; + util_uv_trianglemap_cached = false; + util_uv_dilatemap_cached = false; } function context_main_object(): mesh_object_t { @@ -757,38 +783,3 @@ function context_enable_import_plugin(file: string): bool { function context_set_swatch(s: swatch_color_t) { context_raw.swatch = s; } - - -function context_ext_init(c: context_t) { - c.tool = tool_type_t.BRUSH; - c.color_picker_previous_tool = tool_type_t.BRUSH; - c.brush_radius = 0.5; - c.brush_radius_handle.f = 0.5; - c.brush_hardness = 0.8; -} - -function context_ext_select_paint_object(o: mesh_object_t) { - ui_header_handle.redraws = 2; - for (let i: i32 = 0; i < project_paint_objects.length; ++i) { - let p: mesh_object_t = project_paint_objects[i]; - p.skip_context = "paint"; - } - - ///if_forge - context_raw.paint_object.skip_context = ""; - ///end - - context_raw.paint_object = o; - - let mask: i32 = slot_layer_get_object_mask(context_raw.layer); - if (context_layer_filter_used()) { - mask = context_raw.layer_filter; - } - - if (context_raw.merged_object == null || mask > 0) { - context_raw.paint_object.skip_context = ""; - } - util_uv_uvmap_cached = false; - util_uv_trianglemap_cached = false; - util_uv_dilatemap_cached = false; -} diff --git a/paint/sources/export_arm.ts b/paint/sources/export_arm.ts index 1369e563..9d2e7cd1 100644 --- a/paint/sources/export_arm.ts +++ b/paint/sources/export_arm.ts @@ -205,12 +205,8 @@ function export_arm_run_project() { console_info(tr("Project saved")); } -function export_arm_texture_node_name(): string { - return "TEX_IMAGE"; -} - function export_arm_export_node(n: ui_node_t, assets: asset_t[] = null) { - if (n.type == export_arm_texture_node_name()) { + if (n.type == "TEX_IMAGE") { let index: i32 = n.buttons[0].default_value[0]; n.buttons[0].data = u8_array_create_from_string(base_enum_texts(n.type)[index]); diff --git a/paint/sources/history.ts b/paint/sources/history.ts index 31948ace..3c5c0cda 100644 --- a/paint/sources/history.ts +++ b/paint/sources/history.ts @@ -1,5 +1,5 @@ -let history_steps: step_t[]; +let history_steps: history_step_t[]; let history_undo_i: i32 = 0; // Undo layer let history_undos: i32 = 0; // Undos available let history_redos: i32 = 0; // Redos available @@ -10,7 +10,7 @@ let history_push_undo2: bool = false; function history_undo() { if (history_undos > 0) { let active: i32 = history_steps.length - 1 - history_redos; - let step: step_t = history_steps[active]; + let step: history_step_t = history_steps[active]; if (step.name == tr("Edit Nodes")) { history_swap_canvas(step); @@ -142,7 +142,7 @@ function history_undo() { context_set_layer(context_raw.layer); } else if (step.name == tr("Invert Mask")) { - sys_notify_on_next_frame(function (step: step_t) { + sys_notify_on_next_frame(function (step: history_step_t) { context_raw.layer = project_layers[step.layer]; slot_layer_invert_mask(context_raw.layer); }, step); @@ -236,7 +236,7 @@ function history_undo() { function history_redo() { if (history_redos > 0) { let active: i32 = history_steps.length - history_redos; - let step: step_t = history_steps[active]; + let step: history_step_t = history_steps[active]; if (step.name == tr("Edit Nodes")) { history_swap_canvas(step); @@ -335,7 +335,7 @@ function history_redo() { }); } else if (step.name == tr("Invert Mask")) { - sys_notify_on_next_frame(function (step: step_t) { + sys_notify_on_next_frame(function (step: history_step_t) { context_raw.layer = project_layers[step.layer]; slot_layer_invert_mask(context_raw.layer); }, step); @@ -442,7 +442,7 @@ function history_reset() { } function history_edit_nodes(canvas: ui_node_canvas_t, canvas_type: i32, canvas_group: i32 = -1) { - let step: step_t = history_push(tr("Edit Nodes")); + let step: history_step_t = history_push(tr("Edit Nodes")); step.canvas_group = canvas_group; step.canvas_type = canvas_type; step.canvas = util_clone_canvas(canvas); @@ -491,14 +491,14 @@ function history_clear_layer() { } function history_order_layers(prev_order: i32) { - let step: step_t = history_push(tr("Order Layers")); + let step: history_step_t = history_push(tr("Order Layers")); step.prev_order = prev_order; } function history_merge_layers() { history_copy_merging_layers(); - let step: step_t = history_push(tr("Merge Layers")); + let step: history_step_t = history_push(tr("Merge Layers")); step.layer -= 1; // Merge down if (slot_layer_has_masks(context_raw.layer)) { step.layer -= slot_layer_get_masks(context_raw.layer).length; @@ -564,31 +564,31 @@ function history_layer_blending() { } function history_new_material() { - let step: step_t = history_push(tr("New Material")); + let step: history_step_t = history_push(tr("New Material")); step.canvas_type = 0; step.canvas = util_clone_canvas(context_raw.material.canvas); } function history_delete_material() { - let step: step_t = history_push(tr("Delete Material")); + let step: history_step_t = history_push(tr("Delete Material")); step.canvas_type = 0; step.canvas = util_clone_canvas(context_raw.material.canvas); } function history_duplicate_material() { - let step: step_t = history_push(tr("Duplicate Material")); + let step: history_step_t = history_push(tr("Duplicate Material")); step.canvas_type = 0; step.canvas = util_clone_canvas(context_raw.material.canvas); } function history_delete_material_group(group: node_group_t) { - let step: step_t = history_push(tr("Delete Node Group")); + let step: history_step_t = history_push(tr("Delete Node Group")); step.canvas_type = canvas_type_t.MATERIAL; step.canvas_group = array_index_of(project_material_groups, group); step.canvas = util_clone_canvas(group.canvas); } -function history_push(name: string): step_t { +function history_push(name: string): history_step_t { ///if (arm_windows || arm_linux || arm_macos) let filename: string = project_filepath == "" ? ui_files_filename : substring(project_filepath, string_last_index_of(project_filepath, path_sep) + 1, project_filepath.length - 4); sys_title_set(filename + "* - " + manifest_title); @@ -614,7 +614,7 @@ function history_push(name: string): step_t { let mpos: i32 = array_index_of(project_materials, context_raw.material); let bpos: i32 = array_index_of(project_brushes, context_raw.brush); - let step: step_t = { + let step: history_step_t = { name: name, layer: lpos, layer_type: slot_layer_is_mask(context_raw.layer) ? layer_slot_type_t.MASK : slot_layer_is_group(context_raw.layer) ? layer_slot_type_t.GROUP : layer_slot_type_t.LAYER, @@ -689,7 +689,7 @@ function history_copy_to_undo(from_id: i32, to_id: i32, is_mask: bool) { history_undo_i = (history_undo_i + 1) % config_raw.undo_steps; } -function history_get_canvas(step: step_t): ui_node_canvas_t { +function history_get_canvas(step: history_step_t): ui_node_canvas_t { if (step.canvas_group == -1) { return project_materials[step.material].canvas; } @@ -698,7 +698,7 @@ function history_get_canvas(step: step_t): ui_node_canvas_t { } } -function history_set_canvas(step: step_t, canvas: ui_node_canvas_t) { +function history_set_canvas(step: history_step_t, canvas: ui_node_canvas_t) { if (step.canvas_group == -1) { project_materials[step.material].canvas = canvas; } @@ -707,7 +707,7 @@ function history_set_canvas(step: step_t, canvas: ui_node_canvas_t) { } } -function history_swap_canvas(step: step_t) { +function history_swap_canvas(step: history_step_t) { if (step.canvas_type == 0) { let _canvas: ui_node_canvas_t = history_get_canvas(step); history_set_canvas(step, step.canvas); @@ -728,7 +728,7 @@ function history_swap_canvas(step: step_t) { ui_nodes_hwnd.redraws = 2; } -type step_t = { +type history_step_t = { name?: string; canvas?: ui_node_canvas_t; // Node history canvas_group?: i32; diff --git a/paint/sources/import_arm.ts b/paint/sources/import_arm.ts index 73d420c8..8c7b2945 100644 --- a/paint/sources/import_arm.ts +++ b/paint/sources/import_arm.ts @@ -592,14 +592,10 @@ function import_arm_make_pink(abs: string) { map_set(data_cached_images, abs, pink); } -function import_arm_texture_node_name(): string { - return "TEX_IMAGE"; -} - function import_arm_init_nodes(nodes: ui_node_t[]) { for (let i: i32 = 0; i < nodes.length; ++i) { let node: ui_node_t = nodes[i]; - if (node.type == import_arm_texture_node_name()) { + if (node.type == "TEX_IMAGE") { node.buttons[0].default_value = f32_array_create_x(base_get_asset_index(u8_array_to_string(node.buttons[0].data))); node.buttons[0].data = u8_array_create_from_string(""); } diff --git a/paint/sources/layers.ts b/paint/sources/layers.ts deleted file mode 100644 index 87ca0616..00000000 --- a/paint/sources/layers.ts +++ /dev/null @@ -1,937 +0,0 @@ - -let layers_temp_image: gpu_texture_t = null; -let layers_expa: gpu_texture_t = null; -let layers_expb: gpu_texture_t = null; -let layers_expc: gpu_texture_t = null; -let layers_default_base: f32 = 0.5; -let layers_default_rough: f32 = 0.4; -let layers_max_layers: i32 = -///if (arm_android || arm_ios) - 18; -///else - 255; -///end - -let _layers_uv_type: uv_type_t; -let _layers_decal_mat: mat4_t; -let _layers_position: i32; -let _layers_base_color: i32; -let _layers_occlusion: f32; -let _layers_roughness: f32; -let _layers_metallic: f32; - -function layers_init() { - slot_layer_clear(project_layers[0], color_from_floats(layers_default_base, layers_default_base, layers_default_base, 1.0)); -} - -function layers_resize() { - let conf: config_t = config_raw; - if (base_res_handle.i >= math_floor(texture_res_t.RES16384)) { // Save memory for >=16k - conf.undo_steps = 1; - if (context_raw.undo_handle != null) { - context_raw.undo_handle.f = conf.undo_steps; - } - while (history_undo_layers.length > conf.undo_steps) { - let l: slot_layer_t = array_pop(history_undo_layers); - sys_notify_on_next_frame(function (l: slot_layer_t) { - slot_layer_unload(l); - }, l); - } - } - for (let i: i32 = 0; i < project_layers.length; ++i) { - let l: slot_layer_t = project_layers[i]; - slot_layer_resize_and_set_bits(l); - } - for (let i: i32 = 0; i < history_undo_layers.length; ++i) { - let l: slot_layer_t = history_undo_layers[i]; - slot_layer_resize_and_set_bits(l); - } - - let rts: map_t = render_path_render_targets; - - let blend0: render_target_t = map_get(rts, "texpaint_blend0"); - let _texpaint_blend0: gpu_texture_t = blend0._image; - gpu_delete_texture(_texpaint_blend0); - blend0.width = config_get_texture_res_x(); - blend0.height = config_get_texture_res_y(); - blend0._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); - - let blend1: render_target_t = map_get(rts, "texpaint_blend1"); - let _texpaint_blend1: gpu_texture_t = blend1._image; - gpu_delete_texture(_texpaint_blend1); - blend1.width = config_get_texture_res_x(); - blend1.height = config_get_texture_res_y(); - blend1._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); - - context_raw.brush_blend_dirty = true; - - let blur: render_target_t = map_get(rts, "texpaint_blur"); - if (blur != null) { - let _texpaint_blur: gpu_texture_t = blur._image; - gpu_delete_texture(_texpaint_blur); - let size_x: f32 = math_floor(config_get_texture_res_x() * 0.95); - let size_y: f32 = math_floor(config_get_texture_res_y() * 0.95); - blur.width = size_x; - blur.height = size_y; - blur._image = gpu_create_render_target(size_x, size_y); - } - if (render_path_paint_live_layer != null) { - slot_layer_resize_and_set_bits(render_path_paint_live_layer); - } - render_path_raytrace_ready = false; // Rebuild baketex - context_raw.ddirty = 2; -} - -function layers_set_bits() { - for (let i: i32 = 0; i < project_layers.length; ++i) { - let l: slot_layer_t = project_layers[i]; - slot_layer_resize_and_set_bits(l); - } - for (let i: i32 = 0; i < history_undo_layers.length; ++i) { - let l: slot_layer_t = history_undo_layers[i]; - slot_layer_resize_and_set_bits(l); - } -} - -function layers_make_temp_img() { - let l: slot_layer_t = project_layers[0]; - - if (layers_temp_image != null && (layers_temp_image.width != l.texpaint.width || layers_temp_image.height != l.texpaint.height || layers_temp_image.format != l.texpaint.format)) { - let _temptex0: render_target_t = map_get(render_path_render_targets, "temptex0"); - render_target_unload(_temptex0); - map_delete(render_path_render_targets, "temptex0"); - layers_temp_image = null; - } - if (layers_temp_image == null) { - let format: string = base_bits_handle.i == texture_bits_t.BITS8 ? "RGBA32" : - base_bits_handle.i == texture_bits_t.BITS16 ? "RGBA64" : - "RGBA128"; - - let t: render_target_t = render_target_create(); - t.name = "temptex0"; - t.width = l.texpaint.width; - t.height = l.texpaint.height; - t.format = format; - let rt: render_target_t = render_path_create_render_target(t); - layers_temp_image = rt._image; - } -} - -function layers_make_temp_mask_img() { - 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: gpu_texture_t = pipes_temp_mask_image; - gpu_delete_texture(_temp_mask_image); - pipes_temp_mask_image = null; - } - if (pipes_temp_mask_image == null) { - pipes_temp_mask_image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); - } -} - -function layers_make_export_img() { - let l: slot_layer_t = project_layers[0]; - - if (layers_expa != null && (layers_expa.width != l.texpaint.width || layers_expa.height != l.texpaint.height || layers_expa.format != l.texpaint.format)) { - let _expa: gpu_texture_t = layers_expa; - let _expb: gpu_texture_t = layers_expb; - let _expc: gpu_texture_t = layers_expc; - gpu_delete_texture(_expa); - gpu_delete_texture(_expb); - gpu_delete_texture(_expc); - layers_expa = null; - layers_expb = null; - layers_expc = null; - map_delete(render_path_render_targets, "expa"); - map_delete(render_path_render_targets, "expb"); - map_delete(render_path_render_targets, "expc"); - } - if (layers_expa == null) { - let format: string = base_bits_handle.i == texture_bits_t.BITS8 ? "RGBA32" : - base_bits_handle.i == texture_bits_t.BITS16 ? "RGBA64" : - "RGBA128"; - - - { - let t: render_target_t = render_target_create(); - t.name = "expa"; - t.width = l.texpaint.width; - t.height = l.texpaint.height; - t.format = format; - let rt: render_target_t = render_path_create_render_target(t); - layers_expa = rt._image; - } - - { - let t: render_target_t = render_target_create(); - t.name = "expb"; - t.width = l.texpaint.width; - t.height = l.texpaint.height; - t.format = format; - let rt: render_target_t = render_path_create_render_target(t); - layers_expb = rt._image; - } - - { - let t: render_target_t = render_target_create(); - t.name = "expc"; - t.width = l.texpaint.width; - t.height = l.texpaint.height; - t.format = format; - let rt: render_target_t = render_path_create_render_target(t); - layers_expc = rt._image; - } - } -} - -function layers_apply_mask(l: slot_layer_t, m: slot_layer_t) { - if (!slot_layer_is_layer(l) || !slot_layer_is_mask(m)) { - return; - } - - layers_make_temp_img(); - - // Copy layer to temp - draw_begin(layers_temp_image); - draw_set_pipeline(pipes_copy); - draw_image(l.texpaint, 0, 0); - draw_set_pipeline(null); - draw_end(); - - // Apply mask - _gpu_begin(l.texpaint); - gpu_set_pipeline(pipes_apply_mask); - gpu_set_texture(pipes_tex0_mask, layers_temp_image); - gpu_set_texture(pipes_texa_mask, m.texpaint); - gpu_set_vertex_buffer(const_data_screen_aligned_vb); - gpu_set_index_buffer(const_data_screen_aligned_ib); - gpu_draw(); - gpu_end(); -} - -function layers_commands_merge_pack(pipe: gpu_pipeline_t, i0: gpu_texture_t, i1: gpu_texture_t, i1pack: gpu_texture_t, i1mask_opacity: f32, i1texmask: gpu_texture_t, i1blending: i32 = 101) { - _gpu_begin(i0); - gpu_set_pipeline(pipe); - gpu_set_texture(pipes_tex0, i1); - gpu_set_texture(pipes_tex1, i1pack); - gpu_set_texture(pipes_texmask, i1texmask); - gpu_set_texture(pipes_texa, layers_temp_image); - gpu_set_float(pipes_opac, i1mask_opacity); - gpu_set_float(pipes_tex1w, i1pack.width); - gpu_set_int(pipes_blending, i1blending); - gpu_set_vertex_buffer(const_data_screen_aligned_vb); - gpu_set_index_buffer(const_data_screen_aligned_ib); - gpu_draw(); - gpu_end(); -} - -function layers_is_fill_material(): bool { - if (context_raw.tool == tool_type_t.MATERIAL) { - return true; - } - - let m: slot_material_t = context_raw.material; - for (let i: i32 = 0; i < project_layers.length; ++i) { - let l: slot_layer_t = project_layers[i]; - if (l.fill_layer == m) { - return true; - } - } - return false; -} - -function layers_update_fill_layers() { - let _layer: slot_layer_t = context_raw.layer; - let _tool: tool_type_t = context_raw.tool; - let _fill_type: i32 = context_raw.fill_type_handle.i; - let current: gpu_texture_t = null; - - if (context_raw.tool == tool_type_t.MATERIAL) { - if (render_path_paint_live_layer == null) { - render_path_paint_live_layer = slot_layer_create("_live"); - } - - current = _draw_current; - if (current != null) draw_end(); - - context_raw.tool = tool_type_t.FILL; - context_raw.fill_type_handle.i = fill_type_t.OBJECT; - render_path_paint_set_plane_mesh(); - make_material_parse_paint_material(false); - context_raw.pdirty = 1; - render_path_paint_use_live_layer(true); - render_path_paint_commands_paint(false); - render_path_paint_dilate(true, true); - render_path_paint_use_live_layer(false); - context_raw.tool = _tool; - context_raw.fill_type_handle.i = _fill_type; - context_raw.pdirty = 0; - context_raw.rdirty = 2; - render_path_paint_restore_plane_mesh(); - make_material_parse_paint_material(); - ui_view2d_hwnd.redraws = 2; - - if (current != null) draw_begin(current); - return; - } - - let has_fill_layer: bool = false; - let has_fill_mask: bool = false; - for (let i: i32 = 0; i < project_layers.length; ++i) { - let l: slot_layer_t = project_layers[i]; - if (slot_layer_is_layer(l) && l.fill_layer == context_raw.material) { - has_fill_layer = true; - } - } - for (let i: i32 = 0; i < project_layers.length; ++i) { - let l: slot_layer_t = project_layers[i]; - if (slot_layer_is_mask(l) && l.fill_layer == context_raw.material) { - has_fill_mask = true; - } - } - - if (has_fill_layer || has_fill_mask) { - current = _draw_current; - if (current != null) { - draw_end(); - } - context_raw.pdirty = 1; - context_raw.tool = tool_type_t.FILL; - context_raw.fill_type_handle.i = fill_type_t.OBJECT; - - if (has_fill_layer) { - let first: bool = true; - for (let i: i32 = 0; i < project_layers.length; ++i) { - let l: slot_layer_t = project_layers[i]; - if (slot_layer_is_layer(l) && l.fill_layer == context_raw.material) { - context_raw.layer = l; - if (first) { - first = false; - make_material_parse_paint_material(false); - } - layers_set_object_mask(); - slot_layer_clear(l); - render_path_paint_commands_paint(false); - render_path_paint_dilate(true, true); - } - } - } - if (has_fill_mask) { - let first: bool = true; - for (let i: i32 = 0; i < project_layers.length; ++i) { - let l: slot_layer_t = project_layers[i]; - if (slot_layer_is_mask(l) && l.fill_layer == context_raw.material) { - context_raw.layer = l; - if (first) { - first = false; - make_material_parse_paint_material(false); - } - layers_set_object_mask(); - slot_layer_clear(l); - render_path_paint_commands_paint(false); - render_path_paint_dilate(true, true); - } - } - } - - context_raw.pdirty = 0; - context_raw.ddirty = 2; - context_raw.rdirty = 2; - context_raw.layers_preview_dirty = true; // Repaint all layer previews as multiple layers might have changed. - if (current != null) draw_begin(current); - context_raw.layer = _layer; - layers_set_object_mask(); - context_raw.tool = _tool; - context_raw.fill_type_handle.i = _fill_type; - make_material_parse_paint_material(false); - } -} - -function layers_update_fill_layer(parse_paint: bool = true) { - let current: gpu_texture_t = _draw_current; - let in_use: bool = gpu_in_use; - if (in_use) draw_end(); - - let _tool: tool_type_t = context_raw.tool; - let _fill_type: i32 = context_raw.fill_type_handle.i; - context_raw.tool = tool_type_t.FILL; - context_raw.fill_type_handle.i = fill_type_t.OBJECT; - context_raw.pdirty = 1; - - slot_layer_clear(context_raw.layer); - - if (parse_paint) { - make_material_parse_paint_material(false); - } - render_path_paint_commands_paint(false); - render_path_paint_dilate(true, true); - - context_raw.rdirty = 2; - context_raw.tool = _tool; - context_raw.fill_type_handle.i = _fill_type; - if (in_use) draw_begin(current); -} - -function layers_set_object_mask() { - let ar: string[] = [tr("None")]; - for (let i: i32 = 0; i < project_paint_objects.length; ++i) { - let p: mesh_object_t = project_paint_objects[i]; - array_push(ar, p.base.name); - } - - let mask: i32 = context_object_mask_used() ? slot_layer_get_object_mask(context_raw.layer) : 0; - if (context_layer_filter_used()) { - mask = context_raw.layer_filter; - } - if (mask > 0) { - if (context_raw.merged_object != null) { - context_raw.merged_object.base.visible = false; - } - let o: mesh_object_t = project_paint_objects[0]; - for (let i: i32 = 0; i < project_paint_objects.length; ++i) { - let p: mesh_object_t = project_paint_objects[i]; - let mask_name: string = ar[mask]; - if (p.base.name == mask_name) { - o = p; - break; - } - } - context_select_paint_object(o); - } - else { - let is_atlas: bool = slot_layer_get_object_mask(context_raw.layer) > 0 && slot_layer_get_object_mask(context_raw.layer) <= project_paint_objects.length; - if (context_raw.merged_object == null || is_atlas || context_raw.merged_object_is_atlas) { - let visibles: mesh_object_t[] = is_atlas ? project_get_atlas_objects(slot_layer_get_object_mask(context_raw.layer)) : null; - util_mesh_merge(visibles); - } - context_select_paint_object(context_main_object()); - context_raw.paint_object.skip_context = "paint"; - context_raw.merged_object.base.visible = true; - } - util_uv_dilatemap_cached = false; -} - -function layers_new_layer(clear: bool = true, position: i32 = -1): slot_layer_t { - if (project_layers.length > layers_max_layers) { - return null; - } - - let l: slot_layer_t = slot_layer_create(); - l.object_mask = context_raw.layer_filter; - - if (position == -1) { - if (slot_layer_is_mask(context_raw.layer)) context_set_layer(context_raw.layer.parent); - array_insert(project_layers, array_index_of(project_layers, context_raw.layer) + 1, l); - } - else { - array_insert(project_layers, position, l); - } - - context_set_layer(l); - let li: i32 = array_index_of(project_layers, context_raw.layer); - if (li > 0) { - let below: slot_layer_t = project_layers[li - 1]; - if (slot_layer_is_layer(below)) { - context_raw.layer.parent = below.parent; - } - } - if (clear) { - sys_notify_on_next_frame(function (l: slot_layer_t) { - slot_layer_clear(l); - }, l); - } - context_raw.layer_preview_dirty = true; - return l; -} - -function layers_new_mask(clear: bool = true, parent: slot_layer_t, position: i32 = -1): slot_layer_t { - if (project_layers.length > layers_max_layers) { - return null; - } - let l: slot_layer_t = slot_layer_create("", layer_slot_type_t.MASK, parent); - if (position == -1) { - position = array_index_of(project_layers, parent); - } - array_insert(project_layers, position, l); - context_set_layer(l); - if (clear) { - sys_notify_on_next_frame(function (l: slot_layer_t) { - slot_layer_clear(l); - }, l); - } - context_raw.layer_preview_dirty = true; - return l; -} - -function layers_new_group(): slot_layer_t { - if (project_layers.length > layers_max_layers) { - return null; - } - let l: slot_layer_t = slot_layer_create("", layer_slot_type_t.GROUP); - array_push(project_layers, l); - context_set_layer(l); - return l; -} - -function layers_create_fill_layer(uv_type: uv_type_t = uv_type_t.UVMAP, decal_mat: mat4_t = mat4nan, position: i32 = -1) { - if (context_raw.tool == tool_type_t.GIZMO) { - return; - } - - _layers_uv_type = uv_type; - _layers_decal_mat = decal_mat; - _layers_position = position; - sys_notify_on_next_frame(function () { - let l: slot_layer_t = layers_new_layer(false, _layers_position); - history_new_layer(); - l.uv_type = _layers_uv_type; - if (!mat4_isnan(_layers_decal_mat)) { - l.decal_mat = _layers_decal_mat; - } - l.object_mask = context_raw.layer_filter; - history_to_fill_layer(); - slot_layer_to_fill_layer(l); - }); -} - -function layers_create_image_mask(asset: asset_t) { - let l: slot_layer_t = context_raw.layer; - if (slot_layer_is_mask(l) || slot_layer_is_group(l)) { - return; - } - - history_new_layer(); - let m: slot_layer_t = layers_new_mask(false, l); - slot_layer_clear(m, 0x00000000, project_get_image(asset)); - context_raw.layer_preview_dirty = true; -} - -function layers_create_color_layer(base_color: i32, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0, position: i32 = -1) { - _layers_base_color = base_color; - _layers_occlusion = occlusion; - _layers_roughness = roughness; - _layers_metallic = metallic; - _layers_position = position; - - sys_notify_on_next_frame(function () { - let l: slot_layer_t = layers_new_layer(false, _layers_position); - history_new_layer(); - l.uv_type = uv_type_t.UVMAP; - l.object_mask = context_raw.layer_filter; - slot_layer_clear(l, _layers_base_color, null, _layers_occlusion, _layers_roughness, _layers_metallic); - }); -} - -function layers_duplicate_layer(l: slot_layer_t) { - if (!slot_layer_is_group(l)) { - let new_layer: slot_layer_t = slot_layer_duplicate(l); - context_set_layer(new_layer); - let masks: slot_layer_t[] = slot_layer_get_masks(l, false); - if (masks != null) { - for (let i: i32 = 0; i < masks.length; ++i) { - let m: slot_layer_t = masks[i]; - m = slot_layer_duplicate(m); - m.parent = new_layer; - array_remove(project_layers, m); - array_insert(project_layers, array_index_of(project_layers, new_layer), m); - } - } - context_set_layer(new_layer); - } - else { - let new_group: slot_layer_t = layers_new_group(); - array_remove(project_layers, new_group); - array_insert(project_layers, array_index_of(project_layers, l) + 1, new_group); - // group.show_panel = true; - for (let i: i32 = 0; i < slot_layer_get_children(l).length; ++i) { - let c: slot_layer_t = slot_layer_get_children(l)[i]; - let masks: slot_layer_t[] = slot_layer_get_masks(c, false); - let new_layer: slot_layer_t = slot_layer_duplicate(c); - new_layer.parent = new_group; - array_remove(project_layers, new_layer); - array_insert(project_layers, array_index_of(project_layers, new_group), new_layer); - if (masks != null) { - for (let i: i32 = 0; i < masks.length; ++i) { - let m: slot_layer_t = masks[i]; - let new_mask: slot_layer_t = slot_layer_duplicate(m); - new_mask.parent = new_layer; - array_remove(project_layers, new_mask); - array_insert(project_layers, array_index_of(project_layers, new_layer), new_mask); - } - } - } - let group_masks: slot_layer_t[] = slot_layer_get_masks(l); - if (group_masks != null) { - for (let i: i32 = 0; i < group_masks.length; ++i) { - let m: slot_layer_t = group_masks[i]; - let new_mask: slot_layer_t = slot_layer_duplicate(m); - new_mask.parent = new_group; - array_remove(project_layers, new_mask); - array_insert(project_layers, array_index_of(project_layers, new_group), new_mask); - } - } - context_set_layer(new_group); - } -} - -function layers_apply_masks(l: slot_layer_t) { - let masks: slot_layer_t[] = slot_layer_get_masks(l); - - if (masks != null) { - for (let i: i32 = 0; i < masks.length - 1; ++i) { - layers_merge_layer(masks[i + 1], masks[i]); - slot_layer_delete(masks[i]); - } - slot_layer_apply_mask(masks[masks.length - 1]); - context_raw.layer_preview_dirty = true; - } -} - -function layers_merge_down() { - let l1: slot_layer_t = context_raw.layer; - - if (slot_layer_is_group(l1)) { - l1 = layers_merge_group(l1); - } - else if (slot_layer_has_masks(l1)) { // It is a layer - layers_apply_masks(l1); - context_set_layer(l1); - } - - let l0: slot_layer_t = project_layers[array_index_of(project_layers, l1) - 1]; - - if (slot_layer_is_group(l0)) { - l0 = layers_merge_group(l0); - } - else if (slot_layer_has_masks(l0)) { // It is a layer - layers_apply_masks(l0); - context_set_layer(l0); - } - - layers_merge_layer(l0, l1); - slot_layer_delete(l1); - context_set_layer(l0); - context_raw.layer_preview_dirty = true; -} - -function layers_merge_group(l: slot_layer_t): slot_layer_t { - if (!slot_layer_is_group(l)) { - return null; - } - - let children: slot_layer_t[] = slot_layer_get_children(l); - - if (children.length == 1 && slot_layer_has_masks(children[0], false)) { - layers_apply_masks(children[0]); - } - - for (let i: i32 = 0; i < children.length - 1; ++i) { - context_set_layer(children[children.length - 1 - i]); - history_merge_layers(); - layers_merge_down(); - } - - // Now apply the group masks - let masks: slot_layer_t[] = slot_layer_get_masks(l); - if (masks != null) { - for (let i: i32 = 0; i < masks.length - 1; ++i) { - layers_merge_layer(masks[i + 1], masks[i]); - slot_layer_delete(masks[i]); - } - layers_apply_mask(children[0], masks[masks.length - 1]); - } - - children[0].parent = null; - children[0].name = l.name; - if (children[0].fill_layer != null) { - slot_layer_to_paint_layer(children[0]); - } - slot_layer_delete(l); - return children[0]; -} - -function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool = false) { - if (!l1.visible || slot_layer_is_group(l1)) { - return; - } - - layers_make_temp_img(); - - draw_begin(layers_temp_image); // Copy to temp - draw_set_pipeline(pipes_copy); - draw_image(l0.texpaint, 0, 0); - draw_set_pipeline(null); - draw_end(); - - let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); - let empty: gpu_texture_t = empty_rt._image; - let mask: gpu_texture_t = empty; - let l1masks: slot_layer_t[] = use_mask ? slot_layer_get_masks(l1) : null; - if (l1masks != null) { - // for (let i: i32 = 1; i < l1masks.length - 1; ++i) { - // merge_layer(l1masks[i + 1], l1masks[i]); - // } - mask = l1masks[0].texpaint; - } - - if (slot_layer_is_mask(l1)) { - _gpu_begin(l0.texpaint); - gpu_set_pipeline(pipes_merge_mask); - gpu_set_texture(pipes_tex0_merge_mask, l1.texpaint); - gpu_set_texture(pipes_texa_merge_mask, layers_temp_image); - gpu_set_float(pipes_opac_merge_mask, slot_layer_get_opacity(l1)); - gpu_set_int(pipes_blending_merge_mask, l1.blending); - gpu_set_vertex_buffer(const_data_screen_aligned_vb); - gpu_set_index_buffer(const_data_screen_aligned_ib); - gpu_draw(); - gpu_end(); - } - - if (slot_layer_is_layer(l1)) { - if (l1.paint_base) { - _gpu_begin(l0.texpaint); - gpu_set_pipeline(pipes_merge); - gpu_set_texture(pipes_tex0, l1.texpaint); - gpu_set_texture(pipes_tex1, empty); - gpu_set_texture(pipes_texmask, mask); - gpu_set_texture(pipes_texa, layers_temp_image); - gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); - gpu_set_float(pipes_tex1w, empty.width); - gpu_set_int(pipes_blending, l1.blending); - gpu_set_vertex_buffer(const_data_screen_aligned_vb); - gpu_set_index_buffer(const_data_screen_aligned_ib); - gpu_draw(); - gpu_end(); - } - - if (l0.texpaint_nor != null) { - draw_begin(layers_temp_image); - draw_set_pipeline(pipes_copy); - draw_image(l0.texpaint_nor, 0, 0); - draw_set_pipeline(null); - draw_end(); - - if (l1.paint_nor) { - _gpu_begin(l0.texpaint_nor); - gpu_set_pipeline(pipes_merge); - gpu_set_texture(pipes_tex0, l1.texpaint); - gpu_set_texture(pipes_tex1, l1.texpaint_nor); - gpu_set_texture(pipes_texmask, mask); - gpu_set_texture(pipes_texa, layers_temp_image); - gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); - gpu_set_float(pipes_tex1w, l1.texpaint_nor.width); - gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101); - gpu_set_vertex_buffer(const_data_screen_aligned_vb); - gpu_set_index_buffer(const_data_screen_aligned_ib); - gpu_draw(); - gpu_end(); - } - } - - if (l0.texpaint_pack != null) { - draw_begin(layers_temp_image); - draw_set_pipeline(pipes_copy); - draw_image(l0.texpaint_pack, 0, 0); - draw_set_pipeline(null); - draw_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) { - layers_commands_merge_pack(pipes_merge, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? 103 : 101); - } - else { - if (l1.paint_occ) { - layers_commands_merge_pack(pipes_merge_r, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); - } - if (l1.paint_rough) { - layers_commands_merge_pack(pipes_merge_g, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); - } - if (l1.paint_met) { - layers_commands_merge_pack(pipes_merge_b, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); - } - } - } - } - } -} - -function layers_flatten(height_to_normal: bool = false, layers: slot_layer_t[] = null): slot_layer_t { - if (layers == null) { - layers = project_layers; - } - layers_make_temp_img(); - layers_make_export_img(); - - let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); - let empty: gpu_texture_t = empty_rt._image; - - // Clear export layer - _gpu_begin(layers_expa, null, null, clear_flag_t.COLOR, color_from_floats(0.0, 0.0, 0.0, 0.0)); - gpu_end(); - _gpu_begin(layers_expb, null, null, clear_flag_t.COLOR, color_from_floats(0.5, 0.5, 1.0, 0.0)); - gpu_end(); - _gpu_begin(layers_expc, null, null, clear_flag_t.COLOR, color_from_floats(1.0, 0.0, 0.0, 0.0)); - gpu_end(); - - // Flatten layers - for (let i: i32 = 0; i < layers.length; ++i) { - let l1: slot_layer_t = layers[i]; - if (!slot_layer_is_visible(l1)) { - continue; - } - if (!slot_layer_is_layer(l1)) { - continue; - } - - let mask: gpu_texture_t = empty; - let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); - if (l1masks != null) { - if (l1masks.length > 1) { - layers_make_temp_mask_img(); - draw_begin(pipes_temp_mask_image, clear_flag_t.COLOR, 0x00000000); - draw_end(); - let l1: slot_layer_t = { texpaint: pipes_temp_mask_image }; - for (let i: i32 = 0; i < l1masks.length; ++i) { - layers_merge_layer(l1, l1masks[i]); - } - mask = pipes_temp_mask_image; - } - else { - mask = l1masks[0].texpaint; - } - } - - if (l1.paint_base) { - draw_begin(layers_temp_image); // Copy to temp - draw_set_pipeline(pipes_copy); - draw_image(layers_expa, 0, 0); - draw_set_pipeline(null); - draw_end(); - - if (context_raw.tool == tool_type_t.GIZMO) { - // Do not multiply basecol by alpha - draw_begin(layers_expa); // Copy to temp - draw_set_pipeline(pipes_copy); - draw_image(l1.texpaint, 0, 0); - draw_set_pipeline(null); - draw_end(); - } - else { - _gpu_begin(layers_expa); - gpu_set_pipeline(pipes_merge); - gpu_set_texture(pipes_tex0, l1.texpaint); - gpu_set_texture(pipes_tex1, empty); - gpu_set_texture(pipes_texmask, mask); - gpu_set_texture(pipes_texa, layers_temp_image); - gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); - gpu_set_float(pipes_tex1w, empty.width); - gpu_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); - gpu_set_vertex_buffer(const_data_screen_aligned_vb); - gpu_set_index_buffer(const_data_screen_aligned_ib); - gpu_draw(); - gpu_end(); - } - } - - if (l1.paint_nor) { - draw_begin(layers_temp_image); - draw_set_pipeline(pipes_copy); - draw_image(layers_expb, 0, 0); - draw_set_pipeline(null); - draw_end(); - - _gpu_begin(layers_expb); - gpu_set_pipeline(pipes_merge); - gpu_set_texture(pipes_tex0, l1.texpaint); - gpu_set_texture(pipes_tex1, l1.texpaint_nor); - gpu_set_texture(pipes_texmask, mask); - gpu_set_texture(pipes_texa, layers_temp_image); - gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); - gpu_set_float(pipes_tex1w, l1.texpaint_nor.width); - gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101); - gpu_set_vertex_buffer(const_data_screen_aligned_vb); - gpu_set_index_buffer(const_data_screen_aligned_ib); - gpu_draw(); - gpu_end(); - } - - if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { - draw_begin(layers_temp_image); - draw_set_pipeline(pipes_copy); - draw_image(layers_expc, 0, 0); - draw_set_pipeline(null); - draw_end(); - - if (l1.paint_occ && l1.paint_rough && l1.paint_met && l1.paint_height) { - layers_commands_merge_pack(pipes_merge, layers_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? 103 : 101); - } - else { - if (l1.paint_occ) { - layers_commands_merge_pack(pipes_merge_r, layers_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); - } - if (l1.paint_rough) { - layers_commands_merge_pack(pipes_merge_g, layers_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); - } - if (l1.paint_met) { - layers_commands_merge_pack(pipes_merge_b, layers_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); - } - } - } - } - - let l0: slot_layer_t = { - texpaint: layers_expa, - texpaint_nor: layers_expb, - texpaint_pack: layers_expc - }; - - // Merge height map into normal map - if (height_to_normal && make_material_height_used) { - - draw_begin(layers_temp_image); - draw_set_pipeline(pipes_copy); - draw_image(l0.texpaint_nor, 0, 0); - draw_set_pipeline(null); - draw_end(); - - _gpu_begin(l0.texpaint_nor); - gpu_set_pipeline(pipes_merge); - gpu_set_texture(pipes_tex0, layers_temp_image); - gpu_set_texture(pipes_tex1, l0.texpaint_pack); - gpu_set_texture(pipes_texmask, empty); - gpu_set_texture(pipes_texa, empty); - gpu_set_float(pipes_opac, 1.0); - gpu_set_float(pipes_tex1w, l0.texpaint_pack.width); - gpu_set_int(pipes_blending, 104); - gpu_set_vertex_buffer(const_data_screen_aligned_vb); - gpu_set_index_buffer(const_data_screen_aligned_ib); - gpu_draw(); - gpu_end(); - } - - return l0; -} - -function layers_on_resized() { - sys_notify_on_next_frame(function () { - layers_resize(); - let _layer: slot_layer_t = context_raw.layer; - let _material: slot_material_t = context_raw.material; - for (let i: i32 = 0; i < project_layers.length; ++i) { - let l: slot_layer_t = project_layers[i]; - if (l.fill_layer != null) { - context_raw.layer = l; - context_raw.material = l.fill_layer; - layers_update_fill_layer(); - } - } - context_raw.layer = _layer; - context_raw.material = _material; - make_material_parse_paint_material(); - }); - util_uv_uvmap = null; - util_uv_uvmap_cached = false; - util_uv_trianglemap = null; - util_uv_trianglemap_cached = false; - util_uv_dilatemap_cached = false; - render_path_raytrace_ready = false; -} diff --git a/paint/sources/nodes_material.ts b/paint/sources/nodes_material.ts index cdea08ec..79bb681d 100644 --- a/paint/sources/nodes_material.ts +++ b/paint/sources/nodes_material.ts @@ -1,4414 +1,4 @@ -let nodes_material_categories: string[] = [ - _tr("Input"), - _tr("Texture"), - _tr("Color"), - _tr("Vector"), - _tr("Converter"), - // _tr("Neural"), - _tr("Group") -]; - -let nodes_material_input: ui_node_t[] = [ - { - id: 0, - name: _tr("Attribute"), - type: "ATTRIBUTE", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("Name"), - type: "STRING", - output: -1, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Camera Data"), - type: "CAMERA", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("View Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("View Z Depth"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("View Distance"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Fresnel"), - type: "FRESNEL", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("IOR"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.45), - min: 0.0, - max: 3.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Geometry"), - type: "NEW_GEOMETRY", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Position"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Tangent"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("True Normal"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Incoming"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Parametric"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Backfacing"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Pointiness"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Random Per Island"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Layer"), - type: "LAYER", // extension - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Base Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Opacity"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Occlusion"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Roughness"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Metallic"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal Map"), - type: "VECTOR", - color: -10238109, - default_value: f32_array_create_xyz(0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Emission"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Height"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Subsurface"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("Layer"), - type: "ENUM", - output: -1, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(""), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Layer Mask"), - type: "LAYER_MASK", // extension - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("Layer"), - type: "ENUM", - output: -1, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(""), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Layer Weight"), - type: "LAYER_WEIGHT", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Blend"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Fresnel"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Facing"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Material"), - type: "MATERIAL", // extension - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Base Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Opacity"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Occlusion"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Roughness"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Metallic"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal Map"), - type: "VECTOR", - color: -10238109, - default_value: f32_array_create_xyz(0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Emission"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Height"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Subsurface"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("Material"), - type: "ENUM", - output: -1, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(""), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Object Info"), - type: "OBJECT_INFO", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Location"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Object Index"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Material Index"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Random"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Picker"), - type: "PICKER", // extension - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Base Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Opacity"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Occlusion"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Roughness"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Metallic"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal Map"), - type: "VECTOR", - color: -10238109, - default_value: f32_array_create_xyz(0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Emission"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Height"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Subsurface"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("RGB"), - type: "RGB", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.5, 0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("default_value"), - type: "RGBA", - output: 0, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Script"), - type: "SCRIPT_CPU", // extension - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: " ", - type: "STRING", - output: -1, - default_value: f32_array_create_x(0), // "", - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Shader"), - type: "SHADER_GPU", // extension - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: " ", - type: "STRING", - output: -1, - default_value: f32_array_create_x(0), // "", - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Tangent"), - type: "TANGENT", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Tangent"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Texture Coordinate"), - type: "TEX_COORD", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Generated"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("UV"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Object"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Camera"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Window"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Reflection"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [] - }, - { - id: 0, - name: _tr("UV Map"), - type: "UVMAP", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("UV"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Value"), - type: "VALUE", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("default_value"), - type: "VALUE", - output: 0, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 10.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Vertex Color"), - type: "VERTEX_COLOR", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Alpha"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Wireframe"), - type: "WIREFRAME", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Size"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.01), - min: 0.0, - max: 0.1, - precision: 100, - display: 0 - }, - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("Pixel Size"), - type: "BOOL", - output: 0, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, -]; - -// let nodes_material_output: ui_node_t[] = [ -// { -// id: 0, -// name: _tr("Material Output"), -// type: "OUTPUT_MATERIAL_PBR", -// x: 0, -// y: 0, -// color: 0xffb34f5a, -// inputs: [ -// { -// id: 0, -// node_id: 0, -// name: _tr("Base Color"), -// type: "RGBA", -// color: 0xffc7c729, -// default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), -// min: 0.0, -// max: 1.0, -// precision: 100, -// display: 0 -// }, -// { -// id: 0, -// node_id: 0, -// name: _tr("Opacity"), -// type: "VALUE", -// color: 0xffa1a1a1, -// default_value: f32_array_create_x(1.0), -// min: 0.0, -// max: 1.0, -// precision: 100, -// display: 0 -// }, -// { -// id: 0, -// node_id: 0, -// name: _tr("Occlusion"), -// type: "VALUE", -// color: 0xffa1a1a1, -// default_value: f32_array_create_x(1.0), -// min: 0.0, -// max: 1.0, -// precision: 100, -// display: 0 -// }, -// { -// id: 0, -// node_id: 0, -// name: _tr("Roughness"), -// type: "VALUE", -// color: 0xffa1a1a1, -// default_value: f32_array_create_x(0.1), -// min: 0.0, -// max: 1.0, -// precision: 100, -// display: 0 -// }, -// { -// id: 0, -// node_id: 0, -// name: _tr("Metallic"), -// type: "VALUE", -// color: 0xffa1a1a1, -// default_value: f32_array_create_x(0.0), -// min: 0.0, -// max: 1.0, -// precision: 100, -// display: 0 -// }, -// { -// id: 0, -// node_id: 0, -// name: _tr("Normal Map"), -// type: "VECTOR", -// color: -10238109, -// default_value: f32_array_create_xyz(0.5, 0.5, 1.0), -// min: 0.0, -// max: 1.0, -// precision: 100, -// display: 0 -// }, -// { -// id: 0, -// node_id: 0, -// name: _tr("Emission"), -// type: "VALUE", -// color: 0xffa1a1a1, -// default_value: f32_array_create_x(0.0), -// min: 0.0, -// max: 1.0, -// precision: 100, -// display: 0 -// }, -// { -// id: 0, -// node_id: 0, -// name: _tr("Height"), -// type: "VALUE", -// color: 0xffa1a1a1, -// default_value: f32_array_create_x(0.0), -// min: 0.0, -// max: 1.0, -// precision: 100, -// display: 0 -// }, -// { -// id: 0, -// node_id: 0, -// name: _tr("Subsurface"), -// type: "VALUE", -// color: 0xffa1a1a1, -// default_value: f32_array_create_x(0.0), -// min: 0.0, -// max: 1.0, -// precision: 100, -// display: 0 -// } -// ], -// outputs: [], -// buttons: [], -// width: 0, -// flags: 0 -// } -// ]; - -let nodes_material_texture: ui_node_t[] = [ - { - id: 0, - name: _tr("Brick Texture"), - type: "TEX_BRICK", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color 1"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyz(0.8, 0.8, 0.8), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color 2"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyz(0.2, 0.2, 0.2), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Mortar"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Scale"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(5.0), - min: 0.0, - max: 10.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Checker Texture"), - type: "TEX_CHECKER", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color 1"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyz(0.8, 0.8, 0.8), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color 2"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyz(0.2, 0.2, 0.2), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Scale"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(5.0), - min: 0.0, - max: 10.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Curvature Bake"), - type: "BAKE_CURVATURE", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Strength"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 2.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Radius"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 2.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Offset"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: -2.0, - max: 2.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Gradient Texture"), - type: "TEX_GRADIENT", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("gradient_type"), - type: "ENUM", - output: 0, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(_tr("Linear") + "\n" + _tr("Diagonal") + "\n" + _tr("Radial") + "\n" + _tr("Spherical")), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Image Texture"), - type: "TEX_IMAGE", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Alpha"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("File"), - type: "ENUM", - output: -1, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(""), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - }, - { - name: _tr("Color Space"), - type: "ENUM", - output: -1, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(_tr("Auto") + "\n" + _tr("Linear") + "\n" + _tr("sRGB") + "\n" + _tr("DirectX Normal Map")), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Text Texture"), - type: "TEX_TEXT", // extension - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Alpha"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: "text", - type: "STRING", - output: -1, - default_value: f32_array_create_x(0), // "", - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Magic Texture"), - type: "TEX_MAGIC", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Scale"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(5.0), - min: 0.0, - max: 10.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Musgrave Texture"), - type: "TEX_MUSGRAVE", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Scale"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(5.0), - min: 0.0, - max: 10.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Height"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Noise Texture"), - type: "TEX_NOISE", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Scale"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(5.0), - min: 0.0, - max: 10.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Voronoi Texture"), - type: "TEX_VORONOI", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Scale"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(5.0), - min: 0.0, - max: 10.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("coloring"), - type: "ENUM", - output: 0, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(_tr("Intensity") + "\n" + _tr("Cells")), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Wave Texture"), - type: "TEX_WAVE", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Scale"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(5.0), - min: 0.0, - max: 10.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - } -]; - -let nodes_material_color: ui_node_t[] = [ - { - id: 0, - name: _tr("Blur"), - type: "BLUR", // extension - x: 0, - y: 0, - color: 0xff448c6d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Strength"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Brightness/Contrast"), - type: "BRIGHTCONTRAST", - x: 0, - y: 0, - color: 0xff448c6d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Bright"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Contrast"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Gamma"), - type: "GAMMA", - x: 0, - y: 0, - color: 0xff448c6d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Gamma"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Hue/Saturation/Value"), - type: "HUE_SAT", - x: 0, - y: 0, - color: 0xff448c6d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Hue"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Saturation"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Invert"), - type: "INVERT", - x: 0, - y: 0, - color: 0xff448c6d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Mix Color"), - type: "MIX_RGB", - x: 0, - y: 0, - color: 0xff448c6d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color 1"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.5, 0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color 2"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.5, 0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("blend_type"), - type: "ENUM", - output: 0, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(_tr("Mix") + "\n" + _tr("Darken") + "\n" + _tr("Multiply") + "\n" + _tr("Burn") + "\n" + _tr("Lighten") + "\n" + _tr("Screen") + "\n" + _tr("Dodge") + "\n" + _tr("Add") + "\n" + _tr("Overlay") + "\n" + _tr("Soft Light") + "\n" + _tr("Linear Light") + "\n" + _tr("Difference") + "\n" + _tr("Subtract") + "\n" + _tr("Divide") + "\n" + _tr("Hue") + "\n" + _tr("Saturation") + "\n" + _tr("Color") + "\n" + _tr("Value")), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - }, - { - name: _tr("use_clamp"), - type: "BOOL", - output: 0, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Quantize"), - type: "QUANTIZE", // extension - x: 0, - y: 0, - color: 0xff448c6d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Strength"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.1), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Replace Color"), - type: "REPLACECOL", // extension - x: 0, - y: 0, - color: 0xff448c6d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0) - }, - { - id: 0, - node_id: 0, - name: _tr("Old Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0) - }, - { - id: 0, - node_id: 0, - name: _tr("New Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0) - }, - { - id: 0, - node_id: 0, - name: _tr("Radius"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.1), - min: 0.0, - max: 1.74, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fuzziness"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0) - } - ], - buttons: [] - }, - { - id: 0, - name: _tr("Warp"), - type: "DIRECT_WARP", // extension - x: 0, - y: 0, - color: 0xff448c6d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Angle"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 360.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Mask"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - } -]; - -let nodes_material_vector: ui_node_t[] = [ - { - id: 0, - name: _tr("Bump"), - type: "BUMP", - x: 0, - y: 0, - color: 0xff522c99, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Strength"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Distance"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Height"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Normal Map"), - type: "VECTOR", - color: -10238109, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Mapping"), - type: "MAPPING", - x: 0, - y: 0, - color: 0xff522c99, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Location"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 1 - }, - { - id: 0, - node_id: 0, - name: _tr("Rotation"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 360.0, - precision: 100, - display: 1 - }, - { - id: 0, - node_id: 0, - name: _tr("Scale"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(1.0, 1.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 1 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Mix Normal Map"), - type: "MIX_NORMAL_MAP", // extension - x: 0, - y: 0, - color: 0xff522c99, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Normal Map 1"), - type: "VECTOR", - color: -10238109, - default_value: f32_array_create_xyz(0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal Map 2"), - type: "VECTOR", - color: -10238109, - default_value: f32_array_create_xyz(0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Normal Map"), - type: "VECTOR", - color: -10238109, - default_value: f32_array_create_xyz(0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("blend_type"), - type: "ENUM", - output: 0, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(_tr("Partial Derivative") + "\n" + _tr("Whiteout") + "\n" + _tr("Reoriented")), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Normal"), - type: "NORMAL", - x: 0, - y: 0, - color: 0xff522c99, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Normal"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Normal"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Dot"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("Vector"), - type: "VECTOR", - output: 0, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Normal Map"), - type: "NORMAL_MAP", - x: 0, - y: 0, - color: 0xff522c99, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Strength"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 2.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal Map"), - type: "VECTOR", - color: -10238109, - default_value: f32_array_create_xyz(0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Normal Map"), - type: "VECTOR", - color: -10238109, - default_value: f32_array_create_xyz(0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Vector Curves"), - type: "CURVE_VEC", - x: 0, - y: 0, - color: 0xff522c99, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: "nodes_material_vector_curves_button", - type: "CUSTOM", - output: 0, - default_value: f32_array_create(96 + 3), // x - [0, 32], y - [33, 64], z - [65, 96], x_len, y_len, z_len - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 8.5 - } - ], - width: 0, - flags: 0 - } -]; - -let nodes_material_converter: ui_node_t[] = [ - { - id: 0, - name: _tr("Clamp"), - type: "CLAMP", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Min"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Max"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("operation"), - type: "ENUM", - output: 0, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(_tr("Min Max") + "\n" + _tr("Range")), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Color Ramp"), - type: "VALTORGB", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Fac"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Alpha"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: "nodes_material_color_ramp_button", - type: "CUSTOM", - output: 0, - default_value: f32_array_create_xyzwv(1.0, 1.0, 1.0, 1.0, 0.0), - data: u8_array_create(1), - min: 0.0, - max: 1.0, - precision: 100, - height: 4.5 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Color Mask"), - type: "COLMASK", // extension - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Mask Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Radius"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.1), - min: 0.0, - max: 1.74, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Fuzziness"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Mask"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Combine HSV"), - type: "COMBHSV", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("H"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("S"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("V"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Combine RGB"), - type: "COMBRGB", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("R"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("G"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("B"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Combine XYZ"), - type: "COMBXYZ", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("X"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Y"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Z"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Map Range"), - type: "MAPRANGE", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("From Min"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("From Max"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("To Min"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("To Max"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("use_clamp"), - type: "BOOL", - output: 0, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Math"), - type: "MATH", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("operation"), - type: "ENUM", - output: 0, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(_tr("Add") + "\n" + _tr("Subtract") + "\n" + _tr("Multiply") + "\n" + _tr("Divide") + "\n" + _tr("Power") + "\n" + _tr("Logarithm") + "\n" + _tr("Square Root") + "\n" + _tr("Inverse Square Root") + "\n" + _tr("Absolute") + "\n" + _tr("Exponent") + "\n" + _tr("Minimum") + "\n" + _tr("Maximum") + "\n" + _tr("Less Than") + "\n" + _tr("Greater Than") + "\n" + _tr("Sign") + "\n" + _tr("Round") + "\n" + _tr("Floor") + "\n" + _tr("Ceil") + "\n" + _tr("Truncate") + "\n" + _tr("Fraction") + "\n" + _tr("Modulo") + "\n" + _tr("Snap") + "\n" + _tr("Ping-Pong") + "\n" + _tr("Sine") + "\n" + _tr("Cosine") + "\n" + _tr("Tangent") + "\n" + _tr("Arcsine") + "\n" + _tr("Arccosine") + "\n" + _tr("Arctangent") + "\n" + _tr("Arctan2") + "\n" + _tr("Hyperbolic Sine") + "\n" + _tr("Hyperbolic Cosine") + "\n" + _tr("Hyperbolic Tangent") + "\n" + _tr("To Radians") + "\n" + _tr("To Degrees")), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - }, - { - name: _tr("use_clamp"), - type: "BOOL", - output: 0, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("RGB to BW"), - type: "RGBTOBW", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Val"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Separate HSV"), - type: "SEPHSV", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.5, 0.5, 0.5, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("H"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("S"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("V"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Separate RGB"), - type: "SEPRGB", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("R"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("G"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("B"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Separate XYZ"), - type: "SEPXYZ", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("X"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Y"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Z"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Vector Math"), - type: "VECT_MATH", - x: 0, - y: 0, - color: 0xff62676d, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 1 - }, - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 1 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Vector"), - type: "VECTOR", - color: 0xff6363c7, - default_value: f32_array_create_xyz(0.0, 0.0, 0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Value"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("operation"), - type: "ENUM", - output: 0, - default_value: f32_array_create_x(0), - data: u8_array_create_from_string(_tr("Add") + "\n" + _tr("Subtract") + "\n" + _tr("Multiply") + "\n" + _tr("Divide") + "\n" + _tr("Average") + "\n" + _tr("Cross Product") + "\n" + _tr("Project") + "\n" + _tr("Reflect") + "\n" + _tr("Dot Product") + "\n" + _tr("Distance") + "\n" + _tr("Length") + "\n" + _tr("Scale") + "\n" + _tr("Normalize") + "\n" + _tr("Absolute") + "\n" + _tr("Minimum") + "\n" + _tr("Maximum") + "\n" + _tr("Floor") + "\n" + _tr("Ceil") + "\n" + _tr("Fraction") + "\n" + _tr("Modulo") + "\n" + _tr("Snap") + "\n" + _tr("Sine") + "\n" + _tr("Cosine") + "\n" + _tr("Tangent")), - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - } -]; - -let nodes_material_neural: ui_node_t[] = [ - { - id: 0, - name: _tr("Text to Photo"), - type: "text_to_photo_node", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("tiling"), - type: "BOOL", - output: 0, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - }, - { - name: "text_to_photo_node_button", - type: "CUSTOM", - output: -1, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 1 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Inpaint"), - type: "inpaint_node", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(1.0, 1.0, 1.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("auto"), - type: "BOOL", - output: 0, - default_value: f32_array_create_x(1), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - }, - { - name: "inpaint_node_button", - type: "CUSTOM", - output: -1, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Photo to PBR"), - type: "photo_to_pbr_node", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Base Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Occlusion"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Roughness"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Metallic"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Normal Map"), - type: "VECTOR", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Height"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Tiling"), - type: "tiling_node", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: _tr("auto"), - type: "BOOL", - output: 0, - default_value: f32_array_create_x(1), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - }, - { - name: "tiling_node_button", - type: "CUSTOM", - output: -1, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 0 - } - ], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Upscale"), - type: "upscale_node", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [], - width: 0, - flags: 0 - }, - { - id: 0, - name: _tr("Variance"), - type: "variance_node", - x: 0, - y: 0, - color: 0xff4982a0, - inputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - }, - { - id: 0, - node_id: 0, - name: _tr("Strength"), - type: "VALUE", - color: 0xffa1a1a1, - default_value: f32_array_create_x(0.5), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - outputs: [ - { - id: 0, - node_id: 0, - name: _tr("Color"), - type: "RGBA", - color: 0xffc7c729, - default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), - min: 0.0, - max: 1.0, - precision: 100, - display: 0 - } - ], - buttons: [ - { - name: "variance_node_button", - type: "CUSTOM", - output: -1, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 1 - } - ], - width: 0, - flags: 0 - } -]; - -let nodes_material_group: ui_node_t[] = [ - { - id: 0, - name: _tr("New Group"), - type: "GROUP", - x: 0, - y: 0, - color: 0xffb34f5a, - inputs: [], - outputs: [], - buttons: [ - { - name: "nodes_material_new_group_button", - type: "CUSTOM", - output: -1, - default_value: f32_array_create_x(0), - data: null, - min: 0.0, - max: 1.0, - precision: 100, - height: 1 - } - ], - width: 0, - flags: 0 - } -]; - -type node_list_t = ui_node_t[]; - -let nodes_material_list: node_list_t[] = [ - nodes_material_input, - nodes_material_texture, - nodes_material_color, - nodes_material_vector, - nodes_material_converter, - // nodes_material_neural, - nodes_material_group -]; - let _nodes_material_nodes: ui_nodes_t; let _nodes_material_node: ui_node_t; let _nodes_material_sockets: ui_node_socket_t[]; diff --git a/paint/sources/nodes_material_def.ts b/paint/sources/nodes_material_def.ts new file mode 100644 index 00000000..6bcd578f --- /dev/null +++ b/paint/sources/nodes_material_def.ts @@ -0,0 +1,4410 @@ + +let nodes_material_categories: string[] = [ + _tr("Input"), + _tr("Texture"), + _tr("Color"), + _tr("Vector"), + _tr("Converter"), + // _tr("Neural"), + _tr("Group") +]; + +let nodes_material_input: ui_node_t[] = [ + { + id: 0, + name: _tr("Attribute"), + type: "ATTRIBUTE", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("Name"), + type: "STRING", + output: -1, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Camera Data"), + type: "CAMERA", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("View Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("View Z Depth"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("View Distance"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Fresnel"), + type: "FRESNEL", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("IOR"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.45), + min: 0.0, + max: 3.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Geometry"), + type: "NEW_GEOMETRY", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Position"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Tangent"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("True Normal"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Incoming"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Parametric"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Backfacing"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Pointiness"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Random Per Island"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Layer"), + type: "LAYER", // extension + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Base Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Opacity"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Occlusion"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Roughness"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Metallic"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal Map"), + type: "VECTOR", + color: -10238109, + default_value: f32_array_create_xyz(0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Emission"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Height"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Subsurface"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("Layer"), + type: "ENUM", + output: -1, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(""), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Layer Mask"), + type: "LAYER_MASK", // extension + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("Layer"), + type: "ENUM", + output: -1, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(""), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Layer Weight"), + type: "LAYER_WEIGHT", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Blend"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Fresnel"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Facing"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Material"), + type: "MATERIAL", // extension + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Base Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Opacity"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Occlusion"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Roughness"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Metallic"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal Map"), + type: "VECTOR", + color: -10238109, + default_value: f32_array_create_xyz(0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Emission"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Height"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Subsurface"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("Material"), + type: "ENUM", + output: -1, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(""), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Object Info"), + type: "OBJECT_INFO", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Location"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Object Index"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Material Index"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Random"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Picker"), + type: "PICKER", // extension + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Base Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Opacity"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Occlusion"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Roughness"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Metallic"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal Map"), + type: "VECTOR", + color: -10238109, + default_value: f32_array_create_xyz(0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Emission"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Height"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Subsurface"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("RGB"), + type: "RGB", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.5, 0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("default_value"), + type: "RGBA", + output: 0, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Script"), + type: "SCRIPT_CPU", // extension + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: " ", + type: "STRING", + output: -1, + default_value: f32_array_create_x(0), // "", + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Shader"), + type: "SHADER_GPU", // extension + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: " ", + type: "STRING", + output: -1, + default_value: f32_array_create_x(0), // "", + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Tangent"), + type: "TANGENT", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Tangent"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Texture Coordinate"), + type: "TEX_COORD", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Generated"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("UV"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Object"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Camera"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Window"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Reflection"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [] + }, + { + id: 0, + name: _tr("UV Map"), + type: "UVMAP", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("UV"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Value"), + type: "VALUE", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("default_value"), + type: "VALUE", + output: 0, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 10.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Vertex Color"), + type: "VERTEX_COLOR", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Alpha"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Wireframe"), + type: "WIREFRAME", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Size"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.01), + min: 0.0, + max: 0.1, + precision: 100, + display: 0 + }, + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("Pixel Size"), + type: "BOOL", + output: 0, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, +]; + +// let nodes_material_output: ui_node_t[] = [ +// { +// id: 0, +// name: _tr("Material Output"), +// type: "OUTPUT_MATERIAL_PBR", +// x: 0, +// y: 0, +// color: 0xffb34f5a, +// inputs: [ +// { +// id: 0, +// node_id: 0, +// name: _tr("Base Color"), +// type: "RGBA", +// color: 0xffc7c729, +// default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), +// min: 0.0, +// max: 1.0, +// precision: 100, +// display: 0 +// }, +// { +// id: 0, +// node_id: 0, +// name: _tr("Opacity"), +// type: "VALUE", +// color: 0xffa1a1a1, +// default_value: f32_array_create_x(1.0), +// min: 0.0, +// max: 1.0, +// precision: 100, +// display: 0 +// }, +// { +// id: 0, +// node_id: 0, +// name: _tr("Occlusion"), +// type: "VALUE", +// color: 0xffa1a1a1, +// default_value: f32_array_create_x(1.0), +// min: 0.0, +// max: 1.0, +// precision: 100, +// display: 0 +// }, +// { +// id: 0, +// node_id: 0, +// name: _tr("Roughness"), +// type: "VALUE", +// color: 0xffa1a1a1, +// default_value: f32_array_create_x(0.1), +// min: 0.0, +// max: 1.0, +// precision: 100, +// display: 0 +// }, +// { +// id: 0, +// node_id: 0, +// name: _tr("Metallic"), +// type: "VALUE", +// color: 0xffa1a1a1, +// default_value: f32_array_create_x(0.0), +// min: 0.0, +// max: 1.0, +// precision: 100, +// display: 0 +// }, +// { +// id: 0, +// node_id: 0, +// name: _tr("Normal Map"), +// type: "VECTOR", +// color: -10238109, +// default_value: f32_array_create_xyz(0.5, 0.5, 1.0), +// min: 0.0, +// max: 1.0, +// precision: 100, +// display: 0 +// }, +// { +// id: 0, +// node_id: 0, +// name: _tr("Emission"), +// type: "VALUE", +// color: 0xffa1a1a1, +// default_value: f32_array_create_x(0.0), +// min: 0.0, +// max: 1.0, +// precision: 100, +// display: 0 +// }, +// { +// id: 0, +// node_id: 0, +// name: _tr("Height"), +// type: "VALUE", +// color: 0xffa1a1a1, +// default_value: f32_array_create_x(0.0), +// min: 0.0, +// max: 1.0, +// precision: 100, +// display: 0 +// }, +// { +// id: 0, +// node_id: 0, +// name: _tr("Subsurface"), +// type: "VALUE", +// color: 0xffa1a1a1, +// default_value: f32_array_create_x(0.0), +// min: 0.0, +// max: 1.0, +// precision: 100, +// display: 0 +// } +// ], +// outputs: [], +// buttons: [], +// width: 0, +// flags: 0 +// } +// ]; + +let nodes_material_texture: ui_node_t[] = [ + { + id: 0, + name: _tr("Brick Texture"), + type: "TEX_BRICK", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color 1"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyz(0.8, 0.8, 0.8), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color 2"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyz(0.2, 0.2, 0.2), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Mortar"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Scale"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(5.0), + min: 0.0, + max: 10.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Checker Texture"), + type: "TEX_CHECKER", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color 1"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyz(0.8, 0.8, 0.8), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color 2"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyz(0.2, 0.2, 0.2), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Scale"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(5.0), + min: 0.0, + max: 10.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Curvature Bake"), + type: "BAKE_CURVATURE", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Strength"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 2.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Radius"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 2.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Offset"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: -2.0, + max: 2.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Gradient Texture"), + type: "TEX_GRADIENT", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("gradient_type"), + type: "ENUM", + output: 0, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Linear") + "\n" + _tr("Diagonal") + "\n" + _tr("Radial") + "\n" + _tr("Spherical")), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Image Texture"), + type: "TEX_IMAGE", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Alpha"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("File"), + type: "ENUM", + output: -1, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(""), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + }, + { + name: _tr("Color Space"), + type: "ENUM", + output: -1, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Auto") + "\n" + _tr("Linear") + "\n" + _tr("sRGB") + "\n" + _tr("DirectX Normal Map")), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Text Texture"), + type: "TEX_TEXT", // extension + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Alpha"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: "text", + type: "STRING", + output: -1, + default_value: f32_array_create_x(0), // "", + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Magic Texture"), + type: "TEX_MAGIC", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Scale"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(5.0), + min: 0.0, + max: 10.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Musgrave Texture"), + type: "TEX_MUSGRAVE", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Scale"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(5.0), + min: 0.0, + max: 10.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Height"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Noise Texture"), + type: "TEX_NOISE", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Scale"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(5.0), + min: 0.0, + max: 10.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Voronoi Texture"), + type: "TEX_VORONOI", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Scale"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(5.0), + min: 0.0, + max: 10.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("coloring"), + type: "ENUM", + output: 0, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Intensity") + "\n" + _tr("Cells")), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Wave Texture"), + type: "TEX_WAVE", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Scale"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(5.0), + min: 0.0, + max: 10.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + } +]; + +let nodes_material_color: ui_node_t[] = [ + { + id: 0, + name: _tr("Blur"), + type: "BLUR", // extension + x: 0, + y: 0, + color: 0xff448c6d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Strength"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Brightness/Contrast"), + type: "BRIGHTCONTRAST", + x: 0, + y: 0, + color: 0xff448c6d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Bright"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Contrast"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Gamma"), + type: "GAMMA", + x: 0, + y: 0, + color: 0xff448c6d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Gamma"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Hue/Saturation/Value"), + type: "HUE_SAT", + x: 0, + y: 0, + color: 0xff448c6d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Hue"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Saturation"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Invert"), + type: "INVERT", + x: 0, + y: 0, + color: 0xff448c6d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Mix Color"), + type: "MIX_RGB", + x: 0, + y: 0, + color: 0xff448c6d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color 1"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.5, 0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color 2"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.5, 0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("blend_type"), + type: "ENUM", + output: 0, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Mix") + "\n" + _tr("Darken") + "\n" + _tr("Multiply") + "\n" + _tr("Burn") + "\n" + _tr("Lighten") + "\n" + _tr("Screen") + "\n" + _tr("Dodge") + "\n" + _tr("Add") + "\n" + _tr("Overlay") + "\n" + _tr("Soft Light") + "\n" + _tr("Linear Light") + "\n" + _tr("Difference") + "\n" + _tr("Subtract") + "\n" + _tr("Divide") + "\n" + _tr("Hue") + "\n" + _tr("Saturation") + "\n" + _tr("Color") + "\n" + _tr("Value")), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + }, + { + name: _tr("use_clamp"), + type: "BOOL", + output: 0, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Quantize"), + type: "QUANTIZE", // extension + x: 0, + y: 0, + color: 0xff448c6d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Strength"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.1), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Replace Color"), + type: "REPLACECOL", // extension + x: 0, + y: 0, + color: 0xff448c6d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0) + }, + { + id: 0, + node_id: 0, + name: _tr("Old Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0) + }, + { + id: 0, + node_id: 0, + name: _tr("New Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0) + }, + { + id: 0, + node_id: 0, + name: _tr("Radius"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.1), + min: 0.0, + max: 1.74, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fuzziness"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0) + } + ], + buttons: [] + }, + { + id: 0, + name: _tr("Warp"), + type: "DIRECT_WARP", // extension + x: 0, + y: 0, + color: 0xff448c6d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Angle"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 360.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Mask"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + } +]; + +let nodes_material_vector: ui_node_t[] = [ + { + id: 0, + name: _tr("Bump"), + type: "BUMP", + x: 0, + y: 0, + color: 0xff522c99, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Strength"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Distance"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Height"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Normal Map"), + type: "VECTOR", + color: -10238109, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Mapping"), + type: "MAPPING", + x: 0, + y: 0, + color: 0xff522c99, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Location"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 1 + }, + { + id: 0, + node_id: 0, + name: _tr("Rotation"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 360.0, + precision: 100, + display: 1 + }, + { + id: 0, + node_id: 0, + name: _tr("Scale"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(1.0, 1.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 1 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Mix Normal Map"), + type: "MIX_NORMAL_MAP", // extension + x: 0, + y: 0, + color: 0xff522c99, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Normal Map 1"), + type: "VECTOR", + color: -10238109, + default_value: f32_array_create_xyz(0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal Map 2"), + type: "VECTOR", + color: -10238109, + default_value: f32_array_create_xyz(0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Normal Map"), + type: "VECTOR", + color: -10238109, + default_value: f32_array_create_xyz(0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("blend_type"), + type: "ENUM", + output: 0, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Partial Derivative") + "\n" + _tr("Whiteout") + "\n" + _tr("Reoriented")), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Normal"), + type: "NORMAL", + x: 0, + y: 0, + color: 0xff522c99, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Normal"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Normal"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Dot"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("Vector"), + type: "VECTOR", + output: 0, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Normal Map"), + type: "NORMAL_MAP", + x: 0, + y: 0, + color: 0xff522c99, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Strength"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 2.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal Map"), + type: "VECTOR", + color: -10238109, + default_value: f32_array_create_xyz(0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Normal Map"), + type: "VECTOR", + color: -10238109, + default_value: f32_array_create_xyz(0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Vector Curves"), + type: "CURVE_VEC", + x: 0, + y: 0, + color: 0xff522c99, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: "nodes_material_vector_curves_button", + type: "CUSTOM", + output: 0, + default_value: f32_array_create(96 + 3), // x - [0, 32], y - [33, 64], z - [65, 96], x_len, y_len, z_len + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 8.5 + } + ], + width: 0, + flags: 0 + } +]; + +let nodes_material_converter: ui_node_t[] = [ + { + id: 0, + name: _tr("Clamp"), + type: "CLAMP", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Min"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Max"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("operation"), + type: "ENUM", + output: 0, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Min Max") + "\n" + _tr("Range")), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Color Ramp"), + type: "VALTORGB", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Fac"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Alpha"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: "nodes_material_color_ramp_button", + type: "CUSTOM", + output: 0, + default_value: f32_array_create_xyzwv(1.0, 1.0, 1.0, 1.0, 0.0), + data: u8_array_create(1), + min: 0.0, + max: 1.0, + precision: 100, + height: 4.5 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Color Mask"), + type: "COLMASK", // extension + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Mask Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Radius"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.1), + min: 0.0, + max: 1.74, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Fuzziness"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Mask"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Combine HSV"), + type: "COMBHSV", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("H"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("S"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("V"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Combine RGB"), + type: "COMBRGB", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("R"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("G"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("B"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Combine XYZ"), + type: "COMBXYZ", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("X"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Y"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Z"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Map Range"), + type: "MAPRANGE", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("From Min"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("From Max"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("To Min"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("To Max"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("use_clamp"), + type: "BOOL", + output: 0, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Math"), + type: "MATH", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("operation"), + type: "ENUM", + output: 0, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Add") + "\n" + _tr("Subtract") + "\n" + _tr("Multiply") + "\n" + _tr("Divide") + "\n" + _tr("Power") + "\n" + _tr("Logarithm") + "\n" + _tr("Square Root") + "\n" + _tr("Inverse Square Root") + "\n" + _tr("Absolute") + "\n" + _tr("Exponent") + "\n" + _tr("Minimum") + "\n" + _tr("Maximum") + "\n" + _tr("Less Than") + "\n" + _tr("Greater Than") + "\n" + _tr("Sign") + "\n" + _tr("Round") + "\n" + _tr("Floor") + "\n" + _tr("Ceil") + "\n" + _tr("Truncate") + "\n" + _tr("Fraction") + "\n" + _tr("Modulo") + "\n" + _tr("Snap") + "\n" + _tr("Ping-Pong") + "\n" + _tr("Sine") + "\n" + _tr("Cosine") + "\n" + _tr("Tangent") + "\n" + _tr("Arcsine") + "\n" + _tr("Arccosine") + "\n" + _tr("Arctangent") + "\n" + _tr("Arctan2") + "\n" + _tr("Hyperbolic Sine") + "\n" + _tr("Hyperbolic Cosine") + "\n" + _tr("Hyperbolic Tangent") + "\n" + _tr("To Radians") + "\n" + _tr("To Degrees")), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + }, + { + name: _tr("use_clamp"), + type: "BOOL", + output: 0, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("RGB to BW"), + type: "RGBTOBW", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Val"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Separate HSV"), + type: "SEPHSV", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.5, 0.5, 0.5, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("H"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("S"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("V"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Separate RGB"), + type: "SEPRGB", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("R"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("G"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("B"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Separate XYZ"), + type: "SEPXYZ", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("X"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Y"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Z"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Vector Math"), + type: "VECT_MATH", + x: 0, + y: 0, + color: 0xff62676d, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 1 + }, + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 1 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Vector"), + type: "VECTOR", + color: 0xff6363c7, + default_value: f32_array_create_xyz(0.0, 0.0, 0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Value"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("operation"), + type: "ENUM", + output: 0, + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Add") + "\n" + _tr("Subtract") + "\n" + _tr("Multiply") + "\n" + _tr("Divide") + "\n" + _tr("Average") + "\n" + _tr("Cross Product") + "\n" + _tr("Project") + "\n" + _tr("Reflect") + "\n" + _tr("Dot Product") + "\n" + _tr("Distance") + "\n" + _tr("Length") + "\n" + _tr("Scale") + "\n" + _tr("Normalize") + "\n" + _tr("Absolute") + "\n" + _tr("Minimum") + "\n" + _tr("Maximum") + "\n" + _tr("Floor") + "\n" + _tr("Ceil") + "\n" + _tr("Fraction") + "\n" + _tr("Modulo") + "\n" + _tr("Snap") + "\n" + _tr("Sine") + "\n" + _tr("Cosine") + "\n" + _tr("Tangent")), + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + } +]; + +let nodes_material_neural: ui_node_t[] = [ + { + id: 0, + name: _tr("Text to Photo"), + type: "text_to_photo_node", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("tiling"), + type: "BOOL", + output: 0, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + }, + { + name: "text_to_photo_node_button", + type: "CUSTOM", + output: -1, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 1 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Inpaint"), + type: "inpaint_node", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(1.0, 1.0, 1.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("auto"), + type: "BOOL", + output: 0, + default_value: f32_array_create_x(1), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + }, + { + name: "inpaint_node_button", + type: "CUSTOM", + output: -1, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Photo to PBR"), + type: "photo_to_pbr_node", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Base Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Occlusion"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Roughness"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Metallic"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Normal Map"), + type: "VECTOR", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Height"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Tiling"), + type: "tiling_node", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: _tr("auto"), + type: "BOOL", + output: 0, + default_value: f32_array_create_x(1), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + }, + { + name: "tiling_node_button", + type: "CUSTOM", + output: -1, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 0 + } + ], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Upscale"), + type: "upscale_node", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [], + width: 0, + flags: 0 + }, + { + id: 0, + name: _tr("Variance"), + type: "variance_node", + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + }, + { + id: 0, + node_id: 0, + name: _tr("Strength"), + type: "VALUE", + color: 0xffa1a1a1, + default_value: f32_array_create_x(0.5), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: _tr("Color"), + type: "RGBA", + color: 0xffc7c729, + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), + min: 0.0, + max: 1.0, + precision: 100, + display: 0 + } + ], + buttons: [ + { + name: "variance_node_button", + type: "CUSTOM", + output: -1, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 1 + } + ], + width: 0, + flags: 0 + } +]; + +let nodes_material_group: ui_node_t[] = [ + { + id: 0, + name: _tr("New Group"), + type: "GROUP", + x: 0, + y: 0, + color: 0xffb34f5a, + inputs: [], + outputs: [], + buttons: [ + { + name: "nodes_material_new_group_button", + type: "CUSTOM", + output: -1, + default_value: f32_array_create_x(0), + data: null, + min: 0.0, + max: 1.0, + precision: 100, + height: 1 + } + ], + width: 0, + flags: 0 + } +]; + +type node_list_t = ui_node_t[]; + +let nodes_material_list: node_list_t[] = [ + nodes_material_input, + nodes_material_texture, + nodes_material_color, + nodes_material_vector, + nodes_material_converter, + // nodes_material_neural, + nodes_material_group +]; diff --git a/paint/sources/project.ts b/paint/sources/project.ts index 7b92a2cb..a5bf5c57 100644 --- a/paint/sources/project.ts +++ b/paint/sources/project.ts @@ -9,14 +9,12 @@ let project_material_groups: node_group_t[] = []; let project_paint_objects: mesh_object_t[] = null; let project_asset_map: map_t = map_create(); // gpu_texture_t | font_t let project_mesh_list: string[] = null; - let project_materials: slot_material_t[] = []; let project_brushes: slot_brush_t[] = []; let project_layers: slot_layer_t[] = []; let project_fonts: slot_font_t[] = []; let project_atlas_objects: i32[] = null; let project_atlas_names: string[] = null; - let _project_save_and_quit: bool; let _project_import_mesh_replace_existing: bool; let _project_import_mesh_done: ()=>void; diff --git a/paint/sources/slot_layer.ts b/paint/sources/slot_layer.ts index fcbeca1d..3c215cfe 100644 --- a/paint/sources/slot_layer.ts +++ b/paint/sources/slot_layer.ts @@ -763,3 +763,941 @@ function slot_layer_move(raw: slot_layer_t, to: i32) { tab_layers_remap_layer_pointers(m.canvas.nodes, tab_layers_fill_layer_map(pointers)); } } + + +let layers_temp_image: gpu_texture_t = null; +let layers_expa: gpu_texture_t = null; +let layers_expb: gpu_texture_t = null; +let layers_expc: gpu_texture_t = null; +let layers_default_base: f32 = 0.5; +let layers_default_rough: f32 = 0.4; +let layers_max_layers: i32 = +///if (arm_android || arm_ios) + 18; +///else + 255; +///end + +let _layers_uv_type: uv_type_t; +let _layers_decal_mat: mat4_t; +let _layers_position: i32; +let _layers_base_color: i32; +let _layers_occlusion: f32; +let _layers_roughness: f32; +let _layers_metallic: f32; + +function layers_init() { + slot_layer_clear(project_layers[0], color_from_floats(layers_default_base, layers_default_base, layers_default_base, 1.0)); +} + +function layers_resize() { + let conf: config_t = config_raw; + if (base_res_handle.i >= math_floor(texture_res_t.RES16384)) { // Save memory for >=16k + conf.undo_steps = 1; + if (context_raw.undo_handle != null) { + context_raw.undo_handle.f = conf.undo_steps; + } + while (history_undo_layers.length > conf.undo_steps) { + let l: slot_layer_t = array_pop(history_undo_layers); + sys_notify_on_next_frame(function (l: slot_layer_t) { + slot_layer_unload(l); + }, l); + } + } + for (let i: i32 = 0; i < project_layers.length; ++i) { + let l: slot_layer_t = project_layers[i]; + slot_layer_resize_and_set_bits(l); + } + for (let i: i32 = 0; i < history_undo_layers.length; ++i) { + let l: slot_layer_t = history_undo_layers[i]; + slot_layer_resize_and_set_bits(l); + } + + let rts: map_t = render_path_render_targets; + + let blend0: render_target_t = map_get(rts, "texpaint_blend0"); + let _texpaint_blend0: gpu_texture_t = blend0._image; + gpu_delete_texture(_texpaint_blend0); + blend0.width = config_get_texture_res_x(); + blend0.height = config_get_texture_res_y(); + blend0._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + + let blend1: render_target_t = map_get(rts, "texpaint_blend1"); + let _texpaint_blend1: gpu_texture_t = blend1._image; + gpu_delete_texture(_texpaint_blend1); + blend1.width = config_get_texture_res_x(); + blend1.height = config_get_texture_res_y(); + blend1._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + + context_raw.brush_blend_dirty = true; + + let blur: render_target_t = map_get(rts, "texpaint_blur"); + if (blur != null) { + let _texpaint_blur: gpu_texture_t = blur._image; + gpu_delete_texture(_texpaint_blur); + let size_x: f32 = math_floor(config_get_texture_res_x() * 0.95); + let size_y: f32 = math_floor(config_get_texture_res_y() * 0.95); + blur.width = size_x; + blur.height = size_y; + blur._image = gpu_create_render_target(size_x, size_y); + } + if (render_path_paint_live_layer != null) { + slot_layer_resize_and_set_bits(render_path_paint_live_layer); + } + render_path_raytrace_ready = false; // Rebuild baketex + context_raw.ddirty = 2; +} + +function layers_set_bits() { + for (let i: i32 = 0; i < project_layers.length; ++i) { + let l: slot_layer_t = project_layers[i]; + slot_layer_resize_and_set_bits(l); + } + for (let i: i32 = 0; i < history_undo_layers.length; ++i) { + let l: slot_layer_t = history_undo_layers[i]; + slot_layer_resize_and_set_bits(l); + } +} + +function layers_make_temp_img() { + let l: slot_layer_t = project_layers[0]; + + if (layers_temp_image != null && (layers_temp_image.width != l.texpaint.width || layers_temp_image.height != l.texpaint.height || layers_temp_image.format != l.texpaint.format)) { + let _temptex0: render_target_t = map_get(render_path_render_targets, "temptex0"); + render_target_unload(_temptex0); + map_delete(render_path_render_targets, "temptex0"); + layers_temp_image = null; + } + if (layers_temp_image == null) { + let format: string = base_bits_handle.i == texture_bits_t.BITS8 ? "RGBA32" : + base_bits_handle.i == texture_bits_t.BITS16 ? "RGBA64" : + "RGBA128"; + + let t: render_target_t = render_target_create(); + t.name = "temptex0"; + t.width = l.texpaint.width; + t.height = l.texpaint.height; + t.format = format; + let rt: render_target_t = render_path_create_render_target(t); + layers_temp_image = rt._image; + } +} + +function layers_make_temp_mask_img() { + 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: gpu_texture_t = pipes_temp_mask_image; + gpu_delete_texture(_temp_mask_image); + pipes_temp_mask_image = null; + } + if (pipes_temp_mask_image == null) { + pipes_temp_mask_image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + } +} + +function layers_make_export_img() { + let l: slot_layer_t = project_layers[0]; + + if (layers_expa != null && (layers_expa.width != l.texpaint.width || layers_expa.height != l.texpaint.height || layers_expa.format != l.texpaint.format)) { + let _expa: gpu_texture_t = layers_expa; + let _expb: gpu_texture_t = layers_expb; + let _expc: gpu_texture_t = layers_expc; + gpu_delete_texture(_expa); + gpu_delete_texture(_expb); + gpu_delete_texture(_expc); + layers_expa = null; + layers_expb = null; + layers_expc = null; + map_delete(render_path_render_targets, "expa"); + map_delete(render_path_render_targets, "expb"); + map_delete(render_path_render_targets, "expc"); + } + if (layers_expa == null) { + let format: string = base_bits_handle.i == texture_bits_t.BITS8 ? "RGBA32" : + base_bits_handle.i == texture_bits_t.BITS16 ? "RGBA64" : + "RGBA128"; + + + { + let t: render_target_t = render_target_create(); + t.name = "expa"; + t.width = l.texpaint.width; + t.height = l.texpaint.height; + t.format = format; + let rt: render_target_t = render_path_create_render_target(t); + layers_expa = rt._image; + } + + { + let t: render_target_t = render_target_create(); + t.name = "expb"; + t.width = l.texpaint.width; + t.height = l.texpaint.height; + t.format = format; + let rt: render_target_t = render_path_create_render_target(t); + layers_expb = rt._image; + } + + { + let t: render_target_t = render_target_create(); + t.name = "expc"; + t.width = l.texpaint.width; + t.height = l.texpaint.height; + t.format = format; + let rt: render_target_t = render_path_create_render_target(t); + layers_expc = rt._image; + } + } +} + +function layers_apply_mask(l: slot_layer_t, m: slot_layer_t) { + if (!slot_layer_is_layer(l) || !slot_layer_is_mask(m)) { + return; + } + + layers_make_temp_img(); + + // Copy layer to temp + draw_begin(layers_temp_image); + draw_set_pipeline(pipes_copy); + draw_image(l.texpaint, 0, 0); + draw_set_pipeline(null); + draw_end(); + + // Apply mask + _gpu_begin(l.texpaint); + gpu_set_pipeline(pipes_apply_mask); + gpu_set_texture(pipes_tex0_mask, layers_temp_image); + gpu_set_texture(pipes_texa_mask, m.texpaint); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw(); + gpu_end(); +} + +function layers_commands_merge_pack(pipe: gpu_pipeline_t, i0: gpu_texture_t, i1: gpu_texture_t, i1pack: gpu_texture_t, i1mask_opacity: f32, i1texmask: gpu_texture_t, i1blending: i32 = 101) { + _gpu_begin(i0); + gpu_set_pipeline(pipe); + gpu_set_texture(pipes_tex0, i1); + gpu_set_texture(pipes_tex1, i1pack); + gpu_set_texture(pipes_texmask, i1texmask); + gpu_set_texture(pipes_texa, layers_temp_image); + gpu_set_float(pipes_opac, i1mask_opacity); + gpu_set_float(pipes_tex1w, i1pack.width); + gpu_set_int(pipes_blending, i1blending); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw(); + gpu_end(); +} + +function layers_is_fill_material(): bool { + if (context_raw.tool == tool_type_t.MATERIAL) { + return true; + } + + let m: slot_material_t = context_raw.material; + for (let i: i32 = 0; i < project_layers.length; ++i) { + let l: slot_layer_t = project_layers[i]; + if (l.fill_layer == m) { + return true; + } + } + return false; +} + +function layers_update_fill_layers() { + let _layer: slot_layer_t = context_raw.layer; + let _tool: tool_type_t = context_raw.tool; + let _fill_type: i32 = context_raw.fill_type_handle.i; + let current: gpu_texture_t = null; + + if (context_raw.tool == tool_type_t.MATERIAL) { + if (render_path_paint_live_layer == null) { + render_path_paint_live_layer = slot_layer_create("_live"); + } + + current = _draw_current; + if (current != null) draw_end(); + + context_raw.tool = tool_type_t.FILL; + context_raw.fill_type_handle.i = fill_type_t.OBJECT; + render_path_paint_set_plane_mesh(); + make_material_parse_paint_material(false); + context_raw.pdirty = 1; + render_path_paint_use_live_layer(true); + render_path_paint_commands_paint(false); + render_path_paint_dilate(true, true); + render_path_paint_use_live_layer(false); + context_raw.tool = _tool; + context_raw.fill_type_handle.i = _fill_type; + context_raw.pdirty = 0; + context_raw.rdirty = 2; + render_path_paint_restore_plane_mesh(); + make_material_parse_paint_material(); + ui_view2d_hwnd.redraws = 2; + + if (current != null) draw_begin(current); + return; + } + + let has_fill_layer: bool = false; + let has_fill_mask: bool = false; + for (let i: i32 = 0; i < project_layers.length; ++i) { + let l: slot_layer_t = project_layers[i]; + if (slot_layer_is_layer(l) && l.fill_layer == context_raw.material) { + has_fill_layer = true; + } + } + for (let i: i32 = 0; i < project_layers.length; ++i) { + let l: slot_layer_t = project_layers[i]; + if (slot_layer_is_mask(l) && l.fill_layer == context_raw.material) { + has_fill_mask = true; + } + } + + if (has_fill_layer || has_fill_mask) { + current = _draw_current; + if (current != null) { + draw_end(); + } + context_raw.pdirty = 1; + context_raw.tool = tool_type_t.FILL; + context_raw.fill_type_handle.i = fill_type_t.OBJECT; + + if (has_fill_layer) { + let first: bool = true; + for (let i: i32 = 0; i < project_layers.length; ++i) { + let l: slot_layer_t = project_layers[i]; + if (slot_layer_is_layer(l) && l.fill_layer == context_raw.material) { + context_raw.layer = l; + if (first) { + first = false; + make_material_parse_paint_material(false); + } + layers_set_object_mask(); + slot_layer_clear(l); + render_path_paint_commands_paint(false); + render_path_paint_dilate(true, true); + } + } + } + if (has_fill_mask) { + let first: bool = true; + for (let i: i32 = 0; i < project_layers.length; ++i) { + let l: slot_layer_t = project_layers[i]; + if (slot_layer_is_mask(l) && l.fill_layer == context_raw.material) { + context_raw.layer = l; + if (first) { + first = false; + make_material_parse_paint_material(false); + } + layers_set_object_mask(); + slot_layer_clear(l); + render_path_paint_commands_paint(false); + render_path_paint_dilate(true, true); + } + } + } + + context_raw.pdirty = 0; + context_raw.ddirty = 2; + context_raw.rdirty = 2; + context_raw.layers_preview_dirty = true; // Repaint all layer previews as multiple layers might have changed. + if (current != null) draw_begin(current); + context_raw.layer = _layer; + layers_set_object_mask(); + context_raw.tool = _tool; + context_raw.fill_type_handle.i = _fill_type; + make_material_parse_paint_material(false); + } +} + +function layers_update_fill_layer(parse_paint: bool = true) { + let current: gpu_texture_t = _draw_current; + let in_use: bool = gpu_in_use; + if (in_use) draw_end(); + + let _tool: tool_type_t = context_raw.tool; + let _fill_type: i32 = context_raw.fill_type_handle.i; + context_raw.tool = tool_type_t.FILL; + context_raw.fill_type_handle.i = fill_type_t.OBJECT; + context_raw.pdirty = 1; + + slot_layer_clear(context_raw.layer); + + if (parse_paint) { + make_material_parse_paint_material(false); + } + render_path_paint_commands_paint(false); + render_path_paint_dilate(true, true); + + context_raw.rdirty = 2; + context_raw.tool = _tool; + context_raw.fill_type_handle.i = _fill_type; + if (in_use) draw_begin(current); +} + +function layers_set_object_mask() { + let ar: string[] = [tr("None")]; + for (let i: i32 = 0; i < project_paint_objects.length; ++i) { + let p: mesh_object_t = project_paint_objects[i]; + array_push(ar, p.base.name); + } + + let mask: i32 = context_object_mask_used() ? slot_layer_get_object_mask(context_raw.layer) : 0; + if (context_layer_filter_used()) { + mask = context_raw.layer_filter; + } + if (mask > 0) { + if (context_raw.merged_object != null) { + context_raw.merged_object.base.visible = false; + } + let o: mesh_object_t = project_paint_objects[0]; + for (let i: i32 = 0; i < project_paint_objects.length; ++i) { + let p: mesh_object_t = project_paint_objects[i]; + let mask_name: string = ar[mask]; + if (p.base.name == mask_name) { + o = p; + break; + } + } + context_select_paint_object(o); + } + else { + let is_atlas: bool = slot_layer_get_object_mask(context_raw.layer) > 0 && slot_layer_get_object_mask(context_raw.layer) <= project_paint_objects.length; + if (context_raw.merged_object == null || is_atlas || context_raw.merged_object_is_atlas) { + let visibles: mesh_object_t[] = is_atlas ? project_get_atlas_objects(slot_layer_get_object_mask(context_raw.layer)) : null; + util_mesh_merge(visibles); + } + context_select_paint_object(context_main_object()); + context_raw.paint_object.skip_context = "paint"; + context_raw.merged_object.base.visible = true; + } + util_uv_dilatemap_cached = false; +} + +function layers_new_layer(clear: bool = true, position: i32 = -1): slot_layer_t { + if (project_layers.length > layers_max_layers) { + return null; + } + + let l: slot_layer_t = slot_layer_create(); + l.object_mask = context_raw.layer_filter; + + if (position == -1) { + if (slot_layer_is_mask(context_raw.layer)) context_set_layer(context_raw.layer.parent); + array_insert(project_layers, array_index_of(project_layers, context_raw.layer) + 1, l); + } + else { + array_insert(project_layers, position, l); + } + + context_set_layer(l); + let li: i32 = array_index_of(project_layers, context_raw.layer); + if (li > 0) { + let below: slot_layer_t = project_layers[li - 1]; + if (slot_layer_is_layer(below)) { + context_raw.layer.parent = below.parent; + } + } + if (clear) { + sys_notify_on_next_frame(function (l: slot_layer_t) { + slot_layer_clear(l); + }, l); + } + context_raw.layer_preview_dirty = true; + return l; +} + +function layers_new_mask(clear: bool = true, parent: slot_layer_t, position: i32 = -1): slot_layer_t { + if (project_layers.length > layers_max_layers) { + return null; + } + let l: slot_layer_t = slot_layer_create("", layer_slot_type_t.MASK, parent); + if (position == -1) { + position = array_index_of(project_layers, parent); + } + array_insert(project_layers, position, l); + context_set_layer(l); + if (clear) { + sys_notify_on_next_frame(function (l: slot_layer_t) { + slot_layer_clear(l); + }, l); + } + context_raw.layer_preview_dirty = true; + return l; +} + +function layers_new_group(): slot_layer_t { + if (project_layers.length > layers_max_layers) { + return null; + } + let l: slot_layer_t = slot_layer_create("", layer_slot_type_t.GROUP); + array_push(project_layers, l); + context_set_layer(l); + return l; +} + +function layers_create_fill_layer(uv_type: uv_type_t = uv_type_t.UVMAP, decal_mat: mat4_t = mat4nan, position: i32 = -1) { + if (context_raw.tool == tool_type_t.GIZMO) { + return; + } + + _layers_uv_type = uv_type; + _layers_decal_mat = decal_mat; + _layers_position = position; + sys_notify_on_next_frame(function () { + let l: slot_layer_t = layers_new_layer(false, _layers_position); + history_new_layer(); + l.uv_type = _layers_uv_type; + if (!mat4_isnan(_layers_decal_mat)) { + l.decal_mat = _layers_decal_mat; + } + l.object_mask = context_raw.layer_filter; + history_to_fill_layer(); + slot_layer_to_fill_layer(l); + }); +} + +function layers_create_image_mask(asset: asset_t) { + let l: slot_layer_t = context_raw.layer; + if (slot_layer_is_mask(l) || slot_layer_is_group(l)) { + return; + } + + history_new_layer(); + let m: slot_layer_t = layers_new_mask(false, l); + slot_layer_clear(m, 0x00000000, project_get_image(asset)); + context_raw.layer_preview_dirty = true; +} + +function layers_create_color_layer(base_color: i32, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0, position: i32 = -1) { + _layers_base_color = base_color; + _layers_occlusion = occlusion; + _layers_roughness = roughness; + _layers_metallic = metallic; + _layers_position = position; + + sys_notify_on_next_frame(function () { + let l: slot_layer_t = layers_new_layer(false, _layers_position); + history_new_layer(); + l.uv_type = uv_type_t.UVMAP; + l.object_mask = context_raw.layer_filter; + slot_layer_clear(l, _layers_base_color, null, _layers_occlusion, _layers_roughness, _layers_metallic); + }); +} + +function layers_duplicate_layer(l: slot_layer_t) { + if (!slot_layer_is_group(l)) { + let new_layer: slot_layer_t = slot_layer_duplicate(l); + context_set_layer(new_layer); + let masks: slot_layer_t[] = slot_layer_get_masks(l, false); + if (masks != null) { + for (let i: i32 = 0; i < masks.length; ++i) { + let m: slot_layer_t = masks[i]; + m = slot_layer_duplicate(m); + m.parent = new_layer; + array_remove(project_layers, m); + array_insert(project_layers, array_index_of(project_layers, new_layer), m); + } + } + context_set_layer(new_layer); + } + else { + let new_group: slot_layer_t = layers_new_group(); + array_remove(project_layers, new_group); + array_insert(project_layers, array_index_of(project_layers, l) + 1, new_group); + // group.show_panel = true; + for (let i: i32 = 0; i < slot_layer_get_children(l).length; ++i) { + let c: slot_layer_t = slot_layer_get_children(l)[i]; + let masks: slot_layer_t[] = slot_layer_get_masks(c, false); + let new_layer: slot_layer_t = slot_layer_duplicate(c); + new_layer.parent = new_group; + array_remove(project_layers, new_layer); + array_insert(project_layers, array_index_of(project_layers, new_group), new_layer); + if (masks != null) { + for (let i: i32 = 0; i < masks.length; ++i) { + let m: slot_layer_t = masks[i]; + let new_mask: slot_layer_t = slot_layer_duplicate(m); + new_mask.parent = new_layer; + array_remove(project_layers, new_mask); + array_insert(project_layers, array_index_of(project_layers, new_layer), new_mask); + } + } + } + let group_masks: slot_layer_t[] = slot_layer_get_masks(l); + if (group_masks != null) { + for (let i: i32 = 0; i < group_masks.length; ++i) { + let m: slot_layer_t = group_masks[i]; + let new_mask: slot_layer_t = slot_layer_duplicate(m); + new_mask.parent = new_group; + array_remove(project_layers, new_mask); + array_insert(project_layers, array_index_of(project_layers, new_group), new_mask); + } + } + context_set_layer(new_group); + } +} + +function layers_apply_masks(l: slot_layer_t) { + let masks: slot_layer_t[] = slot_layer_get_masks(l); + + if (masks != null) { + for (let i: i32 = 0; i < masks.length - 1; ++i) { + layers_merge_layer(masks[i + 1], masks[i]); + slot_layer_delete(masks[i]); + } + slot_layer_apply_mask(masks[masks.length - 1]); + context_raw.layer_preview_dirty = true; + } +} + +function layers_merge_down() { + let l1: slot_layer_t = context_raw.layer; + + if (slot_layer_is_group(l1)) { + l1 = layers_merge_group(l1); + } + else if (slot_layer_has_masks(l1)) { // It is a layer + layers_apply_masks(l1); + context_set_layer(l1); + } + + let l0: slot_layer_t = project_layers[array_index_of(project_layers, l1) - 1]; + + if (slot_layer_is_group(l0)) { + l0 = layers_merge_group(l0); + } + else if (slot_layer_has_masks(l0)) { // It is a layer + layers_apply_masks(l0); + context_set_layer(l0); + } + + layers_merge_layer(l0, l1); + slot_layer_delete(l1); + context_set_layer(l0); + context_raw.layer_preview_dirty = true; +} + +function layers_merge_group(l: slot_layer_t): slot_layer_t { + if (!slot_layer_is_group(l)) { + return null; + } + + let children: slot_layer_t[] = slot_layer_get_children(l); + + if (children.length == 1 && slot_layer_has_masks(children[0], false)) { + layers_apply_masks(children[0]); + } + + for (let i: i32 = 0; i < children.length - 1; ++i) { + context_set_layer(children[children.length - 1 - i]); + history_merge_layers(); + layers_merge_down(); + } + + // Now apply the group masks + let masks: slot_layer_t[] = slot_layer_get_masks(l); + if (masks != null) { + for (let i: i32 = 0; i < masks.length - 1; ++i) { + layers_merge_layer(masks[i + 1], masks[i]); + slot_layer_delete(masks[i]); + } + layers_apply_mask(children[0], masks[masks.length - 1]); + } + + children[0].parent = null; + children[0].name = l.name; + if (children[0].fill_layer != null) { + slot_layer_to_paint_layer(children[0]); + } + slot_layer_delete(l); + return children[0]; +} + +function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool = false) { + if (!l1.visible || slot_layer_is_group(l1)) { + return; + } + + layers_make_temp_img(); + + draw_begin(layers_temp_image); // Copy to temp + draw_set_pipeline(pipes_copy); + draw_image(l0.texpaint, 0, 0); + draw_set_pipeline(null); + draw_end(); + + let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); + let empty: gpu_texture_t = empty_rt._image; + let mask: gpu_texture_t = empty; + let l1masks: slot_layer_t[] = use_mask ? slot_layer_get_masks(l1) : null; + if (l1masks != null) { + // for (let i: i32 = 1; i < l1masks.length - 1; ++i) { + // merge_layer(l1masks[i + 1], l1masks[i]); + // } + mask = l1masks[0].texpaint; + } + + if (slot_layer_is_mask(l1)) { + _gpu_begin(l0.texpaint); + gpu_set_pipeline(pipes_merge_mask); + gpu_set_texture(pipes_tex0_merge_mask, l1.texpaint); + gpu_set_texture(pipes_texa_merge_mask, layers_temp_image); + gpu_set_float(pipes_opac_merge_mask, slot_layer_get_opacity(l1)); + gpu_set_int(pipes_blending_merge_mask, l1.blending); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw(); + gpu_end(); + } + + if (slot_layer_is_layer(l1)) { + if (l1.paint_base) { + _gpu_begin(l0.texpaint); + gpu_set_pipeline(pipes_merge); + gpu_set_texture(pipes_tex0, l1.texpaint); + gpu_set_texture(pipes_tex1, empty); + gpu_set_texture(pipes_texmask, mask); + gpu_set_texture(pipes_texa, layers_temp_image); + gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + gpu_set_float(pipes_tex1w, empty.width); + gpu_set_int(pipes_blending, l1.blending); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw(); + gpu_end(); + } + + if (l0.texpaint_nor != null) { + draw_begin(layers_temp_image); + draw_set_pipeline(pipes_copy); + draw_image(l0.texpaint_nor, 0, 0); + draw_set_pipeline(null); + draw_end(); + + if (l1.paint_nor) { + _gpu_begin(l0.texpaint_nor); + gpu_set_pipeline(pipes_merge); + gpu_set_texture(pipes_tex0, l1.texpaint); + gpu_set_texture(pipes_tex1, l1.texpaint_nor); + gpu_set_texture(pipes_texmask, mask); + gpu_set_texture(pipes_texa, layers_temp_image); + gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + gpu_set_float(pipes_tex1w, l1.texpaint_nor.width); + gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw(); + gpu_end(); + } + } + + if (l0.texpaint_pack != null) { + draw_begin(layers_temp_image); + draw_set_pipeline(pipes_copy); + draw_image(l0.texpaint_pack, 0, 0); + draw_set_pipeline(null); + draw_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) { + layers_commands_merge_pack(pipes_merge, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? 103 : 101); + } + else { + if (l1.paint_occ) { + layers_commands_merge_pack(pipes_merge_r, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + } + if (l1.paint_rough) { + layers_commands_merge_pack(pipes_merge_g, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + } + if (l1.paint_met) { + layers_commands_merge_pack(pipes_merge_b, l0.texpaint_pack, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + } + } + } + } + } +} + +function layers_flatten(height_to_normal: bool = false, layers: slot_layer_t[] = null): slot_layer_t { + if (layers == null) { + layers = project_layers; + } + layers_make_temp_img(); + layers_make_export_img(); + + let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); + let empty: gpu_texture_t = empty_rt._image; + + // Clear export layer + _gpu_begin(layers_expa, null, null, clear_flag_t.COLOR, color_from_floats(0.0, 0.0, 0.0, 0.0)); + gpu_end(); + _gpu_begin(layers_expb, null, null, clear_flag_t.COLOR, color_from_floats(0.5, 0.5, 1.0, 0.0)); + gpu_end(); + _gpu_begin(layers_expc, null, null, clear_flag_t.COLOR, color_from_floats(1.0, 0.0, 0.0, 0.0)); + gpu_end(); + + // Flatten layers + for (let i: i32 = 0; i < layers.length; ++i) { + let l1: slot_layer_t = layers[i]; + if (!slot_layer_is_visible(l1)) { + continue; + } + if (!slot_layer_is_layer(l1)) { + continue; + } + + let mask: gpu_texture_t = empty; + let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); + if (l1masks != null) { + if (l1masks.length > 1) { + layers_make_temp_mask_img(); + draw_begin(pipes_temp_mask_image, clear_flag_t.COLOR, 0x00000000); + draw_end(); + let l1: slot_layer_t = { texpaint: pipes_temp_mask_image }; + for (let i: i32 = 0; i < l1masks.length; ++i) { + layers_merge_layer(l1, l1masks[i]); + } + mask = pipes_temp_mask_image; + } + else { + mask = l1masks[0].texpaint; + } + } + + if (l1.paint_base) { + draw_begin(layers_temp_image); // Copy to temp + draw_set_pipeline(pipes_copy); + draw_image(layers_expa, 0, 0); + draw_set_pipeline(null); + draw_end(); + + if (context_raw.tool == tool_type_t.GIZMO) { + // Do not multiply basecol by alpha + draw_begin(layers_expa); // Copy to temp + draw_set_pipeline(pipes_copy); + draw_image(l1.texpaint, 0, 0); + draw_set_pipeline(null); + draw_end(); + } + else { + _gpu_begin(layers_expa); + gpu_set_pipeline(pipes_merge); + gpu_set_texture(pipes_tex0, l1.texpaint); + gpu_set_texture(pipes_tex1, empty); + gpu_set_texture(pipes_texmask, mask); + gpu_set_texture(pipes_texa, layers_temp_image); + gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + gpu_set_float(pipes_tex1w, empty.width); + gpu_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw(); + gpu_end(); + } + } + + if (l1.paint_nor) { + draw_begin(layers_temp_image); + draw_set_pipeline(pipes_copy); + draw_image(layers_expb, 0, 0); + draw_set_pipeline(null); + draw_end(); + + _gpu_begin(layers_expb); + gpu_set_pipeline(pipes_merge); + gpu_set_texture(pipes_tex0, l1.texpaint); + gpu_set_texture(pipes_tex1, l1.texpaint_nor); + gpu_set_texture(pipes_texmask, mask); + gpu_set_texture(pipes_texa, layers_temp_image); + gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + gpu_set_float(pipes_tex1w, l1.texpaint_nor.width); + gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw(); + gpu_end(); + } + + if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { + draw_begin(layers_temp_image); + draw_set_pipeline(pipes_copy); + draw_image(layers_expc, 0, 0); + draw_set_pipeline(null); + draw_end(); + + if (l1.paint_occ && l1.paint_rough && l1.paint_met && l1.paint_height) { + layers_commands_merge_pack(pipes_merge, layers_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask, l1.paint_height_blend ? 103 : 101); + } + else { + if (l1.paint_occ) { + layers_commands_merge_pack(pipes_merge_r, layers_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + } + if (l1.paint_rough) { + layers_commands_merge_pack(pipes_merge_g, layers_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + } + if (l1.paint_met) { + layers_commands_merge_pack(pipes_merge_b, layers_expc, l1.texpaint, l1.texpaint_pack, slot_layer_get_opacity(l1), mask); + } + } + } + } + + let l0: slot_layer_t = { + texpaint: layers_expa, + texpaint_nor: layers_expb, + texpaint_pack: layers_expc + }; + + // Merge height map into normal map + if (height_to_normal && make_material_height_used) { + + draw_begin(layers_temp_image); + draw_set_pipeline(pipes_copy); + draw_image(l0.texpaint_nor, 0, 0); + draw_set_pipeline(null); + draw_end(); + + _gpu_begin(l0.texpaint_nor); + gpu_set_pipeline(pipes_merge); + gpu_set_texture(pipes_tex0, layers_temp_image); + gpu_set_texture(pipes_tex1, l0.texpaint_pack); + gpu_set_texture(pipes_texmask, empty); + gpu_set_texture(pipes_texa, empty); + gpu_set_float(pipes_opac, 1.0); + gpu_set_float(pipes_tex1w, l0.texpaint_pack.width); + gpu_set_int(pipes_blending, 104); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw(); + gpu_end(); + } + + return l0; +} + +function layers_on_resized() { + sys_notify_on_next_frame(function () { + layers_resize(); + let _layer: slot_layer_t = context_raw.layer; + let _material: slot_material_t = context_raw.material; + for (let i: i32 = 0; i < project_layers.length; ++i) { + let l: slot_layer_t = project_layers[i]; + if (l.fill_layer != null) { + context_raw.layer = l; + context_raw.material = l.fill_layer; + layers_update_fill_layer(); + } + } + context_raw.layer = _layer; + context_raw.material = _material; + make_material_parse_paint_material(); + }); + util_uv_uvmap = null; + util_uv_uvmap_cached = false; + util_uv_trianglemap = null; + util_uv_trianglemap_cached = false; + util_uv_dilatemap_cached = false; + render_path_raytrace_ready = false; +}