Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-09-16 01:02:46 +0300
committerJeroen Bakker <jeroen@blender.org>2020-09-16 15:18:28 +0300
commitde0fc2a540c75d10538e4ebaf0280f61efb13dd1 (patch)
tree9361a9214a480013a56cb01e2483d90c5880905d
parentade72e46fdec77e53ad956e88dc4f971684b503a (diff)
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.
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl33
1 files changed, 21 insertions, 12 deletions
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;