paint: height parse fixes

This commit is contained in:
luboslenco
2026-07-17 15:47:17 +02:00
parent ee0cc3b7cc
commit 59254abac2
4 changed files with 7 additions and 8 deletions
+6 -1
View File
@@ -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));
}
}
+1 -4
View File
@@ -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;
-2
View File
@@ -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) {
-1
View File
@@ -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);