diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-04-28 22:27:56 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-04-28 22:43:54 +0300 |
commit | d5f3351f5511010c30e19dcb55d4fc0705fbd285 (patch) | |
tree | 3753c764fc1571ca278718200dc71d0e9af6096c /source/blender/draw/engines/overlay | |
parent | 308a12ac647d6f9b4ef2b6c403903e0aeb65a571 (diff) |
Overlay: Port UDIM Grid shader to shaderCreateInfo
Simple Straight forward port.
Diffstat (limited to 'source/blender/draw/engines/overlay')
4 files changed, 25 insertions, 17 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.c index 651fb0f2494..a9b796a5e85 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.c +++ b/source/blender/draw/engines/overlay/overlay_shader.c @@ -858,12 +858,7 @@ GPUShader *OVERLAY_shader_grid_background(void) { OVERLAY_Shaders *sh_data = &e_data.sh_data[0]; if (!sh_data->grid_background) { - sh_data->grid_background = GPU_shader_create_from_arrays({ - .vert = (const char *[]){datatoc_common_view_lib_glsl, - datatoc_edit_uv_tiled_image_borders_vert_glsl, - NULL}, - .frag = (const char *[]){datatoc_grid_background_frag_glsl, NULL}, - }); + sh_data->grid_background = GPU_shader_create_from_info_name("overlay_grid_background"); } return sh_data->grid_background; } @@ -872,12 +867,7 @@ GPUShader *OVERLAY_shader_grid_image(void) { OVERLAY_Shaders *sh_data = &e_data.sh_data[0]; if (!sh_data->grid_image) { - sh_data->grid_image = DRW_shader_create_with_shaderlib( - datatoc_edit_uv_tiled_image_borders_vert_glsl, - NULL, - datatoc_gpu_shader_uniform_color_frag_glsl, - e_data.lib, - "#define blender_srgb_to_framebuffer_space(a) a\n"); + sh_data->grid_image = GPU_shader_create_from_info_name("overlay_grid_image"); } return sh_data->grid_image; } diff --git a/source/blender/draw/engines/overlay/shaders/edit_uv_tiled_image_borders_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_uv_tiled_image_borders_vert.glsl index c762858a910..bc5235b9cab 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_uv_tiled_image_borders_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_uv_tiled_image_borders_vert.glsl @@ -1,6 +1,8 @@ #pragma BLENDER_REQUIRE(common_view_lib.glsl) +#ifndef USE_GPU_SHADER_CREATE_INFO in vec3 pos; +#endif void main() { diff --git a/source/blender/draw/engines/overlay/shaders/grid_background_frag.glsl b/source/blender/draw/engines/overlay/shaders/grid_background_frag.glsl index f09918da6dc..37958319b44 100644 --- a/source/blender/draw/engines/overlay/shaders/grid_background_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/grid_background_frag.glsl @@ -1,9 +1,4 @@ -uniform vec4 color; -uniform sampler2D depthBuffer; - -out vec4 fragColor; - void main() { fragColor = color; diff --git a/source/blender/draw/engines/overlay/shaders/infos/grid_info.hh b/source/blender/draw/engines/overlay/shaders/infos/grid_info.hh index be36aa67735..d02014c98a0 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/grid_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/grid_info.hh @@ -18,3 +18,24 @@ GPU_SHADER_CREATE_INFO(overlay_grid) .vertex_source("grid_vert.glsl") .fragment_source("grid_frag.glsl") .additional_info("draw_view", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_grid_background) + .do_static_compilation(true) + .vertex_in(0, Type::VEC3, "pos") + .sampler(0, ImageType::DEPTH_2D, "depthBuffer") + .push_constant(Type::VEC4, "color") + .fragment_out(0, Type::VEC4, "fragColor") + .vertex_source("edit_uv_tiled_image_borders_vert.glsl") + .fragment_source("grid_background_frag.glsl") + .additional_info("draw_modelmat"); + +GPU_SHADER_CREATE_INFO(overlay_grid_image) + .do_static_compilation(true) + /* NOTE: Color already in Linear space. Which is what we want. */ + .define("srgbTarget", "false") + .vertex_in(0, Type::VEC3, "pos") + .push_constant(Type::VEC4, "color") + .fragment_out(0, Type::VEC4, "fragColor") + .vertex_source("edit_uv_tiled_image_borders_vert.glsl") + .fragment_source("gpu_shader_uniform_color_frag.glsl") + .additional_info("draw_modelmat"); |