Preferences: Add option to disable edit-mode wire Antialiasing

Requested by some users who prefer old wireframe precision.

Smooth wires are still enabled by defaults as they don't have a noticeable
perf impact.

Application restart is needed for changes to take effects.
This commit is contained in:
Clément Foucault 2019-03-04 19:15:18 +01:00
parent 81ae7773e7
commit 89db684d82
Notes: blender-bot 2023-02-14 09:02:41 +01:00
Referenced by issue #58188, Extreme FPS loss (24x) between 2.79 and 2.8 with particle systems
9 changed files with 25 additions and 7 deletions

View File

@ -608,6 +608,7 @@ class USERPREF_PT_viewport_quality(PreferencePanel):
flow.prop(system, "gpu_viewport_quality")
flow.prop(system, "multi_sample", text="Multisampling")
flow.prop(system, "gpencil_multi_sample", text="Grease Pencil Multisampling")
flow.prop(system, "use_edit_mode_smooth_wire")
class USERPREF_PT_viewport_textures(PreferencePanel):

View File

@ -24,7 +24,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 280
#define BLENDER_SUBVERSION 45
#define BLENDER_SUBVERSION 46
/* Several breakages with 280, e.g. collections vs layers */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0

View File

@ -2799,9 +2799,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
{
/* Versioning code until next subversion bump goes here. */
if (!MAIN_VERSION_ATLEAST(bmain, 280, 46)) {
/* Add wireframe color. */
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "wire_color_type")) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
@ -2826,4 +2824,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
{
/* Versioning code until next subversion bump goes here. */
}
}

View File

@ -476,6 +476,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
GP_PAINT_DEPRECATED_0);
}
if (!USER_VERSION_ATLEAST(280, 46)) {
userdef->uiflag2 |= USER_EDIT_MODE_SMOOTH_WIRE;
}
/**
* Include next version bump.
*/

View File

@ -197,6 +197,7 @@ static void EDIT_MESH_engine_init(void *vedata)
geom_sh_code[0] = NULL;
}
const char *use_geom_def = use_geom_shader ? "#define USE_GEOM_SHADER\n" : "";
const char *use_smooth_def = (U.uiflag2 & USER_EDIT_MODE_SMOOTH_WIRE) ? "#define USE_SMOOTH_WIRE\n" : "";
sh_data->overlay_face = GPU_shader_create_from_arrays({
.vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL},
.frag = (const char *[]){datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL},
@ -205,13 +206,13 @@ static void EDIT_MESH_engine_init(void *vedata)
sh_data->overlay_edge = GPU_shader_create_from_arrays({
.vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL},
.frag = (const char *[]){lib, datatoc_edit_mesh_overlay_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg_data->def, use_geom_def, "#define EDGE\n", NULL},
.defs = (const char *[]){sh_cfg_data->def, use_geom_def, use_smooth_def, "#define EDGE\n", NULL},
.geom = (use_geom_shader) ? geom_sh_code : NULL,
});
sh_data->overlay_edge_flat = GPU_shader_create_from_arrays({
.vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL},
.frag = (const char *[]){lib, datatoc_edit_mesh_overlay_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg_data->def, use_geom_def, "#define EDGE\n", "#define FLAT\n", NULL},
.defs = (const char *[]){sh_cfg_data->def, use_geom_def, use_smooth_def, "#define EDGE\n", "#define FLAT\n", NULL},
.geom = (use_geom_shader) ? geom_sh_code : NULL,
});
sh_data->overlay_vert = GPU_shader_create_from_arrays({

View File

@ -24,7 +24,7 @@ void main()
{
float dist = abs(edgeCoord_f) - max(sizeEdge * edgeScale - 0.5, 0.0);
float dist_outer = dist - max(sizeEdge * edgeScale, 1.0);
#if 1
#ifdef USE_SMOOTH_WIRE
float mix_w = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist);
float mix_w_outer = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist_outer);
#else

View File

@ -40,8 +40,11 @@ void main()
float half_size = sizeEdge * edgeScale;
/* Enlarge edge for flag display. */
half_size += (finalColorOuter_f.a > 0.0) ? max(sizeEdge * edgeScale, 1.0) : 0.0;
#ifdef USE_SMOOTH_WIRE
/* Add 1 px for AA */
half_size += 0.5;
#endif
vec3 edge_ofs = half_size * viewportSizeInv.xyy * vec3(1.0, 1.0, 0.0);

View File

@ -899,6 +899,7 @@ typedef enum eUserpref_UI_Flag2 {
USER_UIFLAG2_DEPRECATED_0 = (1 << 0),
USER_REGION_OVERLAP = (1 << 1),
USER_TRACKPAD_NATURAL = (1 << 2),
USER_EDIT_MODE_SMOOTH_WIRE = (1 << 3),
} eUserpref_UI_Flag2;
/** #UserDef.tablet_api */

View File

@ -4408,6 +4408,12 @@ static void rna_def_userdef_system(BlenderRNA *brna)
"Enable OpenGL multi-sampling, only for systems that support it, requires restart");
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
prop = RNA_def_property(srna, "use_edit_mode_smooth_wire", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_EDIT_MODE_SMOOTH_WIRE);
RNA_def_property_ui_text(prop, "Edit-Mode Smooth Wires",
"Enable Edit-Mode edge smoothing, reducing aliasing, requires restart");
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
/* grease pencil anti-aliasing */
prop = RNA_def_property(srna, "gpencil_multi_sample", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_multisamples");