diff options
4 files changed, 51 insertions, 37 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.c index fc2427be9d2..09eceb55668 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.c +++ b/source/blender/draw/engines/overlay/overlay_shader.c @@ -542,18 +542,11 @@ GPUShader *OVERLAY_shader_edit_mesh_skin_root(void) GPUShader *OVERLAY_shader_edit_particle_strand(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->edit_particle_strand) { - sh_data->edit_particle_strand = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_edit_particle_strand_vert_glsl, - NULL}, - .frag = (const char *[]){datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->edit_particle_strand = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_edit_particle_strand_clipped" : + "overlay_edit_particle_strand"); } return sh_data->edit_particle_strand; } @@ -561,18 +554,10 @@ GPUShader *OVERLAY_shader_edit_particle_strand(void) GPUShader *OVERLAY_shader_edit_particle_point(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->edit_particle_point) { - sh_data->edit_particle_point = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_edit_particle_point_vert_glsl, - NULL}, - .frag = (const char *[]){datatoc_gpu_shader_point_varying_color_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->edit_particle_point = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_edit_particle_point_clipped" : "overlay_edit_particle_point"); } return sh_data->edit_particle_point; } diff --git a/source/blender/draw/engines/overlay/shaders/edit_particle_point_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_particle_point_vert.glsl index efc0d7bee61..956b27e948d 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_particle_point_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_particle_point_vert.glsl @@ -1,8 +1,6 @@ -in vec3 pos; -in float color; - -out vec4 finalColor; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) void main() { @@ -13,7 +11,5 @@ void main() gl_PointSize = sizeVertex * 2.0; -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(world_pos); -#endif + view_clipping_distances(world_pos); } diff --git a/source/blender/draw/engines/overlay/shaders/edit_particle_strand_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_particle_strand_vert.glsl index adda4866bf1..6a92206d524 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_particle_strand_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_particle_strand_vert.glsl @@ -1,11 +1,6 @@ -uniform sampler1D weightTex; -uniform bool useWeight; - -in vec3 pos; -in float color; - -out vec4 finalColor; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) #define no_active_weight 666.0 @@ -36,7 +31,5 @@ void main() finalColor = mix(colorWire, colorVertexSelect, color); } -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(world_pos); -#endif + view_clipping_distances(world_pos); } 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 a30c1df4f6a..e6f15046838 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 @@ -427,6 +427,46 @@ GPU_SHADER_CREATE_INFO(overlay_edit_lattice_wire_clipped) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Edit Particle + * \{ */ + +GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand) + .do_static_compilation(true) + /* NOTE: Color already in Linear space. Which is what we want. */ + .define("srgbTarget", "false") + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::FLOAT, "color") + .sampler(0, ImageType::FLOAT_1D, "weightTex") + .push_constant(Type::BOOL, "useWeight") + .vertex_out(overlay_edit_smooth_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .vertex_source("edit_particle_strand_vert.glsl") + .fragment_source("gpu_shader_3D_smooth_color_frag.glsl") + .additional_info("draw_mesh", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand_clipped) + .do_static_compilation(true) + .additional_info("overlay_edit_particle_strand", "drw_clipped"); + +GPU_SHADER_CREATE_INFO(overlay_edit_particle_point) + .do_static_compilation(true) + /* NOTE: Color already in Linear space. Which is what we want. */ + .define("srgbTarget", "false") + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::FLOAT, "color") + .vertex_out(overlay_edit_flat_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .vertex_source("edit_particle_point_vert.glsl") + .fragment_source("gpu_shader_point_varying_color_frag.glsl") + .additional_info("draw_mesh", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_edit_particle_point_clipped) + .do_static_compilation(true) + .additional_info("overlay_edit_particle_point", "drw_clipped"); + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Edit GPencil * \{ */ |