paint: add colorid viewport mask option
This commit is contained in:
@@ -482,7 +482,7 @@ swatch_color_t *util_clone_swatch_color(swatch_color_t *s);
|
||||
void import_keymap_run(char *path);
|
||||
void tab_plugins_draw(ui_handle_t *htab);
|
||||
void plugin_uv_unwrap_button();
|
||||
void make_discard_color_id(node_shader_t *kong);
|
||||
void make_discard_color_id(node_shader_t *kong, char *tex_coord);
|
||||
void make_discard_face(node_shader_t *kong);
|
||||
void make_discard_uv_island(node_shader_t *kong);
|
||||
void make_discard_material_id(node_shader_t *kong);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
void make_discard_color_id(node_shader_t *kong) {
|
||||
void make_discard_color_id(node_shader_t *kong, char *tex_coord) {
|
||||
node_shader_add_texture(kong, "texpaint_colorid", NULL); // 1x1 picker
|
||||
node_shader_add_texture(kong, "texcolorid", "_texcolorid"); // color map
|
||||
// node_shader_write_frag(kong, "var colorid_c1: float3 = texpaint_colorid[uint2(0, 0)].rgb;");
|
||||
node_shader_write_frag(kong, "var colorid_c14: float4 = texpaint_colorid[uint2(uint(0), uint(0))];");
|
||||
node_shader_write_frag(kong, "var colorid_c1: float3 = colorid_c14.rgb;");
|
||||
node_shader_write_frag(kong, "var colorid_c2: float3 = sample_lod(texcolorid, sampler_linear, input.tex_coord_pick, 0.0).rgb;");
|
||||
// node_shader_write_frag(kong, "if (void *(colorid_c1 != colorid_c2)) { discard };");
|
||||
node_shader_write_frag(kong, string("var colorid_c2: float3 = sample_lod(texcolorid, sampler_linear, input.%s, 0.0).rgb;", tex_coord));
|
||||
// node_shader_write_frag(kong, "if (any(colorid_c1 != colorid_c2)) { discard };");
|
||||
node_shader_write_frag(kong, "if (colorid_c1.r != colorid_c2.r || colorid_c1.g != colorid_c2.g || colorid_c1.b != colorid_c2.b) { discard; }");
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ void make_discard_face(node_shader_t *kong) {
|
||||
node_shader_write_frag(kong, "var face_c1: float4 = textrianglemap[uint2(uint(tex_coord_inp.x * constants.textrianglemap_size.x), uint(tex_coord_inp.y * "
|
||||
"constants.textrianglemap_size.y))];");
|
||||
node_shader_write_frag(kong, "var face_c2: float4 = sample_lod(textrianglemap, sampler_linear, input.tex_coord_pick, 0.0);");
|
||||
// node_shader_write_frag(kong, "if (void *(face_c1 != face_c2)) { discard; }");
|
||||
// node_shader_write_frag(kong, "if (any(face_c1 != face_c2)) { discard; }");
|
||||
node_shader_write_frag(kong, "if (face_c1.x != face_c2.x || face_c1.y != face_c2.y || face_c1.z != face_c2.z || face_c1.w != face_c2.w) { discard; }");
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +168,11 @@ node_shader_context_t *make_mesh_run(material_t *data, i32 layer_pass) {
|
||||
sculpt_make_mesh_run(kong, l);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_context->colorid_viewport_mask && g_context->tool != TOOL_TYPE_COLORID) {
|
||||
make_discard_color_id(kong, "tex_coord");
|
||||
}
|
||||
|
||||
if (g_context->tool == TOOL_TYPE_COLORID) {
|
||||
texture_count++;
|
||||
node_shader_add_texture(kong, "texcolorid", "_texcolorid");
|
||||
|
||||
@@ -266,7 +266,7 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc
|
||||
node_shader_add_out(kong, "tex_coord_pick: float2");
|
||||
node_shader_write_vert(kong, "output.tex_coord_pick = input.tex;");
|
||||
if (g_context->colorid_picked) {
|
||||
make_discard_color_id(kong);
|
||||
make_discard_color_id(kong, "tex_coord_pick");
|
||||
}
|
||||
if (face_fill) {
|
||||
make_discard_face(kong);
|
||||
|
||||
@@ -894,6 +894,10 @@ void render_path_paint_bind_layers() {
|
||||
render_path_bind_target(string("texpaint_sculpt%d", l->id), string("texpaint_sculpt%d", l->id));
|
||||
}
|
||||
}
|
||||
|
||||
if (g_context->colorid_picked && g_context->colorid_viewport_mask) {
|
||||
render_path_bind_target("texpaint_colorid", "texpaint_colorid");
|
||||
}
|
||||
}
|
||||
|
||||
void render_path_paint_unbind_layers() {
|
||||
|
||||
@@ -253,6 +253,7 @@ typedef struct context {
|
||||
struct gpu_texture *mask_preview_rgba32;
|
||||
struct slot_layer *mask_preview_last;
|
||||
bool colorid_picked;
|
||||
bool colorid_viewport_mask;
|
||||
bool material_preview;
|
||||
mat4_t saved_camera;
|
||||
tool_type_t color_picker_previous_tool;
|
||||
|
||||
@@ -138,6 +138,12 @@ void ui_header_draw_tool_properties() {
|
||||
history_new_white_mask();
|
||||
}
|
||||
ui->enabled = true;
|
||||
|
||||
ui_handle_t *h_viewport_mask = ui_handle(__ID__);
|
||||
g_context->colorid_viewport_mask = ui_check(h_viewport_mask, tr("Viewport Mask"), "");
|
||||
if (h_viewport_mask->changed) {
|
||||
make_material_parse_mesh_material();
|
||||
}
|
||||
}
|
||||
else if (g_context->tool == TOOL_TYPE_PICKER || g_context->tool == TOOL_TYPE_MATERIAL) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user