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
This commit is contained in:
parent
aacdc39958
commit
e6f61a4a37
|
@ -676,6 +676,7 @@ class AddPresetGpencilMaterial(AddPresetBase, Operator):
|
|||
"gpcolor.pixel_size",
|
||||
"gpcolor.mix_stroke_factor",
|
||||
"gpcolor.alignment_mode",
|
||||
"gpcolor.alignment_rotation",
|
||||
"gpcolor.fill_style",
|
||||
"gpcolor.fill_color",
|
||||
"gpcolor.fill_image",
|
||||
|
|
|
@ -165,6 +165,7 @@ class MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
|
|||
|
||||
if gpcolor.mode in {'DOTS', 'BOX'}:
|
||||
col.prop(gpcolor, "alignment_mode")
|
||||
col.prop(gpcolor, "alignment_rotation")
|
||||
|
||||
if gpcolor.mode == 'LINE':
|
||||
col.prop(gpcolor, "use_overlap_strokes")
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue