Fix #125680: Grease Pencil edit overlay shader theme switch

Grease Pencil v3 was using the same shader as particle strands, this leads
to sharing edit overlay color as particle strands. This patch fixes this
behaviour by adding a grease pencil toggle in the shader so grease pencil
overlay will use appropriate color and point sizes specified in the theme.

Pull Request: https://projects.blender.org/blender/blender/pulls/125689
This commit is contained in:
YimingWu
2024-08-28 09:10:05 +02:00
committed by YimingWu
parent 83ffadb248
commit 17397dae19
6 changed files with 14 additions and 3 deletions

View File

@@ -56,12 +56,14 @@ void OVERLAY_edit_curves_cache_init(OVERLAY_Data *vedata)
grp = pd->edit_curves_points_grp[i] = DRW_shgroup_create(sh, psl->edit_curves_points_ps[i]);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_bool_copy(grp, "useWeight", false);
DRW_shgroup_uniform_bool_copy(grp, "useGreasePencil", false);
}
DRW_PASS_CREATE(psl->edit_curves_lines_ps[i], (state | pd->clipping_state));
sh = OVERLAY_shader_edit_particle_strand();
grp = pd->edit_curves_lines_grp[i] = DRW_shgroup_create(sh, psl->edit_curves_lines_ps[i]);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_bool_copy(grp, "useWeight", false);
DRW_shgroup_uniform_bool_copy(grp, "useGreasePencil", false);
}
{
state = DRW_STATE_WRITE_COLOR;

View File

@@ -54,6 +54,7 @@ void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata)
grp = pd->edit_grease_pencil_wires_grp = DRW_shgroup_create(sh, psl->edit_grease_pencil_ps);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_bool_copy(grp, "useWeight", use_weight);
DRW_shgroup_uniform_bool_copy(grp, "useGreasePencil", true);
DRW_shgroup_uniform_texture(grp, "weightTex", G_draw.weight_ramp);
}
else {
@@ -65,6 +66,7 @@ void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata)
grp = pd->edit_grease_pencil_points_grp = DRW_shgroup_create(sh, psl->edit_grease_pencil_ps);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_bool_copy(grp, "useWeight", use_weight);
DRW_shgroup_uniform_bool_copy(grp, "useGreasePencil", true);
DRW_shgroup_uniform_texture(grp, "weightTex", G_draw.weight_ramp);
}
else {

View File

@@ -41,12 +41,14 @@ void OVERLAY_edit_particle_cache_init(OVERLAY_Data *vedata)
pd->edit_particle_strand_grp = grp = DRW_shgroup_create(sh, psl->edit_particle_ps);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_bool_copy(grp, "useWeight", pd->edit_particle.use_weight);
DRW_shgroup_uniform_bool_copy(grp, "useGreasePencil", false);
DRW_shgroup_uniform_texture(grp, "weightTex", G_draw.weight_ramp);
sh = OVERLAY_shader_edit_particle_point();
pd->edit_particle_point_grp = grp = DRW_shgroup_create(sh, psl->edit_particle_ps);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_bool_copy(grp, "useWeight", false);
DRW_shgroup_uniform_bool_copy(grp, "useGreasePencil", false);
}
void OVERLAY_edit_particle_cache_populate(OVERLAY_Data *vedata, Object *ob)

View File

@@ -634,6 +634,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand)
.vertex_in(1, Type::FLOAT, "selection")
.sampler(0, ImageType::FLOAT_1D, "weightTex")
.push_constant(Type::BOOL, "useWeight")
.push_constant(Type::BOOL, "useGreasePencil")
.vertex_out(overlay_edit_smooth_color_iface)
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_edit_particle_strand_vert.glsl")
@@ -651,6 +652,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_particle_point)
.vertex_out(overlay_edit_flat_color_iface)
.sampler(0, ImageType::FLOAT_1D, "weightTex")
.push_constant(Type::BOOL, "useWeight")
.push_constant(Type::BOOL, "useGreasePencil")
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_edit_particle_point_vert.glsl")
.fragment_source("overlay_point_varying_color_frag.glsl")

View File

@@ -31,10 +31,12 @@ void main()
finalColor = vec4(weight_to_rgb(selection), 1.0);
}
else {
finalColor = mix(colorWire, colorVertexSelect, selection);
vec4 use_color = useGreasePencil ? colorGpencilVertexSelect : colorVertexSelect;
finalColor = mix(colorWire, use_color, selection);
}
gl_PointSize = sizeVertex * 2.0;
float vsize = useGreasePencil ? sizeVertexGpencil : sizeVertex;
gl_PointSize = vsize * 2.0;
view_clipping_distances(world_pos);
}

View File

@@ -31,7 +31,8 @@ void main()
finalColor = vec4(weight_to_rgb(selection), 1.0);
}
else {
finalColor = mix(colorWire, colorVertexSelect, selection);
vec4 use_color = useGreasePencil ? colorGpencilVertexSelect : colorVertexSelect;
finalColor = mix(colorWire, use_color, selection);
}
view_clipping_distances(world_pos);