Workbench: Viewport AA Preferences
In recent changes the viewport_quality setting was not working what users expected. This change will separate the anti-aliasing method that is being used. We now have three settings: * scene.display.render_aa: Will be used during `Render Image`. * scene.display.viewport_aa: Will be used during `Viewport Render Image`. * userpref.viewport_aa: Will be used in the 3d view. The viewport_quality setting has been replaced by the viewport_aa setting as it was the only thing in currently controlled. Reviewed By: brecht Maniphest Tasks: T64132 Differential Revision: https://developer.blender.org/D4828
This commit is contained in:
@@ -611,7 +611,7 @@ class USERPREF_PT_viewport_quality(PreferencePanel, Panel):
|
||||
|
||||
flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
|
||||
flow.prop(system, "gpu_viewport_quality")
|
||||
flow.prop(system, "viewport_aa")
|
||||
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")
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*
|
||||
* Version patch user preferences.
|
||||
*/
|
||||
|
||||
#define DNA_DEPRECATED_ALLOW
|
||||
#include <string.h>
|
||||
|
||||
#include "BLI_math.h"
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "DNA_userdef_types.h"
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_addon.h"
|
||||
#include "BKE_colorband.h"
|
||||
@@ -554,6 +555,29 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
|
||||
userdef->dupflag |= USER_DUP_GPENCIL;
|
||||
}
|
||||
|
||||
if (!USER_VERSION_ATLEAST(280, 60)) {
|
||||
const float GPU_VIEWPORT_QUALITY_FXAA = 0.10f;
|
||||
const float GPU_VIEWPORT_QUALITY_TAA8 = 0.25f;
|
||||
const float GPU_VIEWPORT_QUALITY_TAA16 = 0.6f;
|
||||
const float GPU_VIEWPORT_QUALITY_TAA32 = 0.8f;
|
||||
|
||||
if (userdef->gpu_viewport_quality < GPU_VIEWPORT_QUALITY_FXAA) {
|
||||
userdef->viewport_aa = SCE_DISPLAY_AA_OFF;
|
||||
}
|
||||
else if (userdef->gpu_viewport_quality < GPU_VIEWPORT_QUALITY_TAA8) {
|
||||
userdef->viewport_aa = SCE_DISPLAY_AA_FXAA;
|
||||
}
|
||||
else if (userdef->gpu_viewport_quality < GPU_VIEWPORT_QUALITY_TAA16) {
|
||||
userdef->viewport_aa = SCE_DISPLAY_AA_SAMPLES_8;
|
||||
}
|
||||
else if (userdef->gpu_viewport_quality < GPU_VIEWPORT_QUALITY_TAA32) {
|
||||
userdef->viewport_aa = SCE_DISPLAY_AA_SAMPLES_16;
|
||||
}
|
||||
else {
|
||||
userdef->viewport_aa = SCE_DISPLAY_AA_SAMPLES_32;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include next version bump.
|
||||
*/
|
||||
|
||||
@@ -91,23 +91,19 @@ int workbench_taa_calculate_num_iterations(WORKBENCH_Data *vedata)
|
||||
WORKBENCH_StorageList *stl = vedata->stl;
|
||||
WORKBENCH_PrivateData *wpd = stl->g_data;
|
||||
const Scene *scene = DRW_context_state_get()->scene;
|
||||
int result = scene->display.viewport_aa;
|
||||
int result;
|
||||
if (workbench_is_taa_enabled(wpd)) {
|
||||
if (DRW_state_is_image_render()) {
|
||||
result = scene->display.render_aa;
|
||||
}
|
||||
else if (IN_RANGE_INCL(wpd->preferences->gpu_viewport_quality,
|
||||
GPU_VIEWPORT_QUALITY_TAA8,
|
||||
GPU_VIEWPORT_QUALITY_TAA16)) {
|
||||
result = MIN2(result, 8);
|
||||
}
|
||||
else if (IN_RANGE_INCL(wpd->preferences->gpu_viewport_quality,
|
||||
GPU_VIEWPORT_QUALITY_TAA16,
|
||||
GPU_VIEWPORT_QUALITY_TAA32)) {
|
||||
result = MIN2(result, 16);
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
if (draw_ctx->v3d) {
|
||||
result = scene->display.viewport_aa;
|
||||
}
|
||||
else {
|
||||
result = scene->display.render_aa;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = MIN2(result, 32);
|
||||
result = wpd->preferences->viewport_aa;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -319,23 +319,32 @@ typedef struct WORKBENCH_ObjectData {
|
||||
BLI_INLINE bool workbench_is_taa_enabled(WORKBENCH_PrivateData *wpd)
|
||||
{
|
||||
if (DRW_state_is_image_render()) {
|
||||
return DRW_context_state_get()->scene->display.render_aa > SCE_DISPLAY_AA_FXAA;
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
if (draw_ctx->v3d) {
|
||||
return draw_ctx->scene->display.viewport_aa > SCE_DISPLAY_AA_FXAA;
|
||||
}
|
||||
else {
|
||||
return draw_ctx->scene->display.render_aa > SCE_DISPLAY_AA_FXAA;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return DRW_context_state_get()->scene->display.viewport_aa > SCE_DISPLAY_AA_FXAA &&
|
||||
wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 &&
|
||||
!wpd->is_playback;
|
||||
return wpd->preferences->viewport_aa > SCE_DISPLAY_AA_FXAA && !wpd->is_playback;
|
||||
}
|
||||
}
|
||||
|
||||
BLI_INLINE bool workbench_is_fxaa_enabled(WORKBENCH_PrivateData *wpd)
|
||||
{
|
||||
if (DRW_state_is_image_render()) {
|
||||
return DRW_context_state_get()->scene->display.render_aa == SCE_DISPLAY_AA_FXAA;
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
if (draw_ctx->v3d) {
|
||||
return draw_ctx->scene->display.viewport_aa == SCE_DISPLAY_AA_FXAA;
|
||||
}
|
||||
else {
|
||||
return draw_ctx->scene->display.render_aa == SCE_DISPLAY_AA_FXAA;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_FXAA &&
|
||||
DRW_context_state_get()->scene->display.viewport_aa == SCE_DISPLAY_AA_FXAA) {
|
||||
if (wpd->preferences->viewport_aa == SCE_DISPLAY_AA_FXAA) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,6 @@ struct ColorBand;
|
||||
|
||||
#define MAX_STYLE_NAME 64
|
||||
|
||||
#define GPU_VIEWPORT_QUALITY_FXAA 0.10f
|
||||
#define GPU_VIEWPORT_QUALITY_TAA8 0.25f
|
||||
#define GPU_VIEWPORT_QUALITY_TAA16 0.6f
|
||||
#define GPU_VIEWPORT_QUALITY_TAA32 0.8f
|
||||
|
||||
/** default offered by Blender.
|
||||
* #uiFont.uifont_id */
|
||||
typedef enum eUIFont_ID {
|
||||
@@ -635,7 +630,7 @@ typedef struct UserDef {
|
||||
short undosteps;
|
||||
char _pad1[2];
|
||||
int undomemory;
|
||||
float gpu_viewport_quality;
|
||||
float gpu_viewport_quality DNA_DEPRECATED;
|
||||
short gp_manhattendist, gp_euclideandist, gp_eraser;
|
||||
/** #eGP_UserdefSettings. */
|
||||
short gp_settings;
|
||||
@@ -763,7 +758,9 @@ typedef struct UserDef {
|
||||
|
||||
char factor_display_type;
|
||||
|
||||
char _pad5[3];
|
||||
char viewport_aa;
|
||||
|
||||
char _pad5[2];
|
||||
} UserDef;
|
||||
|
||||
/* from blenkernel blender.c */
|
||||
|
||||
@@ -6592,13 +6592,14 @@ static void rna_def_scene_display(BlenderRNA *brna)
|
||||
|
||||
prop = RNA_def_property(srna, "render_aa", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, rna_enum_scene_display_aa_methods);
|
||||
RNA_def_property_ui_text(prop, "Render Anti-Aliasing", "Method of anti-aliasing when rendering");
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Render Anti-Aliasing", "Method of anti-aliasing when rendering final image");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
|
||||
prop = RNA_def_property(srna, "viewport_aa", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, rna_enum_scene_display_aa_methods);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Viewport Anti-Aliasing", "Method of anti-aliasing in 3d viewport");
|
||||
prop, "Viewport Anti-Aliasing", "Method of anti-aliasing when rendering 3d viewport");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
|
||||
/* OpenGL render engine settings. */
|
||||
|
||||
@@ -99,6 +99,45 @@ static const EnumPropertyItem rna_enum_studio_light_type_items[] = {
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem rna_enum_userdef_viewport_aa_items[] = {
|
||||
{SCE_DISPLAY_AA_OFF,
|
||||
"OFF",
|
||||
0,
|
||||
"No Anti-Aliasing",
|
||||
"Scene will be rendering without any anti-aliasing"},
|
||||
{SCE_DISPLAY_AA_FXAA,
|
||||
"FXAA",
|
||||
0,
|
||||
"Single Pass Anti-Aliasing",
|
||||
"Scene will be rendered using a single pass anti-aliasing method (FXAA)"},
|
||||
{SCE_DISPLAY_AA_SAMPLES_5,
|
||||
"5",
|
||||
0,
|
||||
"5 Samples",
|
||||
"Scene will be rendered using 5 anti-aliasing samples"},
|
||||
{SCE_DISPLAY_AA_SAMPLES_8,
|
||||
"8",
|
||||
0,
|
||||
"8 Samples",
|
||||
"Scene will be rendered using 8 anti-aliasing samples"},
|
||||
{SCE_DISPLAY_AA_SAMPLES_11,
|
||||
"11",
|
||||
0,
|
||||
"11 Samples",
|
||||
"Scene will be rendered using 11 anti-aliasing samples"},
|
||||
{SCE_DISPLAY_AA_SAMPLES_16,
|
||||
"16",
|
||||
0,
|
||||
"16 Samples",
|
||||
"Scene will be rendered using 16 anti-aliasing samples"},
|
||||
{SCE_DISPLAY_AA_SAMPLES_32,
|
||||
"32",
|
||||
0,
|
||||
"32 Samples",
|
||||
"Scene will be rendered using 32 anti-aliasing samples"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
# include "BLI_math_vector.h"
|
||||
@@ -4731,12 +4770,11 @@ static void rna_def_userdef_system(BlenderRNA *brna)
|
||||
prop, "Region Overlap", "Draw tool/property regions over the main region");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
|
||||
|
||||
prop = RNA_def_property(srna, "gpu_viewport_quality", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, NULL, "gpu_viewport_quality");
|
||||
RNA_def_property_float_default(prop, 0.6f);
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
prop = RNA_def_property(srna, "viewport_aa", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, rna_enum_userdef_viewport_aa_items);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Viewport Quality", "Quality setting for Solid mode rendering in the 3d viewport");
|
||||
prop, "Viewport Anti-Aliasing", "Method of anti-aliasing in 3d viewport");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||
|
||||
prop = RNA_def_property(srna, "solid_lights", PROP_COLLECTION, PROP_NONE);
|
||||
|
||||
Reference in New Issue
Block a user