diff options
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl | 270 |
1 files changed, 142 insertions, 128 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl b/source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl index 328fbbe26a1..946fc752e17 100644 --- a/source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl @@ -29,138 +29,152 @@ in vec2 texCoord_interp; out vec4 fragColor; #define texture2D texture -void set_color(in vec4 color, in vec4 color2, in vec4 tcolor, in float mixv, in float factor, - in int tmix, in int flip, out vec4 ocolor) +void set_color(in vec4 color, + in vec4 color2, + in vec4 tcolor, + in float mixv, + in float factor, + in int tmix, + in int flip, + out vec4 ocolor) { - /* full color A */ - if (mixv == 1.0) { - if (tmix == 1) { - if (flip == 0) { - ocolor = color; - } - else { - ocolor = tcolor; - } - } - else { - if (flip == 0) { - ocolor = color; - } - else { - ocolor = color2; - } - } - } - /* full color B */ - else if (mixv == 0.0) { - if (tmix == 1) { - if (flip == 0) { - ocolor = tcolor; - } - else { - ocolor = color; - } - } - else { - if (flip == 0) { - ocolor = color2; - } - else { - ocolor = color; - } - } - } - /* mix of colors */ - else { - if (tmix == 1) { - if (flip == 0) { - ocolor = mix(color, tcolor, factor); - } - else { - ocolor = mix(tcolor, color, factor); - } - } - else { - if (flip == 0) { - ocolor = mix(color, color2, factor); - } - else { - ocolor = mix(color2, color, factor); - } - } - } + /* full color A */ + if (mixv == 1.0) { + if (tmix == 1) { + if (flip == 0) { + ocolor = color; + } + else { + ocolor = tcolor; + } + } + else { + if (flip == 0) { + ocolor = color; + } + else { + ocolor = color2; + } + } + } + /* full color B */ + else if (mixv == 0.0) { + if (tmix == 1) { + if (flip == 0) { + ocolor = tcolor; + } + else { + ocolor = color; + } + } + else { + if (flip == 0) { + ocolor = color2; + } + else { + ocolor = color; + } + } + } + /* mix of colors */ + else { + if (tmix == 1) { + if (flip == 0) { + ocolor = mix(color, tcolor, factor); + } + else { + ocolor = mix(tcolor, color, factor); + } + } + else { + if (flip == 0) { + ocolor = mix(color, color2, factor); + } + else { + ocolor = mix(color2, color, factor); + } + } + } } void main() { - vec2 t_center = vec2(0.5, 0.5); - mat2 matrot_tex = mat2(cos(t_angle), -sin(t_angle), sin(t_angle), cos(t_angle)); - vec2 rot_tex = (matrot_tex * (texCoord_interp - t_center)) + t_center + t_offset; - vec4 tmp_color = texture2D(myTexture, rot_tex * t_scale); - vec4 text_color = vec4(tmp_color[0], tmp_color[1], tmp_color[2], tmp_color[3] * t_opacity); - vec4 chesscolor; + vec2 t_center = vec2(0.5, 0.5); + mat2 matrot_tex = mat2(cos(t_angle), -sin(t_angle), sin(t_angle), cos(t_angle)); + vec2 rot_tex = (matrot_tex * (texCoord_interp - t_center)) + t_center + t_offset; + vec4 tmp_color = texture2D(myTexture, rot_tex * t_scale); + vec4 text_color = vec4(tmp_color[0], tmp_color[1], tmp_color[2], tmp_color[3] * t_opacity); + vec4 chesscolor; - /* solid fill */ - if (fill_type == SOLID) { - if (t_mix == 1) { - fragColor = mix(color, text_color, mix_factor); - } - else { - fragColor = color; - } - } - else { - vec2 center = vec2(0.5, 0.5) + g_shift; - mat2 matrot = mat2(cos(g_angle), -sin(g_angle), sin(g_angle), cos(g_angle)); - vec2 rot = (((matrot * (texCoord_interp - center)) + center) * g_scale) + g_shift; - /* gradient */ - if (fill_type == GRADIENT) { - set_color(color, color2, text_color, mix_factor, rot.x - mix_factor + 0.5, t_mix, t_flip, fragColor); - } - /* radial gradient */ - if (fill_type == RADIAL) { - float in_rad = g_radius * mix_factor; - float ex_rad = g_radius - in_rad; - float intensity = 0; - float distance = length((center - texCoord_interp) * g_scale); - if (distance > g_radius) { - discard; - } - if (distance > in_rad) { - intensity = clamp(((distance - in_rad) / ex_rad), 0.0, 1.0); - } - set_color(color, color2, text_color, mix_factor, intensity, t_mix, t_flip, fragColor); - } - /* chessboard */ - if (fill_type == CHESS) { - vec2 pos = rot / g_boxsize; - if ((fract(pos.x) < 0.5 && fract(pos.y) < 0.5) || (fract(pos.x) > 0.5 && fract(pos.y) > 0.5)) { - if (t_flip == 0) { - chesscolor = color; - } - else { - chesscolor = color2; - } - } - else { - if (t_flip == 0) { - chesscolor = color2; - } - else { - chesscolor = color; - } - } - /* mix with texture */ - if (t_mix == 1) { - fragColor = mix(chesscolor, text_color, mix_factor); - } - else { - fragColor = chesscolor; - } - } - /* texture */ - if (fill_type == TEXTURE) { - fragColor = text_color; - } - } + /* solid fill */ + if (fill_type == SOLID) { + if (t_mix == 1) { + fragColor = mix(color, text_color, mix_factor); + } + else { + fragColor = color; + } + } + else { + vec2 center = vec2(0.5, 0.5) + g_shift; + mat2 matrot = mat2(cos(g_angle), -sin(g_angle), sin(g_angle), cos(g_angle)); + vec2 rot = (((matrot * (texCoord_interp - center)) + center) * g_scale) + g_shift; + /* gradient */ + if (fill_type == GRADIENT) { + set_color(color, + color2, + text_color, + mix_factor, + rot.x - mix_factor + 0.5, + t_mix, + t_flip, + fragColor); + } + /* radial gradient */ + if (fill_type == RADIAL) { + float in_rad = g_radius * mix_factor; + float ex_rad = g_radius - in_rad; + float intensity = 0; + float distance = length((center - texCoord_interp) * g_scale); + if (distance > g_radius) { + discard; + } + if (distance > in_rad) { + intensity = clamp(((distance - in_rad) / ex_rad), 0.0, 1.0); + } + set_color(color, color2, text_color, mix_factor, intensity, t_mix, t_flip, fragColor); + } + /* chessboard */ + if (fill_type == CHESS) { + vec2 pos = rot / g_boxsize; + if ((fract(pos.x) < 0.5 && fract(pos.y) < 0.5) || + (fract(pos.x) > 0.5 && fract(pos.y) > 0.5)) { + if (t_flip == 0) { + chesscolor = color; + } + else { + chesscolor = color2; + } + } + else { + if (t_flip == 0) { + chesscolor = color2; + } + else { + chesscolor = color; + } + } + /* mix with texture */ + if (t_mix == 1) { + fragColor = mix(chesscolor, text_color, mix_factor); + } + else { + fragColor = chesscolor; + } + } + /* texture */ + if (fill_type == TEXTURE) { + fragColor = text_color; + } + } } |