diff options
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl | 33 |
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 c19bf1e7b50..e1323f01d9e 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 @@ -197,7 +207,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 @@ -371,8 +380,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 @@ -424,7 +433,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; @@ -509,7 +518,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) { @@ -517,7 +526,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; @@ -548,7 +557,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; } @@ -568,7 +577,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; |