[Bf-blender-cvs] [1e2fedd15ea] greasepencil-object: GPencil: New Glow rotation parameter
Antonio Vazquez
noreply at git.blender.org
Sat Feb 15 19:02:10 CET 2020
Commit: 1e2fedd15ea86fcb6fb4ab4460cc6b24c1605532
Author: Antonio Vazquez
Date: Sat Feb 15 19:02:03 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB1e2fedd15ea86fcb6fb4ab4460cc6b24c1605532
GPencil: New Glow rotation parameter
Similar to Blur rotate parameter.
===================================================================
M release/scripts/startup/bl_ui/properties_data_shaderfx.py
M source/blender/draw/engines/gpencil/gpencil_shader_fx.c
M source/blender/makesdna/DNA_shader_fx_types.h
M source/blender/makesrna/intern/rna_shader_fx.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_shaderfx.py b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
index 0143def6015..061218cddb8 100644
--- a/release/scripts/startup/bl_ui/properties_data_shaderfx.py
+++ b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
@@ -138,6 +138,7 @@ class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
layout.separator()
layout.prop(fx, "radius")
+ layout.prop(fx, "rotation")
layout.prop(fx, "samples")
layout.prop(fx, "use_alpha_mode", text="Use Alpha Mode")
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index 420e24080a3..ebf8aaefdc8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -415,6 +415,8 @@ static void gpencil_vfx_shadow(ShadowShaderFxData *fx, Object *ob, gpIterVfxData
static void gpencil_vfx_glow(GlowShaderFxData *fx, Object *UNUSED(ob), gpIterVfxData *iter)
{
DRWShadingGroup *grp;
+ const float s = sin(fx->rotation);
+ const float c = cos(fx->rotation);
GPUShader *sh = GPENCIL_shader_fx_glow_get();
@@ -431,7 +433,7 @@ static void gpencil_vfx_glow(GlowShaderFxData *fx, Object *UNUSED(ob), gpIterVfx
DRWState state = DRW_STATE_WRITE_COLOR;
grp = gpencil_vfx_pass_create("Fx Glow H", state, iter, sh);
- DRW_shgroup_uniform_vec2_copy(grp, "offset", (float[2]){fx->blur[0], 0.0f});
+ DRW_shgroup_uniform_vec2_copy(grp, "offset", (float[2]){fx->blur[0] * c, fx->blur[0] * s});
DRW_shgroup_uniform_int_copy(grp, "sampCount", max_ii(1, min_ii(fx->samples, fx->blur[0])));
DRW_shgroup_uniform_vec3_copy(grp, "threshold", ref_col);
DRW_shgroup_uniform_vec3_copy(grp, "glowColor", fx->glow_color);
@@ -442,7 +444,8 @@ static void gpencil_vfx_glow(GlowShaderFxData *fx, Object *UNUSED(ob), gpIterVfx
state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ADD_FULL;
grp = gpencil_vfx_pass_create("Fx Glow V", state, iter, sh);
- DRW_shgroup_uniform_vec2_copy(grp, "offset", (float[2]){0.0f, fx->blur[0]});
+ DRW_shgroup_uniform_vec2_copy(
+ grp, "offset", (float[2]){0.0f - fx->blur[1] * s, fx->blur[1] * c});
DRW_shgroup_uniform_vec3_copy(grp, "threshold", ref_col);
DRW_shgroup_uniform_vec3_copy(grp, "glowColor", (float[3]){1.0f, 1.0f, 1.0f});
DRW_shgroup_uniform_bool_copy(grp, "useAlphaMode", (fx->flag & FX_GLOW_USE_ALPHA) != 0);
diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h
index 07c25d8e370..b13c3361cd5 100644
--- a/source/blender/makesdna/DNA_shader_fx_types.h
+++ b/source/blender/makesdna/DNA_shader_fx_types.h
@@ -142,6 +142,10 @@ typedef struct GlowShaderFxData {
int mode;
int blur[2];
int samples;
+ /** Rotation of effect. */
+ float rotation;
+ char _pad[4];
+
ShaderFxData_Runtime runtime;
} GlowShaderFxData;
diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c
index d2deabec2d0..92447bc4fed 100644
--- a/source/blender/makesrna/intern/rna_shader_fx.c
+++ b/source/blender/makesrna/intern/rna_shader_fx.c
@@ -548,6 +548,12 @@ static void rna_def_shader_fx_glow(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_GLOW_USE_ALPHA);
RNA_def_property_ui_text(prop, "Use Alpha", "Glow only areas with alpha");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update");
+
+ prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "rotation");
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Rotation", "Rotation of the effect");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update");
}
static void rna_def_shader_fx_swirl(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list