Add toggle for edit mode overlays fresnel #111494

Merged
Jeroen Bakker merged 1 commits from Gilberto.R/blender:temp-editfresnelpref into main 2023-08-28 15:29:32 +02:00
7 changed files with 24 additions and 5 deletions

View File

@ -741,6 +741,10 @@ class USERPREF_PT_viewport_display(ViewportPanel, CenterAlignMixIn, Panel):
if view.mini_axis_type == 'GIZMO':
col.prop(view, "gizmo_size_navigate_v3d", text="Size")
layout.separator()
col = layout.column(heading="Fresnel")
col.prop(view, "use_fresnel_edit")
class USERPREF_PT_viewport_quality(ViewportPanel, CenterAlignMixIn, Panel):
bl_label = "Quality"

View File

@ -103,7 +103,8 @@ void main()
facing = 1.0 - abs(facing) * 0.2;
/* Do interpolation in a non-linear space to have a better visual result. */
finalColor.rgb = non_linear_blend_color(colorEditMeshMiddle.rgb, finalColor.rgb, facing);
finalColor.rgb = mix(finalColor.rgb, non_linear_blend_color(colorEditMeshMiddle.rgb,
finalColor.rgb, facing), fresnelMixEdit);
#endif
view_clipping_distances(world_pos);

View File

@ -145,10 +145,10 @@ void main()
facing1 = 1.0 - abs(facing1) * 0.2;
/* Do interpolation in a non-linear space to have a better visual result. */
out_finalColor[0].rgb = non_linear_blend_color(
colorEditMeshMiddle.rgb, out_finalColor[0].rgb, facing0);
out_finalColor[1].rgb = non_linear_blend_color(
colorEditMeshMiddle.rgb, out_finalColor[1].rgb, facing1);
out_finalColor[0].rgb = mix(out_finalColor[0].rgb, non_linear_blend_color(
colorEditMeshMiddle.rgb, out_finalColor[0].rgb, facing0), fresnelMixEdit);
out_finalColor[1].rgb = mix(out_finalColor[1].rgb, non_linear_blend_color(
colorEditMeshMiddle.rgb, out_finalColor[1].rgb, facing1), fresnelMixEdit);
#endif
// -------- GEOM SHADER ALTERNATIVE ----------- //

View File

@ -84,6 +84,7 @@ void DRW_globals_update()
UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_PRIMARY, gb->color_checker_primary);
UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_SECONDARY, gb->color_checker_secondary);
gb->size_checker = UI_GetThemeValuef(TH_TRANSPARENT_CHECKER_SIZE);
gb->fresnel_mix_edit = ((U.gpu_flag & USER_GPU_FLAG_FRESNEL_EDIT) == 0 ) ? 0.0f : 1.0f;
Gilberto.R marked this conversation as resolved Outdated

Small tweak, use ? 0.0f : 1.0f

Small tweak, use `? 0.0f : 1.0f`
UI_GetThemeColor4fv(TH_V3D_CLIPPING_BORDER, gb->color_clipping_border);
/* Custom median color to slightly affect the edit mesh colors. */

View File

@ -134,6 +134,8 @@ struct GlobalsUboStorage {
float size_vertex, size_edge, size_edge_fix, size_face_dot;
float size_checker;
float size_vertex_gpencil;
float fresnel_mix_edit;
float _pad[3];
};
BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
@ -244,6 +246,7 @@ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
# define sizeFaceDot globalsBlock.size_face_dot
# define sizeChecker globalsBlock.size_checker
# define sizeVertexGpencil globalsBlock.size_vertex_gpencil
# define fresnelMixEdit globalsBlock.fresnel_mix_edit
#endif
/* See: 'draw_cache_impl.hh' for matching includes. */

View File

@ -1230,6 +1230,7 @@ typedef enum eUserpref_GPU_Flag {
USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE = (1 << 1),
USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE = (1 << 2),
USER_GPU_FLAG_SUBDIVISION_EVALUATION = (1 << 3),
USER_GPU_FLAG_FRESNEL_EDIT = (1 << 4),
} eUserpref_GPU_Flag;
/** #UserDef.tablet_api */

View File

@ -4846,6 +4846,15 @@ static void rna_def_userdef_view(BlenderRNA *brna)
"Zero to calculate this automatically, where the number of samples matches the target FPS");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "use_fresnel_edit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "gpu_flag", USER_GPU_FLAG_FRESNEL_EDIT);
RNA_def_property_ui_text(prop,
"Edit Mode",
"Enable a fresnel effect on edit mesh overlays.\n"
"It improves shape readability of very dense meshes, "
"but increases eye fatigue when modeling lower poly");
RNA_def_property_update(prop, 0, "rna_userdef_gpu_update");
USERDEF_TAG_DIRTY_PROPERTY_UPDATE_DISABLE;
prop = RNA_def_property(srna, "show_addons_enabled_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(