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
path: root/source
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2019-04-23 18:25:37 +0300
committerAntonioya <blendergit@gmail.com>2019-04-23 18:26:01 +0300
commit40baa2e2b358a8a376fd54f0ae0d52a4ef75dc4c (patch)
treef527e533e83edc398fff08dc0cb04451e7cbaaa2 /source
parent8e861725dc9e9388c1c764491676c0684b1b6f8f (diff)
GPencil: Add support for gradient to Box strokes
Before this options was only available to Dots mode.
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl29
-rw-r--r--source/blender/makesrna/intern/rna_brush.c2
2 files changed, 25 insertions, 6 deletions
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
index 204d1962a51..b7206ac2e80 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
@@ -24,23 +24,40 @@ out vec4 fragColor;
#define GPENCIL_COLOR_PATTERN 2
/* Function to check the point inside ellipse */
-float checkpoint(vec2 pt, vec2 radius)
+float check_ellipse_point(vec2 pt, vec2 radius)
{
float p = (pow(pt.x, 2) / pow(radius.x, 2)) + (pow(pt.y, 2) / pow(radius.y, 2));
return p;
}
+/* Function to check the point inside box */
+vec2 check_box_point(vec2 pt, vec2 radius)
+{
+ vec2 rtn;
+ rtn.x = abs(pt.x) / radius.x;
+ rtn.y = abs(pt.y) / radius.y;
+
+ return rtn;
+}
+
void main()
{
vec2 centered = mTexCoord - vec2(0.5);
- float ellip = checkpoint(centered, vec2(gradient_s / 2.0));
+ float ellip = check_ellipse_point(centered, vec2(gradient_s / 2.0));
+ vec2 box;
if (mode != GPENCIL_MODE_BOX) {
if (ellip > 1.0) {
discard;
}
}
+ else {
+ box = check_box_point(centered, vec2(gradient_s / 2.0));
+ if ((box.x > 1.0) || (box.y > 1.0)) {
+ discard;
+ }
+ }
vec4 tmp_color = texture2D(myTexture, mTexCoord);
@@ -70,11 +87,13 @@ void main()
fragColor.a = min(text_color.a * mColor.a, mColor.a);
}
- if ((mode == GPENCIL_MODE_DOTS) && (gradient_f < 1.0)) {
- float dist = length(centered) * 2;
+ if (gradient_f < 1.0) {
+ float dist = length(centered) * 2.0;
float decay = dist * (1.0 - gradient_f) * fragColor.a;
fragColor.a = clamp(fragColor.a - decay, 0.0, 1.0);
- fragColor.a = fragColor.a * (1.0 - ellip);
+ if (mode == GPENCIL_MODE_DOTS) {
+ fragColor.a = fragColor.a * (1.0 - ellip);
+ }
}
if (fragColor.a < 0.0035) {
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 6dc5a9cfd6a..d5c9dfb8d02 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1246,7 +1246,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop,
"Border Opacity Factor",
- "Amount of gradient for Dot strokes (set to 1 for full solid)");
+ "Amount of gradient for Dot and Box strokes (set to 1 for full solid)");
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
/* gradient shape ratio */