diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-10-30 17:41:52 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-10-30 17:45:00 +0300 |
commit | e6f61a4a379bbb80296131fae0cef178e2145e52 (patch) | |
tree | ef7827aaaedbde2b27bda982e66f5c917cdf7157 /source | |
parent | aacdc3995886b4aad93044c4cec5e05f3dfc6cae (diff) |
GPencil: New material parameter to rotate texture
Add a parameter to rotate the texture for Dots and Squares
Differential Revision: https://developer.blender.org/D9369
Diffstat (limited to 'source')
5 files changed, 27 insertions, 2 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.c b/source/blender/draw/engines/gpencil/gpencil_draw_data.c index 52b41726276..4361f6f9b51 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_data.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.c @@ -247,6 +247,10 @@ GPENCIL_MaterialPool *gpencil_material_pool_create(GPENCIL_PrivateData *pd, Obje gp_style = gpencil_viewport_material_overrides(pd, ob, color_type, gp_style); + /* Dots or Squares rotation. */ + mat_data->alignment_rot_cos = cosf(gp_style->alignment_rotation); + mat_data->alignment_rot_sin = sinf(gp_style->alignment_rotation); + /* Stroke Style */ if ((gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_TEXTURE) && (gp_style->sima)) { bool premul; diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index 0922ab6552c..04128dc157e 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -62,7 +62,7 @@ typedef struct gpMaterial { float stroke_color[4]; float fill_color[4]; float fill_mix_color[4]; - float fill_uv_transform[3][2], _pad0[2]; + float fill_uv_transform[3][2], alignment_rot_cos, alignment_rot_sin; float stroke_texture_mix; float stroke_u_scale; float fill_texture_mix; 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 5e930af7bd7..94b066c12e5 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl @@ -461,6 +461,14 @@ void stroke_vertex() float rot_cos = abs(uv_rot); x_axis = mat2(rot_cos, -rot_sin, rot_sin, rot_cos) * x_axis; +# ifdef GP_MATERIAL_BUFFER_LEN + if (is_dot) { + float alignment_cos = MATERIAL(m).fill_uv_offset.z; + float alignment_sin = MATERIAL(m).fill_uv_offset.w; + x_axis = mat2(alignment_cos, -alignment_sin, alignment_sin, alignment_cos) * x_axis; + } +# endif + vec2 y_axis = rotate_90deg(x_axis); strokeAspect = decode_aspect(aspect1); diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 355d3d6439b..1d31b876068 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -99,7 +99,8 @@ typedef struct MaterialGPencilStyle { float mix_stroke_factor; /** Mode used to align Dots and Boxes with stroke drawing path and object rotation */ int alignment_mode; - char _pad[4]; + /** Rotation for texture for Dots and Squares. */ + float alignment_rotation; } MaterialGPencilStyle; /* MaterialGPencilStyle->flag */ diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 5e16f1187fb..086a182e085 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -24,6 +24,8 @@ #include "DNA_material_types.h" #include "DNA_texture_types.h" +#include "BLI_math.h" + #include "RNA_define.h" #include "RNA_enum_types.h" @@ -594,6 +596,16 @@ static void rna_def_material_greasepencil(BlenderRNA *brna) prop, "Alignment", "Defines how align Dots and Boxes with drawing path and object rotation"); RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + /* Rotation of texture for Dots or Strokes. */ + prop = RNA_def_property(srna, "alignment_rotation", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "alignment_rotation"); + RNA_def_property_float_default(prop, 0.0f); + RNA_def_property_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f)); + RNA_def_property_ui_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f), 10, 3); + RNA_def_property_ui_text( + prop, "Rotation", "Additional rotation applied to dots and square strokes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + /* pass index for future compositing and editing tools */ prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "index"); |