Refactor: Put ViewportAA as UserPref

By default users want AA in the viewport. For slower systems you want to
be able to turn it off. As in the future we would also like to support
TAA in the viewport we introduced it as a Max Viewport AA settings.

Also removed the drawoption to enable/disable AA per viewport
When rendering the AA is always turned on.
This commit is contained in:
Jeroen Bakker 2018-06-18 08:51:29 +02:00
parent 79546a4eb6
commit 04e2a5cef4
9 changed files with 29 additions and 12 deletions

View File

@ -544,6 +544,10 @@ class USERPREF_PT_system(Panel):
col.separator()
col.prop(system, "use_region_overlap")
col.separator()
col.label(text="Max Viewport Anti-aliasing Method")
col.prop(system, "max_anti_alias_method", text="")
col.separator()
col.label(text="Text Draw Options:")

View File

@ -3730,9 +3730,6 @@ class VIEW3D_PT_shading_options(Panel):
sub.prop(shading, "object_outline_color", text="")
layout.prop(view, "show_world")
row = layout.split(0.4)
row.active = not shading.show_xray
row.prop(shading, "show_anti_aliasing")
class VIEW3D_PT_overlay(Panel):

View File

@ -10,6 +10,7 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
const DRWContextState *draw_ctx = DRW_context_state_get();
const Scene *scene = draw_ctx->scene;
wpd->material_hash = BLI_ghash_ptr_new(__func__);
wpd->user_preferences = &U;
View3D *v3d = draw_ctx->v3d;
if (v3d) {

View File

@ -32,6 +32,7 @@
#include "DNA_image_types.h"
#include "DNA_view3d_types.h"
#include "DNA_world_types.h"
#include "DNA_userdef_types.h"
#include "DRW_render.h"
@ -50,7 +51,7 @@
#define STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd) (MATCAP_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL))
#define CAVITY_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_CAVITY)
#define SHADOW_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_SHADOW)
#define FXAA_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_EFFECT_FXAA && (!DRW_state_is_opengl_render()))
#define FXAA_ENABLED(wpd) (wpd->user_preferences->gpu_viewport_antialias & USER_AA_FXAA && (!DRW_state_is_opengl_render()))
#define SPECULAR_HIGHLIGHT_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT) && (!STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)))
#define OBJECT_ID_PASS_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE)
#define NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) (MATCAP_ENABLED(wpd) || STUDIOLIGHT_ENABLED(wpd) || SHADOW_ENABLED(wpd) || SPECULAR_HIGHLIGHT_ENABLED(wpd))
@ -150,6 +151,7 @@ typedef struct WORKBENCH_PrivateData {
struct GPUShader *transparent_accum_texture_hair_sh;
View3DShading shading;
StudioLight *studio_light;
UserDef *user_preferences;
int drawtype;
struct GPUUniformBuffer *world_ubo;
struct DRWShadingGroup *shadow_shgrp;

View File

@ -3034,6 +3034,7 @@ void init_userdef_do_versions(Main *bmain)
rgba_char_args_set(ts->panelcolors.sub_back, 0, 0, 0, 25);
}
}
U.gpu_viewport_antialias = USER_AA_FXAA;
}
/**

View File

@ -542,7 +542,7 @@ typedef struct UserDef {
char keyhandles_new; /* handle types for newly added keyframes */
char gpu_select_method;
char gpu_select_pick_deph;
char pad4;
char gpu_viewport_antialias;
char view_frame_type; /* eZoomFrame_Mode */
int view_frame_keyframes; /* number of keyframes to zoom around current frame */
@ -803,6 +803,12 @@ typedef enum eOpenGL_SelectOptions {
USER_SELECT_USE_SELECT_RENDERMODE = 2
} eOpenGL_SelectOptions;
/* max anti alias draw method UserDef.gpu_viewport_antialias */
typedef enum eOpenGL_AntiAliasMethod {
USER_AA_NONE = 0,
USER_AA_FXAA = 1,
} eOpenGL_AntiAliasMethod;
/* text draw options
* UserDef.text_render */
typedef enum eText_Draw_Options {

View File

@ -353,7 +353,6 @@ enum {
V3D_SHADING_SPECULAR_HIGHLIGHT = (1 << 4),
V3D_SHADING_CAVITY = (1 << 5),
V3D_SHADING_MATCAP_FLIP_X = (1 << 6),
V3D_SHADING_EFFECT_FXAA = (1 << 7),
};
/* View3DShading->single_color_type */

View File

@ -2346,12 +2346,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_anti_aliasing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_EFFECT_FXAA);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Anti Alias", "Draw the view using FXAA");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "selected_studio_light", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "StudioLight");
RNA_define_verify_sdna(0);

View File

@ -4091,6 +4091,12 @@ static void rna_def_userdef_system(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
static const EnumPropertyItem gpu_antialias_method_items[] = {
{USER_AA_NONE, "OFF", 0, "Off", "Disable Anti Alias in viewport"},
{USER_AA_FXAA, "FXAA", 0, "FXAA", "Use FXAA, a fast screenspace Anti Alias method"},
{0, NULL, 0, NULL, NULL}
};
srna = RNA_def_struct(brna, "UserPreferencesSystem", NULL);
RNA_def_struct_sdna(srna, "UserDef");
RNA_def_struct_nested(brna, srna, "UserPreferences");
@ -4349,6 +4355,13 @@ static void rna_def_userdef_system(BlenderRNA *brna)
"Draw tool/property regions over the main region, when using Triple Buffer");
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
prop = RNA_def_property(srna, "max_anti_alias_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "gpu_viewport_antialias");
RNA_def_property_enum_items(prop, gpu_antialias_method_items);
RNA_def_property_ui_text(prop, "Viewport Anti-aliasing",
"Method to draw the Anti-Aliasing in the viewport");
RNA_def_property_update(prop, 0, "rna_userdef_update");
#ifdef WITH_OPENSUBDIV
prop = RNA_def_property(srna, "opensubdiv_compute_type", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT);