[Bf-blender-cvs] [04e2a5cef41] blender2.8: Refactor: Put ViewportAA as UserPref

Jeroen Bakker noreply at git.blender.org
Mon Jun 18 08:54:37 CEST 2018


Commit: 04e2a5cef419a9fcfac0bdd92496815ae7bb2af3
Author: Jeroen Bakker
Date:   Mon Jun 18 08:51:29 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB04e2a5cef419a9fcfac0bdd92496815ae7bb2af3

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.

===================================================================

M	release/scripts/startup/bl_ui/space_userpref.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/draw/engines/workbench/workbench_data.c
M	source/blender/draw/engines/workbench/workbench_private.h
M	source/blender/editors/interface/resources.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 4f07bbb43f0..c929a3c0f7d 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -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:")
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 3cf85d23f59..fe1d23b4225 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -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):
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index 72d59068e03..45af9366a43 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -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) {
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 7a74deed357..90d8cfc3dd2 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -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;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index fcbdcfbd02b..79054190686 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -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;
 	}
 
 	/**
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 71821804ab7..187c9f57e64 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -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 {
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index ef1c9db183d..b7ad9f7d921 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -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 */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 845218e3296..5ce27a533b8 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -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);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 3b9aa5bbaa4..9986701d9c3 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -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);



More information about the Bf-blender-cvs mailing list