diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-01 15:59:43 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-01 16:37:37 +0300 |
commit | 0c44b03b091785a74fddcd5e82a80f22f44ef559 (patch) | |
tree | daf2354028339e0ec12bf911efa99eda77ac377f /source/blender/draw/engines | |
parent | df0616bcd0c3d2a020a36c573b4df49c9947c949 (diff) |
Overlay: Port 2D image overlay shaders to use shaderCreateInfo
This should have no functional changes.
Diffstat (limited to 'source/blender/draw/engines')
5 files changed, 29 insertions, 26 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.c index 8f55eb81bf3..e23c34e1051 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.c +++ b/source/blender/draw/engines/overlay/overlay_shader.c @@ -727,8 +727,8 @@ GPUShader *OVERLAY_shader_edit_uv_stencil_image(void) { OVERLAY_Shaders *sh_data = &e_data.sh_data[0]; if (!sh_data->edit_uv_stencil_image) { - sh_data->edit_uv_stencil_image = DRW_shader_create_with_shaderlib( - datatoc_edit_uv_image_vert_glsl, NULL, datatoc_image_frag_glsl, e_data.lib, NULL); + sh_data->edit_uv_stencil_image = GPU_shader_create_from_info_name( + "overlay_edit_uv_stencil_image"); } return sh_data->edit_uv_stencil_image; } @@ -737,12 +737,7 @@ GPUShader *OVERLAY_shader_edit_uv_mask_image(void) { OVERLAY_Shaders *sh_data = &e_data.sh_data[0]; if (!sh_data->edit_uv_mask_image) { - sh_data->edit_uv_mask_image = DRW_shader_create_with_shaderlib( - datatoc_edit_uv_image_vert_glsl, - NULL, - datatoc_edit_uv_image_mask_frag_glsl, - e_data.lib, - NULL); + sh_data->edit_uv_mask_image = GPU_shader_create_from_info_name("overlay_edit_uv_mask_image"); } return sh_data->edit_uv_mask_image; } diff --git a/source/blender/draw/engines/overlay/shaders/edit_uv_image_mask_frag.glsl b/source/blender/draw/engines/overlay/shaders/edit_uv_image_mask_frag.glsl index 0b579d6067c..a1392abbb92 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_uv_image_mask_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_uv_image_mask_frag.glsl @@ -1,11 +1,5 @@ #pragma BLENDER_REQUIRE(common_colormanagement_lib.glsl) -uniform sampler2D imgTexture; -uniform vec4 color; - -in vec2 uvs; -out vec4 fragColor; - void main() { vec2 uvs_clamped = clamp(uvs, 0.0, 1.0); diff --git a/source/blender/draw/engines/overlay/shaders/edit_uv_image_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_uv_image_vert.glsl index d22cc795e66..7ecbb513265 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_uv_image_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_uv_image_vert.glsl @@ -1,8 +1,5 @@ #pragma BLENDER_REQUIRE(common_view_lib.glsl) -in vec3 pos; -out vec2 uvs; - void main() { /* `pos` contains the coordinates of a quad (-1..1). but we need the coordinates of an image diff --git a/source/blender/draw/engines/overlay/shaders/image_frag.glsl b/source/blender/draw/engines/overlay/shaders/image_frag.glsl index 6e68d156f25..e0339507e0f 100644 --- a/source/blender/draw/engines/overlay/shaders/image_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/image_frag.glsl @@ -1,14 +1,5 @@ #pragma BLENDER_REQUIRE(common_colormanagement_lib.glsl) -uniform sampler2D imgTexture; -uniform bool imgPremultiplied; -uniform bool imgAlphaBlend; -uniform vec4 color; - -in vec2 uvs; - -out vec4 fragColor; - void main() { vec2 uvs_clamped = clamp(uvs, 0.0, 1.0); diff --git a/source/blender/draw/engines/overlay/shaders/infos/edit_mode_info.hh b/source/blender/draw/engines/overlay/shaders/infos/edit_mode_info.hh index 0ef8331da95..a30c1df4f6a 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/edit_mode_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/edit_mode_info.hh @@ -260,6 +260,32 @@ GPU_SHADER_CREATE_INFO(overlay_edit_uv_tiled_image_borders) .fragment_source("gpu_shader_uniform_color_frag.glsl") .additional_info("draw_mesh"); +GPU_SHADER_INTERFACE_INFO(edit_uv_image_iface, "").smooth(Type::VEC2, "uvs"); + +GPU_SHADER_CREATE_INFO(overlay_edit_uv_stencil_image) + .do_static_compilation(true) + .vertex_in(0, Type::VEC3, "pos") + .vertex_out(edit_uv_image_iface) + .vertex_source("edit_uv_image_vert.glsl") + .sampler(0, ImageType::FLOAT_2D, "imgTexture") + .push_constant(Type::BOOL, "imgPremultiplied") + .push_constant(Type::BOOL, "imgAlphaBlend") + .push_constant(Type::VEC4, "color") + .fragment_out(0, Type::VEC4, "fragColor") + .fragment_source("image_frag.glsl") + .additional_info("draw_mesh"); + +GPU_SHADER_CREATE_INFO(overlay_edit_uv_mask_image) + .do_static_compilation(true) + .vertex_in(0, Type::VEC3, "pos") + .vertex_out(edit_uv_image_iface) + .sampler(0, ImageType::FLOAT_2D, "imgTexture") + .push_constant(Type::VEC4, "color") + .fragment_out(0, Type::VEC4, "fragColor") + .vertex_source("edit_uv_image_vert.glsl") + .fragment_source("edit_uv_image_mask_frag.glsl") + .additional_info("draw_mesh"); + /** \} */ /* -------------------------------------------------------------------- */ |