From 59254abac214cdb74c221185ffc7386b2ff3ac16 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Fri, 17 Jul 2026 15:47:17 +0200 Subject: [PATCH] paint: height parse fixes --- paint/sources/parser_material.c | 7 ++++++- paint/sources/render/make_paint.c | 5 +---- paint/sources/render/make_sculpt.c | 2 -- paint/sources/util/util_layer.c | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/paint/sources/parser_material.c b/paint/sources/parser_material.c index d9b6dcaf..ba33369f 100644 --- a/paint/sources/parser_material.c +++ b/paint/sources/parser_material.c @@ -45,6 +45,11 @@ void parser_material_init() { parser_material_parsing_basecolor = false; } +bool parser_material_is_default_normal(char *s) { + // Enable height socket when normal map socket is not connected for now + return string_equals(s, "float3(0.500000, 0.500000, 1.000000)"); +} + void parse_normal_map_color_input(ui_node_socket_t *inp) { parser_material_kong->frag_write_normal++; gc_unroot(parser_material_out_normaltan); @@ -90,7 +95,7 @@ shader_out_t *parser_material_parse_shader(ui_node_t *node, ui_node_socket_t *so // Opacity sout->out_opacity = string_copy(parser_material_parse_value_input(node->inputs->buffer[1], false)); // Height - if (parser_material_parse_height) { + if (parser_material_parse_height && parser_material_is_default_normal(parser_material_out_normaltan)) { sout->out_height = string_copy(parser_material_parse_value_input(node->inputs->buffer[7], false)); } } diff --git a/paint/sources/render/make_paint.c b/paint/sources/render/make_paint.c index 5f7b53b7..7d77125b 100644 --- a/paint/sources/render/make_paint.c +++ b/paint/sources/render/make_paint.c @@ -250,10 +250,9 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc depth_reject = false; } - // TODO: sp.z needs to take height channel into account bool particle = g_context->tool == TOOL_TYPE_PARTICLE; if (!decal && !particle) { - if (make_material_height_used || g_context->sym_x || g_context->sym_y || g_context->sym_z) { + if (g_context->sym_x || g_context->sym_y || g_context->sym_z) { depth_reject = false; } } @@ -371,8 +370,6 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc } if (!make_material_height_used && !make_paint_is_zero_constant(height)) { make_material_height_used = true; - // Height used for the first time, also rebuild vertex shader - return make_paint_run(data, matcon); } make_material_emis_used = parse_float(emis) != 0.0; make_material_subs_used = parse_float(subs) != 0.0; diff --git a/paint/sources/render/make_sculpt.c b/paint/sources/render/make_sculpt.c index 4a7725fc..0dd18ed1 100644 --- a/paint/sources/render/make_sculpt.c +++ b/paint/sources/render/make_sculpt.c @@ -481,11 +481,9 @@ node_shader_context_t *sculpt_make_sculpt_run(material_t *data, material_context // parser_material_parse may add vertex elements i32 velen = con_paint->data->vertex_elements->length; - // parser_material_parse_height = true; shader_out_t *sout = parser_material_parse(g_context->material->canvas, con_paint, kong, matcon); con_paint->data->vertex_elements->length = velen; parser_material_triplanar = false; - // node_shader_write_frag(kong, string("var height: float = %s.r;", sout->out_basecol)); node_shader_write_frag(kong, string("var disp: float3 = %s;", sout->out_basecol)); if (kong->frag_bposition) { diff --git a/paint/sources/util/util_layer.c b/paint/sources/util/util_layer.c index 989dcdec..7fb8cea2 100644 --- a/paint/sources/util/util_layer.c +++ b/paint/sources/util/util_layer.c @@ -1175,7 +1175,6 @@ slot_layer_t *layers_flatten(bool height_to_normal, slot_layer_t_array_t *layers // Merge height map into normal map if (height_to_normal && make_material_height_used) { - draw_begin(layers_temp_image, false, 0); draw_set_pipeline(pipes_copy); draw_image(l0->texpaint_nor, 0, 0);