UI: Custom Face Orientation Colors
authorHarley Acheson <harley.acheson@gmail.com>
Sat, 7 Dec 2019 16:16:45 +0000 (08:16 -0800)
committerHarley Acheson <harley.acheson@gmail.com>
Sat, 7 Dec 2019 16:16:45 +0000 (08:16 -0800)
Adds theme settings to allow change of front and back faces of the Face Orientation overlay

Differential Revision: https://developer.blender.org/D6262

Reviewed by Jeroen Bakker

12 files changed:
release/datafiles/userdef/userdef_default_theme.c
source/blender/blenloader/intern/versioning_userdef.c
source/blender/draw/engines/overlay/overlay_facing.c
source/blender/draw/engines/overlay/overlay_shader.c
source/blender/draw/engines/overlay/shaders/facing_frag.glsl
source/blender/draw/intern/draw_common.c
source/blender/draw/intern/draw_common.h
source/blender/draw/intern/shaders/common_globals_lib.glsl
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/resources.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index 383f3542c7fc4b4b899f21aeea42ef89c6adf0d7..147b55f60ef1245ed58f3a9f2ed5f4b8989f35d5 100644 (file)
@@ -327,6 +327,8 @@ const bTheme U_theme_default = {
     .face = RGBA(0xffffff12),
     .face_select = RGBA(0xffa5526c),
     .face_dot = RGBA(0xff8a00ff),
+    .face_back = RGBA(0xff0000b3),
+    .face_front = RGBA(0x0000ffb3),
     .extra_edge_len = RGBA(0x150806ff),
     .extra_edge_angle = RGBA(0x4d4d00ff),
     .extra_face_angle = RGBA(0x0000ccff),
index 4c85b5abd9765bd091561c9e4b166d7ff545281a..d097ed630b0ae16f2f2db06acfdf8d4fd01d1a76 100644 (file)
@@ -163,6 +163,8 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
     FROM_DEFAULT_V4_UCHAR(space_sequencer.anim_preview_range);
     FROM_DEFAULT_V4_UCHAR(space_text.line_numbers);
     FROM_DEFAULT_V4_UCHAR(tui.widget_text_cursor);
+    FROM_DEFAULT_V4_UCHAR(space_view3d.face_back);
+    FROM_DEFAULT_V4_UCHAR(space_view3d.face_front);
   }
 
 #undef FROM_DEFAULT_V4_UCHAR
index ea6f088e8e11922f0070e6289bf1d99e1803e128..fd974e9b8b80e8ea21db15df8d115c583a0a2924 100644 (file)
@@ -38,6 +38,7 @@ void OVERLAY_facing_cache_init(OVERLAY_Data *vedata)
 
   GPUShader *sh = OVERLAY_shader_facing();
   pd->facing_grp = DRW_shgroup_create(sh, psl->facing_ps);
+  DRW_shgroup_uniform_block_persistent(pd->facing_grp, "globalsBlock", G_draw.block_ubo);
 }
 
 void OVERLAY_facing_cache_populate(OVERLAY_Data *vedata, Object *ob)
index 22f025336eff7268998d1bede62f653f2f46ac87..7bd3cf4a067d3b75a1314ec6f68099804ddbe312 100644 (file)
@@ -845,7 +845,7 @@ GPUShader *OVERLAY_shader_facing(void)
                                  datatoc_common_view_lib_glsl,
                                  datatoc_facing_vert_glsl,
                                  NULL},
-        .frag = (const char *[]){datatoc_facing_frag_glsl, NULL},
+        .frag = (const char *[]){datatoc_common_globals_lib_glsl, datatoc_facing_frag_glsl, NULL},
         .defs = (const char *[]){sh_cfg->def, NULL},
     });
   }
@@ -1314,4 +1314,4 @@ void OVERLAY_shader_free(void)
   for (int i = 0; i < sizeof(g_formats) / sizeof(void *); i++, format++) {
     MEM_SAFE_FREE(*format);
   }
-}
\ No newline at end of file
+}
index 1ed35b4a421fbd07aba0402cafc95f0e8746cfdd..ca7b4eeaf475d3c71337e7c607275024bd7c16a9 100644 (file)
@@ -1,9 +1,6 @@
-uniform vec3 color_towards = vec3(0.0, 0.0, 1.0);
-uniform vec3 color_outwards = vec3(1.0, 0.0, 0.0);
-
 out vec4 fragColor;
 
 void main()
 {
-  fragColor = vec4(gl_FrontFacing ? color_towards : color_outwards, 0.7);
+  fragColor = gl_FrontFacing ? colorFaceFront : colorFaceBack;
 }
index 52adbcf0f78297144bea87e3a30061133476c4e2..65365ef71199f0a5bd5716c1ff00df90fc97a1bc 100644 (file)
@@ -80,6 +80,8 @@ void DRW_globals_update(void)
   UI_GetThemeColor4fv(TH_EDGE_FACESEL, gb->colorEdgeFaceSelect);
   UI_GetThemeColor4fv(TH_FACE, gb->colorFace);
   UI_GetThemeColor4fv(TH_FACE_SELECT, gb->colorFaceSelect);
