Add brush alpha discard option
This commit is contained in:
@@ -473,6 +473,15 @@ function box_preferences_usage_tab() {
|
||||
make_material_parse_paint_material();
|
||||
}
|
||||
ui.enabled = true;
|
||||
|
||||
let alpha_discard_handle: ui_handle_t = ui_handle(__ID__);
|
||||
if (alpha_discard_handle.init) {
|
||||
alpha_discard_handle.f = config_raw.brush_alpha_discard;
|
||||
}
|
||||
config_raw.brush_alpha_discard = ui_slider(alpha_discard_handle, tr("Alpha Discard"), 0.0, 1.0, true);
|
||||
if (alpha_discard_handle.changed) {
|
||||
make_material_parse_paint_material();
|
||||
}
|
||||
}
|
||||
|
||||
function box_preferences_pen_tab() {
|
||||
|
||||
+14
-11
@@ -94,6 +94,7 @@ function config_save() {
|
||||
json_encode_bool("material_live", config_raw.material_live);
|
||||
json_encode_bool("brush_depth_reject", config_raw.brush_depth_reject);
|
||||
json_encode_bool("brush_angle_reject", config_raw.brush_angle_reject);
|
||||
json_encode_f32("brush_alpha_discard", config_raw.brush_alpha_discard);
|
||||
json_encode_i32("dilate_radius", config_raw.dilate_radius);
|
||||
json_encode_string("blender", config_raw.blender);
|
||||
json_encode_i32("scene_atlas_res", config_raw.scene_atlas_res);
|
||||
@@ -195,17 +196,18 @@ function config_init() {
|
||||
/// else
|
||||
config_raw.material_live = true;
|
||||
/// end
|
||||
config_raw.brush_depth_reject = true;
|
||||
config_raw.brush_angle_reject = true;
|
||||
config_raw.brush_live = false;
|
||||
config_raw.show_asset_names = false;
|
||||
config_raw.dilate_radius = 2;
|
||||
config_raw.blender = "";
|
||||
config_raw.scene_atlas_res = texture_res_t.RES8192;
|
||||
config_raw.pathtrace_mode = pathtrace_mode_t.FAST;
|
||||
config_raw.grid_snap = false;
|
||||
config_raw.experimental = false;
|
||||
config_raw.neural_backend = neural_backend_t.VULKAN;
|
||||
config_raw.brush_depth_reject = true;
|
||||
config_raw.brush_angle_reject = true;
|
||||
config_raw.brush_alpha_discard = 0.1;
|
||||
config_raw.brush_live = false;
|
||||
config_raw.show_asset_names = false;
|
||||
config_raw.dilate_radius = 2;
|
||||
config_raw.blender = "";
|
||||
config_raw.scene_atlas_res = texture_res_t.RES8192;
|
||||
config_raw.pathtrace_mode = pathtrace_mode_t.FAST;
|
||||
config_raw.grid_snap = false;
|
||||
config_raw.experimental = false;
|
||||
config_raw.neural_backend = neural_backend_t.VULKAN;
|
||||
}
|
||||
else {
|
||||
// Discard old config
|
||||
@@ -470,6 +472,7 @@ type config_t = {
|
||||
material_live?: bool;
|
||||
brush_depth_reject?: bool;
|
||||
brush_angle_reject?: bool;
|
||||
brush_alpha_discard?: f32;
|
||||
dilate_radius?: i32;
|
||||
blender?: string;
|
||||
scene_atlas_res?: i32;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
let make_mesh_preview_opacity_discard_decal: f32 = 0.05;
|
||||
|
||||
function make_mesh_preview_run(data: material_t, matcon: material_context_t): node_shader_context_t {
|
||||
let context_id: string = "mesh";
|
||||
let props: shader_context_t = {
|
||||
@@ -58,8 +56,8 @@ function make_mesh_preview_run(data: material_t, matcon: material_context_t): no
|
||||
}
|
||||
}
|
||||
if (decal) {
|
||||
let opac: f32 = make_mesh_preview_opacity_discard_decal;
|
||||
node_shader_write_frag(kong, "if (opacity < " + opac + ") { discard; }");
|
||||
let opac: f32 = config_raw.brush_alpha_discard;
|
||||
node_shader_write_frag(kong, "if (opacity <= float(" + opac + ")) { discard; }");
|
||||
}
|
||||
|
||||
kong.frag_out = "float4[2]";
|
||||
|
||||
@@ -336,7 +336,7 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
}
|
||||
}
|
||||
|
||||
node_shader_write_frag(kong, "if (opacity == 0.0) { discard; }");
|
||||
node_shader_write_frag(kong, "if (opacity <= float(" + config_raw.brush_alpha_discard + ")) { discard; }");
|
||||
|
||||
if (context_raw.tool == tool_type_t.PARTICLE) { // Particle mask
|
||||
make_particle_mask(kong);
|
||||
@@ -356,7 +356,7 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
node_shader_add_texture(kong, "paintmask");
|
||||
node_shader_write_frag(kong, "var sample_mask: float = sample_lod(paintmask, sampler_linear, sample_tc, 0.0).r;");
|
||||
node_shader_write_frag(kong, "str = max(str, sample_mask);");
|
||||
// write(frag, "str = clamp(str + sample_mask, 0.0, 1.0);");
|
||||
// node_shader_write_frag(kong, "str = clamp(str + sample_mask, 0.0, 1.0);");
|
||||
|
||||
node_shader_add_texture(kong, "texpaint_undo", "_texpaint_undo");
|
||||
node_shader_write_frag(kong, "var sample_undo: float4 = sample_lod(texpaint_undo, sampler_linear, sample_tc, 0.0);");
|
||||
|
||||
Reference in New Issue
Block a user