diff options
Diffstat (limited to 'source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl | 92 |
1 files changed, 46 insertions, 46 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 ca8c888fe21..c8af822bc9e 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl @@ -11,62 +11,62 @@ out vec4 fragColor; #define texture2D texture -#define GPENCIL_MODE_LINE 0 -#define GPENCIL_MODE_DOTS 1 -#define GPENCIL_MODE_BOX 2 +#define GPENCIL_MODE_LINE 0 +#define GPENCIL_MODE_DOTS 1 +#define GPENCIL_MODE_BOX 2 /* keep this list synchronized with list in gpencil_engine.h */ -#define GPENCIL_COLOR_SOLID 0 +#define GPENCIL_COLOR_SOLID 0 #define GPENCIL_COLOR_TEXTURE 1 #define GPENCIL_COLOR_PATTERN 2 /* Function to check the point inside ellipse */ -float checkpoint(vec2 pt, vec2 radius) -{ - float p = (pow(pt.x, 2) / pow(radius.x, 2)) + (pow(pt.y, 2) / pow(radius.y, 2)); - - return p; -} +float checkpoint(vec2 pt, vec2 radius) +{ + float p = (pow(pt.x, 2) / pow(radius.x, 2)) + (pow(pt.y, 2) / pow(radius.y, 2)); + + return p; +} void main() { - vec2 centered = mTexCoord - vec2(0.5); - float ellip = checkpoint(centered, vec2(gradient_s / 2.0)); + vec2 centered = mTexCoord - vec2(0.5); + float ellip = checkpoint(centered, vec2(gradient_s / 2.0)); + + if (mode != GPENCIL_MODE_BOX) { + if (ellip > 1.0) { + discard; + } + } + + vec4 tmp_color = texture2D(myTexture, mTexCoord); - if (mode != GPENCIL_MODE_BOX) { - if (ellip > 1.0) { - discard; - } - } + /* Solid */ + if (color_type == GPENCIL_COLOR_SOLID) { + fragColor = mColor; + } + /* texture */ + if (color_type == GPENCIL_COLOR_TEXTURE) { + fragColor = texture2D(myTexture, mTexCoord); + /* mult both alpha factor to use strength factor with texture */ + fragColor.a = min(fragColor.a * mColor.a, fragColor.a); + } + /* pattern */ + if (color_type == GPENCIL_COLOR_PATTERN) { + vec4 text_color = texture2D(myTexture, mTexCoord); + fragColor = mColor; + /* mult both alpha factor to use strength factor with color alpha limit */ + fragColor.a = min(text_color.a * mColor.a, mColor.a); + } - vec4 tmp_color = texture2D(myTexture, mTexCoord); + if ((mode == GPENCIL_MODE_DOTS) && (gradient_f < 1.0)) { + float dist = length(centered) * 2; + 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); + } - /* Solid */ - if (color_type == GPENCIL_COLOR_SOLID) { - fragColor = mColor; - } - /* texture */ - if (color_type == GPENCIL_COLOR_TEXTURE) { - fragColor = texture2D(myTexture, mTexCoord); - /* mult both alpha factor to use strength factor with texture */ - fragColor.a = min(fragColor.a * mColor.a, fragColor.a); - } - /* pattern */ - if (color_type == GPENCIL_COLOR_PATTERN) { - vec4 text_color = texture2D(myTexture, mTexCoord); - fragColor = mColor; - /* mult both alpha factor to use strength factor with color alpha limit */ - fragColor.a = min(text_color.a * mColor.a, mColor.a); - } - - if ((mode == GPENCIL_MODE_DOTS) && (gradient_f < 1.0)) { - float dist = length(centered) * 2; - 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(fragColor.a < 0.0035) { - discard; - } + if (fragColor.a < 0.0035) { + discard; + } } |