diff options
Diffstat (limited to 'source')
6 files changed, 40 insertions, 50 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader.c b/source/blender/draw/engines/gpencil/gpencil_shader.c index c37225d84de..fca2e700346 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader.c @@ -136,19 +136,7 @@ GPUShader *GPENCIL_shader_geometry_get(void) GPUShader *GPENCIL_shader_layer_blend_get(void) { if (!g_shaders.layer_blend_sh) { - g_shaders.layer_blend_sh = GPU_shader_create_from_arrays({ - .vert = - (const char *[]){ - datatoc_common_fullscreen_vert_glsl, - NULL, - }, - .frag = - (const char *[]){ - datatoc_gpencil_common_lib_glsl, - datatoc_gpencil_layer_blend_frag_glsl, - NULL, - }, - }); + g_shaders.layer_blend_sh = GPU_shader_create_from_info_name("gpencil_layer_blend"); } return g_shaders.layer_blend_sh; } @@ -156,8 +144,7 @@ GPUShader *GPENCIL_shader_layer_blend_get(void) GPUShader *GPENCIL_shader_mask_invert_get(void) { if (!g_shaders.mask_invert_sh) { - g_shaders.mask_invert_sh = DRW_shader_create_fullscreen(datatoc_gpencil_mask_invert_frag_glsl, - NULL); + g_shaders.mask_invert_sh = GPU_shader_create_from_info_name("gpencil_mask_invert"); } return g_shaders.mask_invert_sh; } @@ -165,19 +152,7 @@ GPUShader *GPENCIL_shader_mask_invert_get(void) GPUShader *GPENCIL_shader_depth_merge_get(void) { if (!g_shaders.depth_merge_sh) { - g_shaders.depth_merge_sh = GPU_shader_create_from_arrays({ - .vert = - (const char *[]){ - datatoc_common_view_lib_glsl, - datatoc_gpencil_depth_merge_vert_glsl, - NULL, - }, - .frag = - (const char *[]){ - datatoc_gpencil_depth_merge_frag_glsl, - NULL, - }, - }); + g_shaders.depth_merge_sh = GPU_shader_create_from_info_name("gpencil_depth_merge"); } return g_shaders.depth_merge_sh; } diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl index 2f711f6a2c5..9723ea307c3 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl @@ -1,7 +1,4 @@ -uniform sampler2D depthBuf; -uniform bool strokeOrder3d; - void main() { float depth = textureLod(depthBuf, gl_FragCoord.xy / vec2(textureSize(depthBuf, 0)), 0).r; diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl index 0c5260a9ec4..e162c5bf45e 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl @@ -1,6 +1,4 @@ -uniform vec4 gpModelMatrix[4]; - void main() { mat4 model_matrix = mat4(gpModelMatrix[0], gpModelMatrix[1], gpModelMatrix[2], gpModelMatrix[3]); diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl index 6fbc7f47dac..805aec940d8 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl @@ -1,16 +1,5 @@ -uniform sampler2D colorBuf; -uniform sampler2D revealBuf; -uniform sampler2D maskBuf; -uniform int blendMode; -uniform float blendOpacity; - -in vec4 uvcoordsvar; - -/* Reminder: This is considered SRC color in blend equations. - * Same operation on all buffers. */ -layout(location = 0) out vec4 fragColor; -layout(location = 1) out vec4 fragRevealage; +#pragma BLENDER_REQUIRE(gpencil_common_lib.glsl) void main() { diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_mask_invert_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_mask_invert_frag.glsl index b21b4147087..7b95ea1d8b2 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_mask_invert_frag.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_mask_invert_frag.glsl @@ -1,9 +1,4 @@ -in vec4 uvcoordsvar; - -layout(location = 0) out vec4 fragColor; -layout(location = 1) out vec4 fragRevealage; - void main() { /* Blend mode does the inversion. */ diff --git a/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh b/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh index 748d4fd9a23..76fa8ae609b 100644 --- a/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh +++ b/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh @@ -3,6 +3,42 @@ #include "gpu_shader_create_info.hh" /* -------------------------------------------------------------------- */ +/** \name Fullscreen shaders + * \{ */ + +GPU_SHADER_CREATE_INFO(gpencil_layer_blend) + .do_static_compilation(true) + .sampler(0, ImageType::FLOAT_2D, "colorBuf") + .sampler(1, ImageType::FLOAT_2D, "revealBuf") + .sampler(2, ImageType::FLOAT_2D, "maskBuf") + .push_constant(Type::INT, "blendMode") + .push_constant(Type::FLOAT, "blendOpacity") + /* Reminder: This is considered SRC color in blend equations. + * Same operation on all buffers. */ + .fragment_out(0, Type::VEC4, "fragColor") + .fragment_out(1, Type::VEC4, "fragRevealage") + .fragment_source("gpencil_layer_blend_frag.glsl") + .additional_info("draw_fullscreen"); + +GPU_SHADER_CREATE_INFO(gpencil_mask_invert) + .do_static_compilation(true) + .fragment_out(0, Type::VEC4, "fragColor") + .fragment_out(1, Type::VEC4, "fragRevealage") + .fragment_source("gpencil_mask_invert_frag.glsl") + .additional_info("draw_fullscreen"); + +GPU_SHADER_CREATE_INFO(gpencil_depth_merge) + .do_static_compilation(true) + .push_constant(Type::VEC4, "gpModelMatrix", 4) + .push_constant(Type::BOOL, "strokeOrder3d") + .sampler(0, ImageType::DEPTH_2D, "depthBuf") + .vertex_source("gpencil_depth_merge_vert.glsl") + .fragment_source("gpencil_depth_merge_frag.glsl") + .additional_info("draw_view"); + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Anti-Aliasing * \{ */ |