Sculpt: add option to fade face sets with a
Moire pattern instead of transparently.
This commit is contained in:
parent
243e9be588
commit
2e3e10cc95
File diff suppressed because it is too large
Load Diff
|
@ -2240,6 +2240,22 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
BKE_brush_mapping_inherit_all(ch);
|
||||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 300, 39)) {
|
||||
if (!DNA_struct_elem_find(
|
||||
fd->filesdna, "View3DOverlay", "float", "sculpt_mode_face_sets_moire_scale")) {
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = (View3D *)sl;
|
||||
v3d->overlay.sculpt_mode_face_sets_moire_scale = 0.45f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,9 +40,18 @@ void OVERLAY_sculpt_cache_init(OVERLAY_Data *vedata)
|
|||
|
||||
GPUShader *sh = OVERLAY_shader_sculpt_mask();
|
||||
pd->sculpt_mask_grp = grp = DRW_shgroup_create(sh, psl->sculpt_mask_ps);
|
||||
|
||||
DRW_shgroup_uniform_float_copy(grp, "maskOpacity", pd->overlay.sculpt_mode_mask_opacity);
|
||||
|
||||
DRW_shgroup_uniform_float_copy(
|
||||
grp, "faceSetsOpacity", pd->overlay.sculpt_mode_face_sets_opacity);
|
||||
DRW_shgroup_uniform_float_copy(
|
||||
grp, "faceSetsPatSeed", pd->overlay.sculpt_mode_face_sets_moire_seed);
|
||||
DRW_shgroup_uniform_bool_copy(
|
||||
grp, "useMoire", pd->overlay.sculpt_flag & V3D_OVERLAY_SCULPT_FSET_MOIRE);
|
||||
|
||||
DRW_shgroup_uniform_float_copy(
|
||||
grp, "faceSetsPatScale", 0.5f * (1.1f - pd->overlay.sculpt_mode_face_sets_moire_scale));
|
||||
}
|
||||
|
||||
void OVERLAY_sculpt_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||
|
|
|
@ -1,10 +1,43 @@
|
|||
uniform float faceSetsOpacity;
|
||||
uniform float faceSetsPatSeed;
|
||||
uniform float faceSetsPatScale;
|
||||
uniform bool useMoire;
|
||||
|
||||
flat in vec3 faceset_color;
|
||||
in float mask_color;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
float tent(float f)
|
||||
{
|
||||
return 1.0 - abs(fract(f) - 0.5) * 2.0;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
fragColor = vec4(faceset_color * vec3(mask_color), 1.0);
|
||||
vec3 final_color = faceset_color;
|
||||
vec3 white = vec3(1.0, 1.0, 1.0);
|
||||
|
||||
if (!useMoire) {
|
||||
fragColor = vec4(final_color * vec3(mask_color), 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 xy = gl_FragCoord.xy * faceSetsPatScale;
|
||||
|
||||
/* Basic moire pattern */
|
||||
|
||||
float seed = 1.0 / 3.0 + faceSetsPatSeed;
|
||||
|
||||
float dx1 = tent(xy.x);
|
||||
float dy1 = tent(xy.y);
|
||||
float dx2 = tent(tent(seed) * xy.x + tent(seed * seed + 0.5) * xy.y);
|
||||
float dy2 = tent(tent(seed) * xy.y - tent(seed * seed + 0.5) * xy.x);
|
||||
|
||||
float fac = (dx1 + dy1 + dx2 + dy2) / 4.0;
|
||||
fac = step(fac, 1.0 - faceSetsOpacity);
|
||||
|
||||
final_color += (white - final_color) * fac;
|
||||
|
||||
fragColor = vec4(final_color * vec3(mask_color), 1.0);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
uniform bool useMoire;
|
||||
|
||||
uniform float maskOpacity;
|
||||
uniform float faceSetsOpacity;
|
||||
|
@ -16,7 +17,7 @@ void main()
|
|||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
|
||||
faceset_color = mix(vec3(1.0), fset, faceSetsOpacity);
|
||||
faceset_color = !useMoire ? mix(vec3(1.0), fset, sqrt(faceSetsOpacity)) : fset;
|
||||
mask_color = 1.0 - (msk * maskOpacity);
|
||||
|
||||
#ifdef USE_WORLD_CLIP_PLANES
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
* we typically want to see shading too. */ \
|
||||
.sculpt_mode_mask_opacity = 0.75f, \
|
||||
.sculpt_mode_face_sets_opacity = 1.0f, \
|
||||
.sculpt_mode_face_sets_moire_scale = 0.45f,\
|
||||
\
|
||||
.edit_flag = V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS | \
|
||||
V3D_OVERLAY_EDIT_SHARP | V3D_OVERLAY_EDIT_FREESTYLE_EDGE | \
|
||||
|
|
|
@ -219,6 +219,11 @@ typedef struct View3DOverlay {
|
|||
float weight_paint_mode_opacity;
|
||||
float sculpt_mode_mask_opacity;
|
||||
float sculpt_mode_face_sets_opacity;
|
||||
float sculpt_mode_face_sets_moire_seed;
|
||||
float sculpt_mode_face_sets_moire_scale;
|
||||
|
||||
/** Sculpt mode settings*/
|
||||
int sculpt_flag;
|
||||
|
||||
/** Armature edit/pose mode settings. */
|
||||
float xray_alpha_bone;
|
||||
|
@ -239,8 +244,6 @@ typedef struct View3DOverlay {
|
|||
float gpencil_vertex_paint_opacity;
|
||||
/** Handles display type for curves. */
|
||||
int handle_display;
|
||||
|
||||
char _pad[4];
|
||||
} View3DOverlay;
|
||||
|
||||
/* View3DOverlay->handle_display */
|
||||
|
@ -580,6 +583,11 @@ enum {
|
|||
V3D_OVERLAY_WPAINT_CONTOURS = (1 << 0),
|
||||
};
|
||||
|
||||
/** #View3DOverlay.sculpt_flag */
|
||||
enum {
|
||||
V3D_OVERLAY_SCULPT_FSET_MOIRE = (1 << 0),
|
||||
};
|
||||
|
||||
/** #View3D.around */
|
||||
enum {
|
||||
/* center of the bounding box */
|
||||
|
|
|
@ -4496,6 +4496,23 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
|
|||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "sculpt_mode_face_sets_moire_seed", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, NULL, "overlay.sculpt_mode_face_sets_moire_seed");
|
||||
RNA_def_property_ui_text(prop, "Pattern Seed", "Sculpt Face Sets Pattern Seed");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "sculpt_mode_use_face_set_moire", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "overlay.sculpt_flag", V3D_OVERLAY_SCULPT_FSET_MOIRE);
|
||||
RNA_def_property_ui_text(prop, "Moire", "Draw face sets with moire pattern");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "sculpt_mode_face_sets_moire_scale", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, NULL, "overlay.sculpt_mode_face_sets_moire_scale");
|
||||
RNA_def_property_ui_text(prop, "Pattern Scale", "Sculpt Face Sets Pattern Scale");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
/* grease pencil paper settings */
|
||||
prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_ANNOTATION);
|
||||
|
|
Loading…
Reference in New Issue