2026-03-09 13:17:15 +01:00
|
|
|
|
|
|
|
|
#include "../global.h"
|
|
|
|
|
|
2026-03-06 12:56:38 +01:00
|
|
|
void layer_node_init() {
|
2026-03-31 18:47:10 +02:00
|
|
|
|
|
|
|
|
layer_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
|
|
|
.name = _tr("Layer"),
|
|
|
|
|
.type = "LAYER", // extension
|
|
|
|
|
.x = 0,
|
|
|
|
|
.y = 0,
|
|
|
|
|
.color = 0xff4982a0,
|
|
|
|
|
.inputs = any_array_create_from_raw((void *[]){}, 0),
|
|
|
|
|
.outputs = any_array_create_from_raw(
|
|
|
|
|
(void *[]){
|
|
|
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
|
|
|
.node_id = 0,
|
|
|
|
|
.name = _tr("Base Color"),
|
|
|
|
|
.type = "RGBA",
|
|
|
|
|
.color = 0xffc7c729,
|
|
|
|
|
.default_value = f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.display = 0}),
|
|
|
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
|
|
|
.node_id = 0,
|
|
|
|
|
.name = _tr("Opacity"),
|
|
|
|
|
.type = "VALUE",
|
|
|
|
|
.color = 0xffa1a1a1,
|
|
|
|
|
.default_value = f32_array_create_x(1.0),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.display = 0}),
|
|
|
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
|
|
|
.node_id = 0,
|
|
|
|
|
.name = _tr("Occlusion"),
|
|
|
|
|
.type = "VALUE",
|
|
|
|
|
.color = 0xffa1a1a1,
|
|
|
|
|
.default_value = f32_array_create_x(1.0),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.display = 0}),
|
|
|
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
|
|
|
.node_id = 0,
|
|
|
|
|
.name = _tr("Roughness"),
|
|
|
|
|
.type = "VALUE",
|
|
|
|
|
.color = 0xffa1a1a1,
|
|
|
|
|
.default_value = f32_array_create_x(1.0),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.display = 0}),
|
|
|
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
|
|
|
.node_id = 0,
|
|
|
|
|
.name = _tr("Metallic"),
|
|
|
|
|
.type = "VALUE",
|
|
|
|
|
.color = 0xffa1a1a1,
|
|
|
|
|
.default_value = f32_array_create_x(1.0),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.display = 0}),
|
|
|
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
|
|
|
.node_id = 0,
|
|
|
|
|
.name = _tr("Normal Map"),
|
|
|
|
|
.type = "VECTOR",
|
|
|
|
|
.color = -10238109,
|
|
|
|
|
.default_value = f32_array_create_xyz(0.5, 0.5, 1.0),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.display = 0}),
|
|
|
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
|
|
|
.node_id = 0,
|
|
|
|
|
.name = _tr("Emission"),
|
|
|
|
|
.type = "VALUE",
|
|
|
|
|
.color = 0xffa1a1a1,
|
|
|
|
|
.default_value = f32_array_create_x(1.0),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.display = 0}),
|
|
|
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
|
|
|
.node_id = 0,
|
|
|
|
|
.name = _tr("Height"),
|
|
|
|
|
.type = "VALUE",
|
|
|
|
|
.color = 0xffa1a1a1,
|
|
|
|
|
.default_value = f32_array_create_x(1.0),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.display = 0}),
|
|
|
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
|
|
|
.node_id = 0,
|
|
|
|
|
.name = _tr("Subsurface"),
|
|
|
|
|
.type = "VALUE",
|
|
|
|
|
.color = 0xffa1a1a1,
|
|
|
|
|
.default_value = f32_array_create_x(1.0),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.display = 0}),
|
|
|
|
|
},
|
|
|
|
|
9),
|
|
|
|
|
.buttons = any_array_create_from_raw(
|
|
|
|
|
(void *[]){
|
|
|
|
|
GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Layer"),
|
|
|
|
|
.type = "ENUM",
|
|
|
|
|
.output = -1,
|
|
|
|
|
.default_value = f32_array_create_x(0),
|
|
|
|
|
.data = u8_array_create_from_string(""),
|
|
|
|
|
.min = 0.0,
|
|
|
|
|
.max = 1.0,
|
|
|
|
|
.precision = 100,
|
|
|
|
|
.height = 0}),
|
|
|
|
|
},
|
|
|
|
|
1),
|
|
|
|
|
.width = 0,
|
|
|
|
|
.flags = 0});
|
|
|
|
|
gc_root(layer_node_def);
|
|
|
|
|
|
2026-03-06 12:56:38 +01:00
|
|
|
any_array_push(nodes_material_input, layer_node_def);
|
|
|
|
|
any_map_set(parser_material_node_vectors, "LAYER", layer_node_vector);
|
|
|
|
|
any_map_set(parser_material_node_values, "LAYER", layer_node_value);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-07 21:12:59 +01:00
|
|
|
char *layer_node_vector(ui_node_t *node, ui_node_socket_t *socket) {
|
2026-03-10 11:49:57 +01:00
|
|
|
i32 l = node->buttons->buffer[0]->default_value->buffer[0];
|
|
|
|
|
char *ls = i32_to_string(l);
|
2026-03-06 12:56:38 +01:00
|
|
|
if (socket == node->outputs->buffer[0]) { // Base
|
2026-03-10 11:49:57 +01:00
|
|
|
node_shader_add_texture(parser_material_kong, string("texpaint%s", ls), string("_texpaint%s", ls));
|
|
|
|
|
return string("sample(texpaint%s, sampler_linear, tex_coord).rgb", ls);
|
2026-03-06 12:56:38 +01:00
|
|
|
}
|
|
|
|
|
else { // Normal
|
2026-03-10 11:49:57 +01:00
|
|
|
node_shader_add_texture(parser_material_kong, string("texpaint_nor%s", ls), string("_texpaint_nor%s", ls));
|
|
|
|
|
return string("sample(texpaint_nor%s, sampler_linear, tex_coord).rgb", ls);
|
2026-03-06 12:56:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-07 21:12:59 +01:00
|
|
|
char *layer_node_value(ui_node_t *node, ui_node_socket_t *socket) {
|
2026-03-10 11:49:57 +01:00
|
|
|
i32 l = node->buttons->buffer[0]->default_value->buffer[0];
|
|
|
|
|
char *ls = i32_to_string(l);
|
2026-03-06 12:56:38 +01:00
|
|
|
if (socket == node->outputs->buffer[1]) { // Opac
|
2026-03-10 11:49:57 +01:00
|
|
|
node_shader_add_texture(parser_material_kong, string("texpaint%s", ls), string("_texpaint%s", ls));
|
|
|
|
|
return string("sample(texpaint%s, sampler_linear, tex_coord).a", ls);
|
2026-03-06 12:56:38 +01:00
|
|
|
}
|
|
|
|
|
else if (socket == node->outputs->buffer[2]) { // Occ
|
2026-03-10 11:49:57 +01:00
|
|
|
node_shader_add_texture(parser_material_kong, string("texpaint_pack%s", ls), string("_texpaint_pack%s", ls));
|
|
|
|
|
return string("sample(texpaint_pack%s, sampler_linear, tex_coord).r", ls);
|
2026-03-06 12:56:38 +01:00
|
|
|
}
|
|
|
|
|
else if (socket == node->outputs->buffer[3]) { // Rough
|
2026-03-10 11:49:57 +01:00
|
|
|
node_shader_add_texture(parser_material_kong, string("texpaint_pack%s", ls), string("_texpaint_pack%s", ls));
|
|
|
|
|
return string("sample(texpaint_pack%s, sampler_linear, tex_coord).g", ls);
|
2026-03-06 12:56:38 +01:00
|
|
|
}
|
|
|
|
|
else if (socket == node->outputs->buffer[4]) { // Metal
|
2026-03-10 11:49:57 +01:00
|
|
|
node_shader_add_texture(parser_material_kong, string("texpaint_pack%s", ls), string("_texpaint_pack%s", ls));
|
|
|
|
|
return string("sample(texpaint_pack%s, sampler_linear, tex_coord).b", ls);
|
2026-03-06 12:56:38 +01:00
|
|
|
}
|
|
|
|
|
else if (socket == node->outputs->buffer[6]) {
|
|
|
|
|
return "0.0";
|
|
|
|
|
} // Emission
|
|
|
|
|
else if (socket == node->outputs->buffer[7]) { // Height
|
2026-03-10 11:49:57 +01:00
|
|
|
node_shader_add_texture(parser_material_kong, string("texpaint_pack%s", ls), string("_texpaint_pack%s", ls));
|
|
|
|
|
return string("sample(texpaint_pack%s, sampler_linear, tex_coord).a", ls);
|
2026-03-06 12:56:38 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return "0.0";
|
|
|
|
|
} // Subsurface
|
|
|
|
|
}
|