diff --git a/paint/sources/base.ts b/paint/sources/base.ts index 4f37642e..2090a8e5 100644 --- a/paint/sources/base.ts +++ b/paint/sources/base.ts @@ -1848,7 +1848,7 @@ function ui_base_render_cursor() { let decal: bool = context_is_decal(); - if (!config_raw.brush_3d || context_in_2d_view() || decal) { + if (context_in_2d_view() || decal) { let decal_mask: bool = context_is_decal_mask(); if (decal && !context_in_nodes()) { let decal_alpha: f32 = 0.5; @@ -1887,12 +1887,11 @@ function ui_base_render_cursor() { context_raw.tool == tool_type_t.BLUR || context_raw.tool == tool_type_t.SMUDGE || context_raw.tool == tool_type_t.PARTICLE || - (decal_mask && !config_raw.brush_3d) || (decal_mask && context_in_2d_view())) { if (decal_mask) { psize = math_floor(cursor_img.width * (context_raw.brush_decal_mask_radius * context_raw.brush_nodes_radius) * UI_SCALE()); } - if (config_raw.brush_3d && context_in_2d_view()) { + if (context_in_2d_view()) { psize = math_floor(psize * ui_view2d_pan_scale); } draw_scaled_image(cursor_img, mx - psize / 2, my - psize / 2, psize, psize); diff --git a/paint/sources/box_preferences.ts b/paint/sources/box_preferences.ts index 20dff563..5f690b0c 100644 --- a/paint/sources/box_preferences.ts +++ b/paint/sources/box_preferences.ts @@ -75,6 +75,16 @@ function box_preferences_show() { config_raw.zoom_direction = zoom_direction_handle.position; } + let h_node_preview: ui_handle_t = ui_handle(__ID__); + if (h_node_preview.init) { + h_node_preview.position = config_raw.node_preview; + } + let node_preview_combo: string[] = [tr("Off"), tr("Selected Node")]; // , tr("All Nodes")]; + ui_combo(h_node_preview, node_preview_combo, tr("Node Preview"), true); + if (h_node_preview.changed) { + config_raw.node_preview = h_node_preview.position; + } + let h_wrap_mouse: ui_handle_t = ui_handle(__ID__); if (h_wrap_mouse.init) { h_wrap_mouse.selected = config_raw.wrap_mouse; @@ -84,12 +94,6 @@ function box_preferences_show() { ui_tooltip(tr("Wrap mouse around view boundaries during camera control")); } - let h_node_preview: ui_handle_t = ui_handle(__ID__); - if (h_node_preview.init) { - h_node_preview.selected = config_raw.node_preview; - } - config_raw.node_preview = ui_check(h_node_preview, tr("Show Node Preview")); - ui.changed = false; let h_show_asset_names: ui_handle_t = ui_handle(__ID__); if (h_show_asset_names.init) { @@ -350,16 +354,6 @@ function box_preferences_show() { ui_tooltip(tr("Dilate painted textures to prevent seams")); } - let dilate_handle: ui_handle_t = ui_handle(__ID__); - if (dilate_handle.init) { - dilate_handle.position = config_raw.dilate; - } - let dilate_combo: string[] = [tr("Instant"), tr("Delayed")]; - ui_combo(dilate_handle, dilate_combo, tr("Dilate"), true); - if (dilate_handle.changed) { - config_raw.dilate = dilate_handle.position; - } - let camera_controls_handle: ui_handle_t = ui_handle(__ID__); if (camera_controls_handle.init) { camera_controls_handle.position = config_raw.camera_controls; @@ -423,16 +417,6 @@ function box_preferences_show() { context_raw.ddirty = 2; } - let brush_3d_handle: ui_handle_t = ui_handle(__ID__); - if (brush_3d_handle.init) { - brush_3d_handle.selected = config_raw.brush_3d; - } - config_raw.brush_3d = ui_check(brush_3d_handle, tr("3D Cursor")); - if (brush_3d_handle.changed) { - make_material_parse_paint_material(); - } - - ui.enabled = config_raw.brush_3d; let brush_depth_reject_handle: ui_handle_t = ui_handle(__ID__); if (brush_depth_reject_handle.init) { brush_depth_reject_handle.selected = config_raw.brush_depth_reject; @@ -453,7 +437,9 @@ function box_preferences_show() { make_material_parse_paint_material(); } - if (!config_raw.brush_angle_reject) ui.enabled = false; + 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.value = context_raw.brush_angle_reject_dot; diff --git a/paint/sources/config.ts b/paint/sources/config.ts index e9865084..3bb604d4 100644 --- a/paint/sources/config.ts +++ b/paint/sources/config.ts @@ -86,15 +86,13 @@ function config_save() { json_encode_f32("displace_strength", config_raw.displace_strength); json_encode_i32("layer_res", config_raw.layer_res); json_encode_bool("brush_live", config_raw.brush_live); - json_encode_bool("brush_3d", config_raw.brush_3d); - json_encode_bool("node_preview", config_raw.node_preview); + json_encode_i32("node_preview", config_raw.node_preview); json_encode_bool("pressure_hardness", config_raw.pressure_hardness); json_encode_bool("pressure_angle", config_raw.pressure_angle); json_encode_bool("pressure_opacity", config_raw.pressure_opacity); json_encode_bool("material_live", config_raw.material_live); json_encode_bool("brush_depth_reject", config_raw.brush_depth_reject); json_encode_bool("brush_angle_reject", config_raw.brush_angle_reject); - json_encode_i32("dilate", config_raw.dilate); json_encode_i32("dilate_radius", config_raw.dilate_radius); json_encode_bool("gpu_inference", config_raw.gpu_inference); json_encode_string("blender", config_raw.blender); @@ -189,7 +187,7 @@ function config_init() { config_raw.touch_ui = false; config_raw.splash_screen = false; ///end - config_raw.node_preview = true; + config_raw.node_preview = node_preview_t.SELECTED_NODE; config_raw.pressure_hardness = true; config_raw.pressure_angle = false; config_raw.pressure_opacity = false; @@ -198,12 +196,10 @@ function config_init() { ///else config_raw.material_live = true; ///end - config_raw.brush_3d = true; config_raw.brush_depth_reject = true; config_raw.brush_angle_reject = true; config_raw.brush_live = false; config_raw.show_asset_names = false; - config_raw.dilate = dilate_type_t.INSTANT; config_raw.dilate_radius = 2; config_raw.gpu_inference = true; config_raw.blender = ""; @@ -476,25 +472,19 @@ type config_t = { server?: string; viewport_mode: i32; pathtrace_mode: i32; - pressure_radius?: bool; // Pen pressure controls pressure_sensitivity?: f32; displace_strength?: f32; layer_res?: i32; brush_live?: bool; - brush_3d?: bool; - node_preview?: bool; - + node_preview?: i32; pressure_hardness?: bool; pressure_angle?: bool; pressure_opacity?: bool; material_live?: bool; brush_depth_reject?: bool; brush_angle_reject?: bool; - - dilate?: i32; dilate_radius?: i32; - gpu_inference?: bool; blender?: string; scene_atlas_res: i32; diff --git a/paint/sources/enums.ts b/paint/sources/enums.ts index f99ef560..94e6515e 100644 --- a/paint/sources/enums.ts +++ b/paint/sources/enums.ts @@ -1,9 +1,4 @@ -enum dilate_type_t { - INSTANT, - DELAYED, -} - enum bake_type_t { INIT = -1, CURVATURE = 0, @@ -283,3 +278,9 @@ enum layout_size_t { STATUS_H = 5, HEADER = 6, // 0 - hidden, 1 - visible } + +enum node_preview_t { + OFF = 0, + SELECTED_NODE = 1, + ALL_NODES = 2, +} diff --git a/paint/sources/make_brush.ts b/paint/sources/make_brush.ts index bc0b7490..43137fd5 100644 --- a/paint/sources/make_brush.ts +++ b/paint/sources/make_brush.ts @@ -13,68 +13,52 @@ function make_brush_run(kong: node_shader_t) { node_shader_write_frag(kong, "if (constants.decal_mask.z > 0.0) {"); } - if (config_raw.brush_3d) { - node_shader_write_frag(kong, "var depth: float = sample_lod(gbufferD, sampler_linear, constants.inp.xy, 0.0).r;"); + node_shader_write_frag(kong, "var depth: float = sample_lod(gbufferD, sampler_linear, constants.inp.xy, 0.0).r;"); - node_shader_add_constant(kong, "invVP: float4x4", "_inv_view_proj_matrix"); - node_shader_write_frag(kong, "var winp: float4 = float4(float2(constants.inp.x, 1.0 - constants.inp.y) * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);"); - node_shader_write_frag(kong, "winp = constants.invVP * winp;"); - node_shader_write_frag(kong, "winp.xyz = winp.xyz / winp.w;"); - kong.frag_wposition = true; + node_shader_add_constant(kong, "invVP: float4x4", "_inv_view_proj_matrix"); + node_shader_write_frag(kong, "var winp: float4 = float4(float2(constants.inp.x, 1.0 - constants.inp.y) * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);"); + node_shader_write_frag(kong, "winp = constants.invVP * winp;"); + node_shader_write_frag(kong, "winp.xyz = winp.xyz / winp.w;"); + kong.frag_wposition = true; - if (config_raw.brush_angle_reject || context_raw.xray) { - node_shader_add_function(kong, str_octahedron_wrap); - node_shader_add_texture(kong, "gbuffer0"); - node_shader_write_frag(kong, "var g0: float2 = sample_lod(gbuffer0, sampler_linear, constants.inp.xy, 0.0).rg;"); - node_shader_write_frag(kong, "var wn: float3;"); - node_shader_write_frag(kong, "wn.z = 1.0 - abs(g0.x) - abs(g0.y);"); - // node_shader_write_frag(kong, "wn.xy = wn.z >= 0.0 ? g0.xy : octahedron_wrap(g0.xy);"); - node_shader_write_frag(kong, "if (wn.z >= 0.0) { wn.x = g0.x; wn.y = g0.y; } else { var f2: float2 = octahedron_wrap(g0.xy); wn.x = f2.x; wn.y = f2.y; }"); - node_shader_write_frag(kong, "wn = normalize(wn);"); - node_shader_write_frag(kong, "var plane_dist: float = dot(wn, winp.xyz - input.wposition);"); + if (config_raw.brush_angle_reject || context_raw.xray) { + node_shader_add_function(kong, str_octahedron_wrap); + node_shader_add_texture(kong, "gbuffer0"); + node_shader_write_frag(kong, "var g0: float2 = sample_lod(gbuffer0, sampler_linear, constants.inp.xy, 0.0).rg;"); + node_shader_write_frag(kong, "var wn: float3;"); + node_shader_write_frag(kong, "wn.z = 1.0 - abs(g0.x) - abs(g0.y);"); + // node_shader_write_frag(kong, "wn.xy = wn.z >= 0.0 ? g0.xy : octahedron_wrap(g0.xy);"); + node_shader_write_frag(kong, "if (wn.z >= 0.0) { wn.x = g0.x; wn.y = g0.y; } else { var f2: float2 = octahedron_wrap(g0.xy); wn.x = f2.x; wn.y = f2.y; }"); + node_shader_write_frag(kong, "wn = normalize(wn);"); + node_shader_write_frag(kong, "var plane_dist: float = dot(wn, winp.xyz - input.wposition);"); - if (config_raw.brush_angle_reject && !context_raw.xray) { - // constants.inp.w = paint2d ? 0.0 : 1.0 - node_shader_write_frag(kong, "if (plane_dist < -0.01 && constants.inp.w == 0.0) { discard; }"); - kong.frag_n = true; - let angle: f32 = context_raw.brush_angle_reject_dot; - node_shader_write_frag(kong, "if (dot(wn, n) < " + angle + " && constants.inp.w == 0.0) { discard; }"); - } - } - - node_shader_write_frag(kong, "var depthlast: float = sample_lod(gbufferD, sampler_linear, constants.inplast.xy, 0.0).r;"); - - node_shader_write_frag(kong, "var winplast: float4 = float4(float2(constants.inplast.x, 1.0 - constants.inplast.y) * 2.0 - 1.0, depthlast * 2.0 - 1.0, 1.0);"); - node_shader_write_frag(kong, "winplast = constants.invVP * winplast;"); - node_shader_write_frag(kong, "winplast.xyz = winplast.xyz / winplast.w;"); - - node_shader_write_frag(kong, "var pa: float3 = input.wposition - winp.xyz;"); - if (context_raw.xray) { - node_shader_write_frag(kong, "pa += wn * float3(plane_dist, plane_dist, plane_dist);"); - } - node_shader_write_frag(kong, "var ba: float3 = winplast.xyz - winp.xyz;"); - - if (context_raw.brush_lazy_radius > 0 && context_raw.brush_lazy_step > 0) { - // Sphere - node_shader_write_frag(kong, "dist = distance(input.wposition, winp.xyz);"); - } - else { - // Capsule - node_shader_write_frag(kong, "var h: float = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);"); - node_shader_write_frag(kong, "dist = length(pa - ba * h);"); + if (config_raw.brush_angle_reject && !context_raw.xray) { + // constants.inp.w = paint2d ? 0.0 : 1.0 + node_shader_write_frag(kong, "if (plane_dist < -0.01 && constants.inp.w == 0.0) { discard; }"); + kong.frag_n = true; + let angle: f32 = context_raw.brush_angle_reject_dot; + node_shader_write_frag(kong, "if (dot(wn, n) < " + angle + " && constants.inp.w == 0.0) { discard; }"); } } - else { // !brush3d - node_shader_write_frag(kong, "var binp: float2 = constants.inp.xy * 2.0 - 1.0;"); - node_shader_write_frag(kong, "binp.x *= constants.aspect_ratio;"); - node_shader_write_frag(kong, "binp = binp * 0.5 + 0.5;"); - node_shader_write_frag(kong, "var binplast: float2 = constants.inplast.xy * 2.0 - 1.0;"); - node_shader_write_frag(kong, "binplast.x *= constants.aspect_ratio;"); - node_shader_write_frag(kong, "binplast = binplast * 0.5 + 0.5;"); + node_shader_write_frag(kong, "var depthlast: float = sample_lod(gbufferD, sampler_linear, constants.inplast.xy, 0.0).r;"); - node_shader_write_frag(kong, "var pa: float2 = bsp.xy - binp.xy;"); - node_shader_write_frag(kong, "var ba: float2 = binplast.xy - binp.xy;"); + node_shader_write_frag(kong, "var winplast: float4 = float4(float2(constants.inplast.x, 1.0 - constants.inplast.y) * 2.0 - 1.0, depthlast * 2.0 - 1.0, 1.0);"); + node_shader_write_frag(kong, "winplast = constants.invVP * winplast;"); + node_shader_write_frag(kong, "winplast.xyz = winplast.xyz / winplast.w;"); + + node_shader_write_frag(kong, "var pa: float3 = input.wposition - winp.xyz;"); + if (context_raw.xray) { + node_shader_write_frag(kong, "pa += wn * float3(plane_dist, plane_dist, plane_dist);"); + } + node_shader_write_frag(kong, "var ba: float3 = winplast.xyz - winp.xyz;"); + + if (context_raw.brush_lazy_radius > 0 && context_raw.brush_lazy_step > 0) { + // Sphere + node_shader_write_frag(kong, "dist = distance(input.wposition, winp.xyz);"); + } + else { + // Capsule node_shader_write_frag(kong, "var h: float = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);"); node_shader_write_frag(kong, "dist = length(pa - ba * h);"); } diff --git a/paint/sources/make_paint.ts b/paint/sources/make_paint.ts index b99142ef..b4920a9d 100644 --- a/paint/sources/make_paint.ts +++ b/paint/sources/make_paint.ts @@ -143,13 +143,13 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad decal) { let depth_reject: bool = !context_raw.xray; - if (config_raw.brush_3d && !config_raw.brush_depth_reject) { + if (!config_raw.brush_depth_reject) { depth_reject = false; } // TODO: sp.z needs to take height channel into account let particle: bool = context_raw.tool == tool_type_t.PARTICLE; - if (config_raw.brush_3d && !decal && !particle) { + if (!decal && !particle) { if (make_material_height_used || context_raw.sym_x || context_raw.sym_y || context_raw.sym_z) { depth_reject = false; } @@ -333,10 +333,8 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad node_shader_write_frag(kong, "pa_mask.xy = float2(pa_mask.x * constants.brush_angle.x - pa_mask.y * constants.brush_angle.y, pa_mask.x * constants.brush_angle.y + pa_mask.y * constants.brush_angle.x);"); } node_shader_write_frag(kong, "pa_mask = pa_mask / constants.brush_radius;"); - if (config_raw.brush_3d) { - node_shader_add_constant(kong, "eye: float3", "_camera_pos"); - node_shader_write_frag(kong, "pa_mask = pa_mask * (distance(constants.eye, winp.xyz) / 1.5);"); - } + node_shader_add_constant(kong, "eye: float3", "_camera_pos"); + node_shader_write_frag(kong, "pa_mask = pa_mask * (distance(constants.eye, winp.xyz) / 1.5);"); node_shader_write_frag(kong, "pa_mask = pa_mask.xy * 0.5 + 0.5;"); node_shader_write_frag(kong, "var mask_sample: float4 = sample_lod(texbrushmask, sampler_linear, pa_mask, 0.0);"); if (context_raw.brush_mask_image_is_alpha) { diff --git a/paint/sources/render_path_base.ts b/paint/sources/render_path_base.ts index db2948e0..66ddc288 100644 --- a/paint/sources/render_path_base.ts +++ b/paint/sources/render_path_base.ts @@ -55,7 +55,7 @@ function render_path_base_begin() { let decal: bool = context_is_decal(); - if (context_raw.view_index_last != context_raw.view_index || decal || !config_raw.brush_3d) { + if (context_raw.view_index_last != context_raw.view_index || decal) { // Redraw on current viewport change context_raw.ddirty = 1; } diff --git a/paint/sources/render_path_paint.ts b/paint/sources/render_path_paint.ts index 17ec6ebb..8d6e8d63 100644 --- a/paint/sources/render_path_paint.ts +++ b/paint/sources/render_path_paint.ts @@ -252,7 +252,7 @@ function render_path_paint_commands_paint(dilation: bool = true) { render_path_set_target(texpaint, additional); } render_path_bind_target("main", "gbufferD"); - if ((context_raw.xray || config_raw.brush_angle_reject) && config_raw.brush_3d) { + if (context_raw.xray || config_raw.brush_angle_reject) { render_path_bind_target("gbuffer0", "gbuffer0"); } render_path_bind_target("texpaint_blend1", "paintmask"); @@ -291,7 +291,7 @@ function render_path_paint_commands_paint(dilation: bool = true) { } } - if (dilation && config_raw.dilate == dilate_type_t.INSTANT) { + if (dilation) { render_path_paint_dilate(true, false); } } @@ -401,9 +401,6 @@ function render_path_paint_commands_live_brush() { } function render_path_paint_commands_cursor() { - if (!config_raw.brush_3d) { - return; - } let decal_mask: bool = context_is_decal_mask(); let tool: tool_type_t = context_raw.tool; if (tool != tool_type_t.BRUSH && @@ -525,7 +522,7 @@ function render_path_paint_live_brush_dirty() { function render_path_paint_begin() { if (!render_path_paint_dilated) { - render_path_paint_dilate(config_raw.dilate == dilate_type_t.DELAYED, true); + render_path_paint_dilate(false, true); render_path_paint_dilated = true; } @@ -674,9 +671,7 @@ function render_path_paint_draw() { else if (render_path_paint_is_rt_bake()) { let dirty: bool = render_path_raytrace_bake_commands(make_material_parse_paint_material); if (dirty) ui_header_handle.redraws = 2; - if (config_raw.dilate == dilate_type_t.INSTANT) { // && raw.pdirty == 1 - render_path_paint_dilate(true, false); - } + render_path_paint_dilate(true, false); } else { render_path_paint_commands_paint(); diff --git a/paint/sources/render_path_raytrace.ts b/paint/sources/render_path_raytrace.ts index 91ebc6c8..16c0d957 100644 --- a/paint/sources/render_path_raytrace.ts +++ b/paint/sources/render_path_raytrace.ts @@ -215,7 +215,5 @@ function render_path_raytrace_draw(use_live_layer: bool) { render_path_set_target(""); render_path_bind_target("last", "tex"); render_path_draw_shader("shader_datas/copy_pass/copy_pass"); - if (config_raw.brush_3d) { - render_path_paint_commands_cursor(); - } + render_path_paint_commands_cursor(); } diff --git a/paint/sources/ui_nodes.ts b/paint/sources/ui_nodes.ts index 030f05e5..3c2b51ab 100644 --- a/paint/sources/ui_nodes.ts +++ b/paint/sources/ui_nodes.ts @@ -816,7 +816,7 @@ function ui_nodes_render() { ui_nodes_grid_redraw = false; } - if (config_raw.node_preview && context_raw.node_preview_dirty) { + if (config_raw.node_preview == node_preview_t.SELECTED_NODE && context_raw.node_preview_dirty) { ui_nodes_make_node_preview(); } @@ -969,7 +969,7 @@ function ui_nodes_render() { ui_nodes_uichanged_last = ui.changed; // Node previews - if (config_raw.node_preview && nodes.nodes_selected_id.length > 0) { + if (config_raw.node_preview == node_preview_t.SELECTED_NODE && nodes.nodes_selected_id.length > 0) { let img: gpu_texture_t = null; let sel: ui_node_t = ui_get_node(c.nodes, nodes.nodes_selected_id[0]); diff --git a/paint/sources/uniforms_ext.ts b/paint/sources/uniforms_ext.ts index 1ea35c08..0af36528 100644 --- a/paint/sources/uniforms_ext.ts +++ b/paint/sources/uniforms_ext.ts @@ -23,9 +23,7 @@ function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: str let decal: bool = context_is_decal(); let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); let brush_decal_mask_radius: f32 = context_raw.brush_decal_mask_radius; - if (config_raw.brush_3d) { - brush_decal_mask_radius *= context_raw.paint2d ? 0.55 * ui_view2d_pan_scale : 2.0; - } + brush_decal_mask_radius *= context_raw.paint2d ? 0.55 * ui_view2d_pan_scale : 2.0; let radius: f32 = decal_mask ? brush_decal_mask_radius : context_raw.brush_radius; let val: f32 = (radius * context_raw.brush_nodes_radius) / 15.0; if (config_raw.pressure_radius && pen_down()) { @@ -33,7 +31,7 @@ function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: str } let scale2d: f32 = (900 / base_h()) * config_raw.window_scale; - if (config_raw.brush_3d && !decal) { + if (!decal) { val *= context_raw.paint2d ? 0.55 * scale2d * ui_view2d_pan_scale : 2; } else { @@ -79,13 +77,11 @@ function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: str if (config_raw.pressure_hardness && pen_down()) { val *= pen_pressure * config_raw.pressure_sensitivity; } - if (config_raw.brush_3d) { - if (context_raw.paint2d) { - val *= 1.0 / ui_view2d_pan_scale; - } - else { - val *= val; - } + if (context_raw.paint2d) { + val *= 1.0 / ui_view2d_pan_scale; + } + else { + val *= val; } return val; }