+  UI_GetThemeColor4fv(TH_FACE_BACK, gb->colorFaceBack);
+  UI_GetThemeColor4fv(TH_FACE_FRONT, gb->colorFaceFront);
   UI_GetThemeColor4fv(TH_NORMAL, gb->colorNormal);
   UI_GetThemeColor4fv(TH_VNORMAL, gb->colorVNormal);
   UI_GetThemeColor4fv(TH_LNORMAL, gb->colorLNormal);
index bffb3ad5a1d97ac8708f9e4215fe24bd8ab60495..a486eb6ba77c1668fcfd31ffb2bc3712256b5317 100644 (file)
@@ -34,7 +34,7 @@ struct ParticleSystem;
 struct ViewLayer;
 
 #define UBO_FIRST_COLOR colorWire
-#define UBO_LAST_COLOR colorGridAxisZ
+#define UBO_LAST_COLOR colorFaceFront
 
 /* Used as ubo but colors can be directly referenced as well */
 /* Keep in sync with: common_globals_lib.glsl (globalsBlock) */
@@ -109,6 +109,9 @@ typedef struct GlobalsUboStorage {
   float colorGridAxisY[4];
   float colorGridAxisZ[4];
 
+  float colorFaceBack[4];
+  float colorFaceFront[4];
+
   /* NOTE! Put all color before UBO_LAST_COLOR */
   float screenVecs[2][4];                    /* padded as vec4  */
   float sizeViewport[2], sizeViewportInv[2]; /* packed as vec4 in glsl */
index 151932a3b4714cb7487b4f395ce44da01b535895..676492f227dba6ac7283fc2a7c2d399da06f944a 100644 (file)
@@ -70,6 +70,9 @@ layout(std140) uniform globalsBlock
   vec4 colorGridAxisY;
   vec4 colorGridAxisZ;
 
+  vec4 colorFaceBack;
+  vec4 colorFaceFront;
+
   vec4 screenVecs[2];
   vec4 sizeViewport; /* Inverted size in zw. */
 
index 738a91c085d2ce3f0477f8531f92886b2ddfe49c..bd8eed4e4aa5e34bd7f481b029b54af8aac0938c 100644 (file)
@@ -99,6 +99,8 @@ typedef enum ThemeColorID {
   TH_EDGE_FACESEL,
   TH_FACE,
   TH_FACE_SELECT,
+  TH_FACE_BACK,
+  TH_FACE_FRONT,
   TH_NORMAL,
   TH_VNORMAL,
   TH_LNORMAL,
index 99833e9200d18f29e78cbf4f47a8fe661dd86cf8..f8b4d85a212ddea1063a6118b69ed68127c02ca7 100644 (file)
@@ -401,6 +401,12 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
         case TH_FACE_SELECT:
           cp = ts->face_select;
           break;
+        case TH_FACE_BACK:
+          cp = ts->face_back;
+          break;
+        case TH_FACE_FRONT:
+          cp = ts->face_front;
+          break;
         case TH_FACE_DOT:
           cp = ts->face_dot;
           break;
index adab1f31507add3e46e5d52eebb9b14f109fc774..fb88f5c9dd4f5f0a3c5e09e49e45206f6e4a73f4 100644 (file)
@@ -276,7 +276,7 @@ typedef struct ThemeSpace {
   unsigned char edge[4], edge_select[4];
   unsigned char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4], edge_bevel[4];
   /** Solid faces. */
-  unsigned char face[4], face_select[4];
+  unsigned char face[4], face_select[4], face_back[4], face_front[4];
   /**  selected color. */
   unsigned char face_dot[4];
   unsigned char extra_edge_len[4], extra_edge_angle[4], extra_face_angle[4], extra_face_area[4];
index af30baf4a80443f66e47384af565e3eac1d1a506..52ad217a9e8f4f3e05d32b5d6918fc5fbba4cfd3 100644 (file)
@@ -1900,6 +1900,16 @@ static void rna_def_userdef_theme_spaces_face(StructRNA *srna)
   RNA_def_property_array(prop, 4);
   RNA_def_property_ui_text(prop, "Freestyle Face Mark", "");
   RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
+
+  prop = RNA_def_property(srna, "face_back", PROP_FLOAT, PROP_COLOR_GAMMA);
+  RNA_def_property_array(prop, 4);
+  RNA_def_property_ui_text(prop, "Face Orientation Back", "");
+  RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
+
+  prop = RNA_def_property(srna, "face_front", PROP_FLOAT, PROP_COLOR_GAMMA);
+  RNA_def_property_array(prop, 4);
+  RNA_def_property_ui_text(prop, "Face Orientation Front", "");
+  RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
 }
 
 static void rna_def_userdef_theme_spaces_paint_curves(StructRNA *srna)