diff options
5 files changed, 31 insertions, 29 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.c index 320fc2417c6..fc2427be9d2 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.c +++ b/source/blender/draw/engines/overlay/overlay_shader.c @@ -934,17 +934,10 @@ GPUShader *OVERLAY_shader_particle_shape(void) GPUShader *OVERLAY_shader_sculpt_mask(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->sculpt_mask) { - sh_data->sculpt_mask = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_view_lib_glsl, - datatoc_sculpt_mask_vert_glsl, - NULL}, - .frag = (const char *[]){datatoc_sculpt_mask_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->sculpt_mask = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_sculpt_mask_clipped" : "overlay_sculpt_mask"); } return sh_data->sculpt_mask; } diff --git a/source/blender/draw/engines/overlay/shaders/infos/sculpt_info.hh b/source/blender/draw/engines/overlay/shaders/infos/sculpt_info.hh new file mode 100644 index 00000000000..d4f1ca44362 --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/infos/sculpt_info.hh @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_INTERFACE_INFO(overlay_sculpt_mask_iface, "") + .flat(Type::VEC3, "faceset_color") + .smooth(Type::FLOAT, "mask_color") + .smooth(Type::VEC4, "finalColor"); + +GPU_SHADER_CREATE_INFO(overlay_sculpt_mask) + .do_static_compilation(true) + .push_constant(Type::FLOAT, "maskOpacity") + .push_constant(Type::FLOAT, "faceSetsOpacity") + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC3, "fset") + .vertex_in(2, Type::FLOAT, "msk") + .vertex_out(overlay_sculpt_mask_iface) + .vertex_source("sculpt_mask_vert.glsl") + .fragment_source("sculpt_mask_frag.glsl") + .fragment_out(0, Type::VEC4, "fragColor") + .additional_info("draw_mesh", "draw_object_infos", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_sculpt_mask_clipped) + .do_static_compilation(true) + .additional_info("overlay_sculpt_mask", "drw_clipped"); diff --git a/source/blender/draw/engines/overlay/shaders/sculpt_mask_frag.glsl b/source/blender/draw/engines/overlay/shaders/sculpt_mask_frag.glsl index a778e518392..9650af755c5 100644 --- a/source/blender/draw/engines/overlay/shaders/sculpt_mask_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/sculpt_mask_frag.glsl @@ -1,9 +1,4 @@ -flat in vec3 faceset_color; -in float mask_color; - -out vec4 fragColor; - void main() { fragColor = vec4(faceset_color * vec3(mask_color), 1.0); diff --git a/source/blender/draw/engines/overlay/shaders/sculpt_mask_vert.glsl b/source/blender/draw/engines/overlay/shaders/sculpt_mask_vert.glsl index f2b827738ac..36c0e6a0acf 100644 --- a/source/blender/draw/engines/overlay/shaders/sculpt_mask_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/sculpt_mask_vert.glsl @@ -1,15 +1,5 @@ - -uniform float maskOpacity; -uniform float faceSetsOpacity; - -in vec3 pos; -in vec3 fset; -in float msk; - -out vec4 finalColor; - -flat out vec3 faceset_color; -out float mask_color; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) void main() { @@ -19,7 +9,5 @@ void main() faceset_color = mix(vec3(1.0), fset, faceSetsOpacity); mask_color = 1.0 - (msk * maskOpacity); -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(world_pos); -#endif + view_clipping_distances(world_pos); } diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 2f4a6edd4dd..bfccf2fd602 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -452,6 +452,7 @@ set(SRC_SHADER_CREATE_INFOS ../draw/engines/overlay/shaders/infos/grid_info.hh ../draw/engines/overlay/shaders/infos/outline_info.hh ../draw/engines/overlay/shaders/infos/paint_info.hh + ../draw/engines/overlay/shaders/infos/sculpt_info.hh ../draw/engines/overlay/shaders/infos/volume_info.hh ../draw/engines/overlay/shaders/infos/wireframe_info.hh ../draw/engines/select/shaders/infos/select_id_info.hh |