paint: fix mask invert

This commit is contained in:
luboslenco
2026-05-20 11:28:00 +02:00
parent 86a1efbf69
commit f04cb69462
4 changed files with 9 additions and 10 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ gpu_pipeline_t *pipes_merge_r = NULL;
gpu_pipeline_t *pipes_merge_g = NULL; gpu_pipeline_t *pipes_merge_g = NULL;
gpu_pipeline_t *pipes_merge_b = NULL; gpu_pipeline_t *pipes_merge_b = NULL;
gpu_pipeline_t *pipes_merge_mask; gpu_pipeline_t *pipes_merge_mask;
gpu_pipeline_t *pipes_invert8; gpu_pipeline_t *pipes_invert_mask;
gpu_pipeline_t *pipes_apply_mask; gpu_pipeline_t *pipes_apply_mask;
gpu_pipeline_t *pipes_colorid_to_mask; gpu_pipeline_t *pipes_colorid_to_mask;
i32 pipes_tex0; i32 pipes_tex0;
+1
View File
@@ -103,6 +103,7 @@ void import_mesh_finish_import(void *_) {
if (string_equals(g_context->paint_object->base->name, "")) { if (string_equals(g_context->paint_object->base->name, "")) {
g_context->paint_object->base->name = "Object"; g_context->paint_object->base->name = "Object";
} }
make_material_parse_paint_material(true); make_material_parse_paint_material(true);
make_material_parse_mesh_material(); make_material_parse_mesh_material();
ui_view2d_hwnd->redraws = 2; ui_view2d_hwnd->redraws = 2;
+6 -8
View File
@@ -116,18 +116,16 @@ void pipes_init() {
{ {
pipes_invert8 = gpu_create_pipeline(); pipes_invert_mask = gpu_create_pipeline();
gc_root(pipes_invert8); gc_root(pipes_invert_mask);
pipes_invert8->vertex_shader = sys_get_shader("layer_invert.vert"); pipes_invert_mask->vertex_shader = sys_get_shader("layer_invert.vert");
pipes_invert8->fragment_shader = sys_get_shader("layer_invert.frag"); pipes_invert_mask->fragment_shader = sys_get_shader("layer_invert.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X); gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X);
pipes_invert8->input_layout = vs; pipes_invert_mask->input_layout = vs;
pipes_invert8->color_attachment_count = 1; gpu_pipeline_compile(pipes_invert_mask);
pipes_invert8->color_attachment[0] = GPU_TEXTURE_FORMAT_R8;
gpu_pipeline_compile(pipes_invert8);
} }
{ {
+1 -1
View File
@@ -242,7 +242,7 @@ void slot_layer_clear(slot_layer_t *raw, i32 base_color, gpu_texture_t *base_ima
void slot_layer_invert_mask(slot_layer_t *raw) { void slot_layer_invert_mask(slot_layer_t *raw) {
gpu_texture_t *inverted = gpu_create_render_target(raw->texpaint->width, raw->texpaint->height, GPU_TEXTURE_FORMAT_RGBA32); gpu_texture_t *inverted = gpu_create_render_target(raw->texpaint->width, raw->texpaint->height, GPU_TEXTURE_FORMAT_RGBA32);
draw_begin(inverted, false, 0); draw_begin(inverted, false, 0);
draw_set_pipeline(pipes_invert8); draw_set_pipeline(pipes_invert_mask);
draw_image(raw->texpaint, 0, 0); draw_image(raw->texpaint, 0, 0);
draw_set_pipeline(NULL); draw_set_pipeline(NULL);
draw_end(); draw_end();