Overlay: Port depth only & uniform_color shaders to use shaderCreateInfo

This should have no functional changes.
This commit is contained in:
Clément Foucault 2022-04-30 23:56:31 +02:00
parent 86b37748a7
commit 12217714c7
Notes: blender-bot 2023-02-14 06:27:47 +01:00
Referenced by issue #97751, New OBJ import: fileselector doesn't filter *.obj but shows all model-like files
Referenced by issue #92787, Cursor jumping to edge of screen when lifting pen from tablet area (wintab)
3 changed files with 47 additions and 22 deletions

View File

@ -255,17 +255,10 @@ GPUShader *OVERLAY_shader_clipbound(void)
GPUShader *OVERLAY_shader_depth_only(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg];
OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
if (!sh_data->depth_only) {
sh_data->depth_only = GPU_shader_create_from_arrays({
.vert = (const char *[]){sh_cfg->lib,
datatoc_common_view_lib_glsl,
datatoc_depth_only_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_gpu_shader_depth_only_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, NULL},
});
sh_data->depth_only = GPU_shader_create_from_info_name(
draw_ctx->sh_cfg ? "overlay_depth_only_clipped" : "overlay_depth_only");
}
return sh_data->depth_only;
}
@ -1002,17 +995,10 @@ GPUShader *OVERLAY_shader_sculpt_mask(void)
struct GPUShader *OVERLAY_shader_uniform_color(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg];
OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
if (!sh_data->uniform_color) {
sh_data->uniform_color = GPU_shader_create_from_arrays({
.vert = (const char *[]){sh_cfg->lib,
datatoc_common_view_lib_glsl,
datatoc_depth_only_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, NULL},
});
sh_data->uniform_color = GPU_shader_create_from_info_name(
draw_ctx->sh_cfg ? "overlay_uniform_color_clipped" : "overlay_uniform_color");
}
return sh_data->uniform_color;
}

View File

@ -1,5 +1,6 @@
in vec3 pos;
#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
void main()
{
@ -8,7 +9,5 @@ void main()
vec3 world_pos = point_object_to_world(pos);
gl_Position = point_world_to_ndc(world_pos);
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance(world_pos);
#endif
view_clipping_distances(world_pos);
}

View File

@ -466,3 +466,43 @@ GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_guide_point_clipped)
.additional_info("overlay_edit_gpencil_guide_point", "drw_clipped");
/** \} */
/* -------------------------------------------------------------------- */
/** \name Depth Only Shader
*
* Used to occlude edit geometry which might not be rendered by the render engine.
* \{ */
GPU_SHADER_CREATE_INFO(overlay_depth_only)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.vertex_source("depth_only_vert.glsl")
.fragment_source("gpu_shader_depth_only_frag.glsl")
.additional_info("draw_mesh");
GPU_SHADER_CREATE_INFO(overlay_depth_only_clipped)
.do_static_compilation(true)
.additional_info("overlay_depth_only", "drw_clipped");
/** \} */
/* -------------------------------------------------------------------- */
/** \name Uniform color
* \{ */
GPU_SHADER_CREATE_INFO(overlay_uniform_color)
.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("depth_only_vert.glsl")
.fragment_source("gpu_shader_uniform_color_frag.glsl")
.additional_info("draw_mesh");
GPU_SHADER_CREATE_INFO(overlay_uniform_color_clipped)
.do_static_compilation(true)
.additional_info("overlay_depth_only", "drw_clipped");
/** \} */