paint: eraser fixes

This commit is contained in:
luboslenco
2026-04-15 16:04:32 +02:00
parent 32bd013679
commit 99f38a61fa
+11 -7
View File
@@ -217,8 +217,8 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc
node_shader_add_constant(kong, "brush_opacity: float", "_brush_opacity");
node_shader_add_constant(kong, "brush_hardness: float", "_brush_hardness");
if (g_context->tool == TOOL_TYPE_BRUSH || g_context->tool == TOOL_TYPE_ERASER || g_context->tool == TOOL_TYPE_CLONE ||
g_context->tool == TOOL_TYPE_BLUR || g_context->tool == TOOL_TYPE_SMUDGE || g_context->tool == TOOL_TYPE_PARTICLE || decal) {
if (g_context->tool == TOOL_TYPE_BRUSH || g_context->tool == TOOL_TYPE_ERASER || g_context->tool == TOOL_TYPE_CLONE || g_context->tool == TOOL_TYPE_BLUR ||
g_context->tool == TOOL_TYPE_SMUDGE || g_context->tool == TOOL_TYPE_PARTICLE || decal) {
bool depth_reject = !g_context->xray;
if (!g_config->brush_depth_reject) {
@@ -379,9 +379,8 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc
}
if (g_context->brush_stencil_image != NULL &&
(g_context->tool == TOOL_TYPE_BRUSH || g_context->tool == TOOL_TYPE_ERASER || g_context->tool == TOOL_TYPE_FILL ||
g_context->tool == TOOL_TYPE_CLONE || g_context->tool == TOOL_TYPE_BLUR || g_context->tool == TOOL_TYPE_SMUDGE ||
g_context->tool == TOOL_TYPE_PARTICLE || decal)) {
(g_context->tool == TOOL_TYPE_BRUSH || g_context->tool == TOOL_TYPE_ERASER || g_context->tool == TOOL_TYPE_FILL || g_context->tool == TOOL_TYPE_CLONE ||
g_context->tool == TOOL_TYPE_BLUR || g_context->tool == TOOL_TYPE_SMUDGE || g_context->tool == TOOL_TYPE_PARTICLE || decal)) {
node_shader_add_texture(kong, "texbrushstencil", "_texbrushstencil");
node_shader_add_constant(kong, "texbrushstencil_size: float2", "_size(_texbrushstencil)");
node_shader_add_constant(kong, "stencil_transform: float4", "_stencil_transform");
@@ -501,10 +500,15 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc
node_shader_write_frag(kong, "var sample_pack_undo: float4 = sample_lod(texpaint_pack_undo, sampler_linear, sample_tc, 0.0);");
bool is_mask = slot_layer_is_mask(g_context->layer);
if ((g_context->tool == TOOL_TYPE_BLUR || g_context->tool == TOOL_TYPE_SMUDGE) && !is_mask) {
if (g_context->tool == TOOL_TYPE_ERASER && !is_mask) {
node_shader_write_frag(kong, "var out_a: float = sample_undo.a * (1.0 - str);");
node_shader_write_frag(kong, "output[0] = float4(sample_undo.rgb, out_a);");
}
else if ((g_context->tool == TOOL_TYPE_BLUR || g_context->tool == TOOL_TYPE_SMUDGE) && !is_mask) {
node_shader_write_frag(kong, "var t_blur: float = str / max(blur_src_alpha, 0.0000001);");
node_shader_write_frag(kong, "var out_a: float = str + sample_undo.a * (1.0 - t_blur);");
node_shader_write_frag(kong, "output[0] = float4((basecol * t_blur + sample_undo.rgb * sample_undo.a * (1.0 - t_blur)) / max(out_a, 0.0000001), out_a);");
node_shader_write_frag(kong,
"output[0] = float4((basecol * t_blur + sample_undo.rgb * sample_undo.a * (1.0 - t_blur)) / max(out_a, 0.0000001), out_a);");
}
else if (make_material_opac_used || g_context->tool == TOOL_TYPE_GIZMO || g_context->layer->fill_layer != NULL) {
node_shader_write_frag(kong, string("output[0] = float4(%s, %s);",