diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-26 16:42:08 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-26 17:37:59 +0300 |
commit | c490428bd4dff75fb371777d4e95ea270c77ea94 (patch) | |
tree | 9cc348fc846dd551ecf716a5335278ceea5ea60d /source/blender/gpu | |
parent | 5876856f7bdaac74ae5b09afb5a2c81cdb4f873e (diff) |
UI: desaturate toolbar icons that the mouse is not over.
This does not look great with light toolbar buttons as in the default,
so consider this a work in progress.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/gpu/GPU_shader.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 3 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_image_desaturate_frag.glsl | 13 |
4 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index cf6bbc7cb94..575dff1e811 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -147,6 +147,7 @@ data_to_c_simple(shaders/gpu_shader_2D_image_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_image_rect_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_image_multi_rect_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_image_frag.glsl SRC) +data_to_c_simple(shaders/gpu_shader_image_desaturate_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_image_linear_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_image_shuffle_color_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_image_mask_uniform_color_frag.glsl SRC) diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 2c795b01a5d..59bf92aa672 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -114,6 +114,7 @@ typedef enum GPUBuiltinShader { GPU_SHADER_2D_SMOOTH_COLOR_DITHER, GPU_SHADER_2D_IMAGE, GPU_SHADER_2D_IMAGE_COLOR, + GPU_SHADER_2D_IMAGE_DESATURATE_COLOR, GPU_SHADER_2D_IMAGE_ALPHA_COLOR, GPU_SHADER_2D_IMAGE_ALPHA, GPU_SHADER_2D_IMAGE_RECT_COLOR, diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 9f492b7af50..609aa529872 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -81,6 +81,7 @@ extern char datatoc_gpu_shader_3D_image_vert_glsl[]; extern char datatoc_gpu_shader_image_frag_glsl[]; extern char datatoc_gpu_shader_image_linear_frag_glsl[]; extern char datatoc_gpu_shader_image_color_frag_glsl[]; +extern char datatoc_gpu_shader_image_desaturate_frag_glsl[]; extern char datatoc_gpu_shader_image_varying_color_frag_glsl[]; extern char datatoc_gpu_shader_image_alpha_color_frag_glsl[]; extern char datatoc_gpu_shader_image_shuffle_color_frag_glsl[]; @@ -709,6 +710,8 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) datatoc_gpu_shader_image_frag_glsl }, [GPU_SHADER_2D_IMAGE_COLOR] = { datatoc_gpu_shader_2D_image_vert_glsl, datatoc_gpu_shader_image_color_frag_glsl }, + [GPU_SHADER_2D_IMAGE_DESATURATE_COLOR] = { datatoc_gpu_shader_2D_image_vert_glsl, + datatoc_gpu_shader_image_desaturate_frag_glsl }, [GPU_SHADER_2D_IMAGE_ALPHA_COLOR] = { datatoc_gpu_shader_2D_image_vert_glsl, datatoc_gpu_shader_image_alpha_color_frag_glsl }, [GPU_SHADER_2D_IMAGE_ALPHA] = { datatoc_gpu_shader_2D_image_vert_glsl, diff --git a/source/blender/gpu/shaders/gpu_shader_image_desaturate_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_desaturate_frag.glsl new file mode 100644 index 00000000000..5b2ccb8ff3a --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_image_desaturate_frag.glsl @@ -0,0 +1,13 @@ + +in vec2 texCoord_interp; +out vec4 fragColor; + +uniform vec4 color; +uniform sampler2D image; + +void main() +{ + vec4 tex = texture(image, texCoord_interp); + tex.rgb = 0.3333333 * vec3(tex.r + tex.g + tex.b); + fragColor = tex * color; +} |