[Bf-blender-cvs] [de0fc2a540c] blender-v2.83-release: Fix T75061 Grease Pencil: MacOS: broken Gradient and Texture

Clément Foucault noreply at git.blender.org
Wed Sep 16 14:39:17 CEST 2020


Commit: de0fc2a540c75d10538e4ebaf0280f61efb13dd1
Author: Clément Foucault
Date:   Wed Sep 16 00:02:46 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBde0fc2a540c75d10538e4ebaf0280f61efb13dd1

Fix T75061 Grease Pencil: MacOS: broken Gradient and Texture

There is a driver bug that makes all the end of the structure unreadable.
Workaround this by just declaring a vec4 an unpacking manually.

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

M	source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl

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

diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
index 1e75f6dd5bb..5516591163b 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
@@ -7,13 +7,23 @@ struct gpMaterial {
   vec4 fill_uv_rot_scale;
   vec4 fill_uv_offset;
   /* Put float/int at the end to avoid padding error */
-  float stroke_texture_mix;
-  float stroke_u_scale;
-  float fill_texture_mix;
-  int flag;
+  /* Some drivers are completely messing the alignment or the fetches here.
+   * We are forced to pack these into vec4 otherwise we only get 0.0 as value. */
+  vec4 gp_mat_packed_1;
+  // float stroke_texture_mix;
+  // float stroke_u_scale;
+  // float fill_texture_mix;
+  // int gp_flag;
   /* Please ensure 16 byte alignment (multiple of vec4). */
 };
 
+#define MATERIAL(m) materials[m + gpMaterialOffset]
+
+#define stroke_texture_mix gp_mat_packed_1.x
+#define stroke_u_scale gp_mat_packed_1.y
+#define fill_texture_mix gp_mat_packed_1.z
+#define GP_FLAG(m) floatBitsToInt(MATERIAL(m).gp_mat_packed_1.w)
+
 /* flag */
 #define GP_STROKE_ALIGNMENT_STROKE 1
 #define GP_STROKE_ALIGNMENT_OBJECT 2
@@ -201,7 +211,6 @@ uniform int gpMaterialOffset;
 uniform float thicknessScale;
 uniform float thicknessWorldScale;
 #define thicknessIsScreenSpace (thicknessWorldScale < 0.0)
-#define MATERIAL(m) materials[m + gpMaterialOffset]
 
 #ifdef GPU_VERTEX_SHADER
 
@@ -375,8 +384,8 @@ void stroke_vertex()
 
 #  ifdef GP_MATERIAL_BUFFER_LEN
   if (m != -1) {
-    is_dot = GP_FLAG_TEST(MATERIAL(m).flag, GP_STROKE_ALIGNMENT);
-    is_squares = !GP_FLAG_TEST(MATERIAL(m).flag, GP_STROKE_DOTS);
+    is_dot = GP_FLAG_TEST(GP_FLAG(m), GP_STROKE_ALIGNMENT);
+    is_squares = !GP_FLAG_TEST(GP_FLAG(m), GP_STROKE_DOTS);
   }
 #  endif
 
@@ -428,7 +437,7 @@ void stroke_vertex()
 
   if (is_dot) {
 #  ifdef GP_MATERIAL_BUFFER_LEN
-    int alignement = MATERIAL(m).flag & GP_STROKE_ALIGNMENT;
+    int alignement = GP_FLAG(m) & GP_STROKE_ALIGNMENT;
 #  endif
 
     vec2 x_axis;
@@ -513,7 +522,7 @@ void stroke_vertex()
 
   color_output(stroke_col, vert_col, vert_strength * small_line_opacity, mix_tex);
 
-  matFlag = MATERIAL(m).flag & ~GP_FILL_FLAGS;
+  matFlag = GP_FLAG(m) & ~GP_FILL_FLAGS;
 #  endif
 
   if (strokeOrder3d) {
@@ -521,7 +530,7 @@ void stroke_vertex()
     depth = -1.0;
   }
 #  ifdef GP_MATERIAL_BUFFER_LEN
-  else if (GP_FLAG_TEST(MATERIAL(m).flag, GP_STROKE_OVERLAP)) {
+  else if (GP_FLAG_TEST(GP_FLAG(m), GP_STROKE_OVERLAP)) {
     /* Use the index of the point as depth.
      * This means the stroke can overlap itself. */
     depth = (point_id1 + strokeIndexOffset + 1.0) * 0.0000002;
@@ -552,7 +561,7 @@ void fill_vertex()
   float mix_tex = MATERIAL(m).fill_texture_mix;
 
   /* Special case: We don't modulate alpha in gradient mode. */
-  if (GP_FLAG_TEST(MATERIAL(m).flag, GP_FILL_GRADIENT_USE)) {
+  if (GP_FLAG_TEST(GP_FLAG(m), GP_FILL_GRADIENT_USE)) {
     fill_col.a = 1.0;
   }
 
@@ -572,7 +581,7 @@ void fill_vertex()
 
   color_output(fill_col, fcol_decode, 1.0, mix_tex);
 
-  matFlag = MATERIAL(m).flag & GP_FILL_FLAGS;
+  matFlag = GP_FLAG(m) & GP_FILL_FLAGS;
   matFlag |= m << GP_MATID_SHIFT;
 
   vec2 loc = MATERIAL(m).fill_uv_offset.xy;



More information about the Bf-blender-cvs mailing list