UI: Custom Tooltips with Optional Images #105905

Merged
Harley Acheson merged 6 commits from Harley/blender:CustomTooltips into main 2023-09-15 21:06:38 +02:00
9 changed files with 139 additions and 63 deletions
Showing only changes of commit 7584135de2 - Show all commits

View File

@ -908,6 +908,7 @@ class LoadImageAsEmpty:
)
filter_image: BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
filter_movie: BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
filter_folder: BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
view_align: BoolProperty(

View File

@ -959,6 +959,32 @@ class VIEW3D_HT_header(Header):
sub.active = overlay.show_overlays
sub.popover(panel="VIEW3D_PT_overlay", text="")
show_bone_overlays = (
(object_mode == 'POSE') or
(object_mode == 'PAINT_WEIGHT' and context.pose_object) or
(object_mode in {'EDIT_ARMATURE', 'OBJECT'} and
VIEW3D_PT_overlay_bones.is_using_wireframe(context))
)
if show_bone_overlays:
sub.popover(panel="VIEW3D_PT_overlay_bones", text="", icon="POSE_HLT")
elif context.mode == 'EDIT_MESH':
sub.popover(panel="VIEW3D_PT_overlay_edit_mesh", text="", icon="EDITMODE_HLT")
if context.mode == 'EDIT_CURVE':
sub.popover(panel="VIEW3D_PT_overlay_edit_curve", text="", icon="EDITMODE_HLT")
elif context.mode == 'SCULPT' and context.sculpt_object:
sub.popover(panel="VIEW3D_PT_overlay_sculpt", text="", icon="SCULPTMODE_HLT")
elif context.mode == 'SCULPT_CURVES' and context.object:
sub.popover(panel="VIEW3D_PT_overlay_sculpt_curves", text="", icon="SCULPTMODE_HLT")
elif context.mode == 'PAINT_WEIGHT':
sub.popover(panel="VIEW3D_PT_overlay_weight_paint", text="", icon="WPAINT_HLT")
elif context.mode == 'PAINT_TEXTURE':
sub.popover(panel="VIEW3D_PT_overlay_texture_paint", text="", icon="TPAINT_HLT")
elif context.mode == 'PAINT_VERTEX':
sub.popover(panel="VIEW3D_PT_overlay_vertex_paint", text="", icon="VPAINT_HLT")
elif context.object and context.object.type == 'GPENCIL':
sub.popover(panel="VIEW3D_PT_overlay_gpencil_options", text="", icon="OUTLINER_DATA_GREASEPENCIL")
row = layout.row()
row.active = (object_mode == 'EDIT') or (shading.type in {'WIREFRAME', 'SOLID'})
@ -6829,8 +6855,8 @@ class VIEW3D_PT_overlay_motion_tracking(Panel):
class VIEW3D_PT_overlay_edit_mesh(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Mesh Edit Mode"
bl_ui_units_x = 12
@classmethod
def poll(cls, context):
@ -6838,6 +6864,7 @@ class VIEW3D_PT_overlay_edit_mesh(Panel):
def draw(self, context):
layout = self.layout
layout.label(text="Mesh Edit Mode Overlays")
view = context.space_data
shading = view.shading
@ -7017,7 +7044,7 @@ class VIEW3D_PT_overlay_edit_mesh_normals(Panel):
class VIEW3D_PT_overlay_edit_mesh_freestyle(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_parent_id = 'VIEW3D_PT_overlay_edit_mesh'
bl_label = "Freestyle"
@classmethod
@ -7042,7 +7069,6 @@ class VIEW3D_PT_overlay_edit_mesh_freestyle(Panel):
class VIEW3D_PT_overlay_edit_curve(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Curve Edit Mode"
@classmethod
@ -7055,6 +7081,8 @@ class VIEW3D_PT_overlay_edit_curve(Panel):
overlay = view.overlay
display_all = overlay.show_overlays
layout.label(text="Curve Edit Mode Overlays")
col = layout.column()
col.active = display_all
@ -7072,7 +7100,6 @@ class VIEW3D_PT_overlay_sculpt(Panel):
bl_space_type = 'VIEW_3D'
bl_context = ".sculpt_mode"
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Sculpt"
@classmethod
@ -7088,6 +7115,8 @@ class VIEW3D_PT_overlay_sculpt(Panel):
view = context.space_data
overlay = view.overlay
layout.label(text="Sculpt Mode Overlays")
row = layout.row(align=True)
row.prop(overlay, "show_sculpt_mask", text="")
sub = row.row()
@ -7105,7 +7134,6 @@ class VIEW3D_PT_overlay_sculpt_curves(Panel):
bl_space_type = 'VIEW_3D'
bl_context = ".curves_sculpt"
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Sculpt"
@classmethod
@ -7118,6 +7146,8 @@ class VIEW3D_PT_overlay_sculpt_curves(Panel):
view = context.space_data
overlay = view.overlay
layout.label(text="Curve Sculpt Overlays")
row = layout.row(align=True)
row.active = overlay.show_overlays
row.prop(overlay, "sculpt_mode_mask_opacity", text="Selection Opacity")
@ -7133,7 +7163,6 @@ class VIEW3D_PT_overlay_sculpt_curves(Panel):
class VIEW3D_PT_overlay_bones(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Bones"
@staticmethod
@ -7171,6 +7200,8 @@ class VIEW3D_PT_overlay_bones(Panel):
overlay = view.overlay
display_all = overlay.show_overlays
layout.label(text="Armature Overlays")
col = layout.column()
col.active = display_all
@ -7191,7 +7222,6 @@ class VIEW3D_PT_overlay_bones(Panel):
class VIEW3D_PT_overlay_texture_paint(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Texture Paint"
@classmethod
@ -7204,6 +7234,8 @@ class VIEW3D_PT_overlay_texture_paint(Panel):
overlay = view.overlay
display_all = overlay.show_overlays
layout.label(text="Texture Paint Overlays")
col = layout.column()
col.active = display_all
col.prop(overlay, "texture_paint_mode_opacity")
@ -7212,7 +7244,6 @@ class VIEW3D_PT_overlay_texture_paint(Panel):
class VIEW3D_PT_overlay_vertex_paint(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Vertex Paint"
@classmethod
@ -7225,6 +7256,8 @@ class VIEW3D_PT_overlay_vertex_paint(Panel):
overlay = view.overlay
display_all = overlay.show_overlays
layout.label(text="Vertex Paint Overlays")
col = layout.column()
col.active = display_all
@ -7235,8 +7268,8 @@ class VIEW3D_PT_overlay_vertex_paint(Panel):
class VIEW3D_PT_overlay_weight_paint(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Weight Paint"
bl_ui_units_x = 12
@classmethod
def poll(cls, context):
@ -7249,6 +7282,8 @@ class VIEW3D_PT_overlay_weight_paint(Panel):
display_all = overlay.show_overlays
tool_settings = context.tool_settings
layout.label(text="Weight Paint Overlays")
col = layout.column()
col.active = display_all
@ -7477,15 +7512,18 @@ class VIEW3D_PT_gpencil_guide(Panel):
class VIEW3D_PT_overlay_gpencil_options(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = ""
bl_ui_units_x = 13
@classmethod
def poll(cls, context):
return context.object and context.object.type == 'GPENCIL'
def draw_header(self, context):
def draw(self, context):
layout = self.layout
view = context.space_data
overlay = view.overlay
layout.label(text={
'PAINT_GPENCIL': iface_("Draw Grease Pencil"),
'EDIT_GPENCIL': iface_("Edit Grease Pencil"),
@ -7495,11 +7533,6 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
'OBJECT': iface_("Grease Pencil"),
}[context.mode], translate=False)
def draw(self, context):
layout = self.layout
view = context.space_data
overlay = view.overlay
layout.prop(overlay, "use_gpencil_onion_skin", text="Onion Skin")
col = layout.column()

View File

@ -51,8 +51,23 @@ vec2 brdf_lut(float cos_theta, float roughness)
return textureLod(utilTex, vec3(lut_coords(cos_theta, roughness), BRDF_LUT_LAYER), 0.0).rg;
}
/* Return texture coordinates to sample Surface LUT. */
vec3 lut_coords_btdf(float cos_theta, float roughness, float ior)
vec4 sample_3D_texture(sampler2DArray tex, vec3 coords)
{
float layer_floored;
float interp = modf(coords.z, layer_floored);
coords.z = layer_floored;
vec4 tex_low = textureLod(tex, coords, 0.0);
coords.z += 1.0;
vec4 tex_high = textureLod(tex, coords, 0.0);
/* Manual trilinear interpolation. */
return mix(tex_low, tex_high, interp);
}
/* Return texture coordinates to sample BSDF LUT. */
vec3 lut_coords_bsdf(float cos_theta, float roughness, float ior)
{
/* ior is sin of critical angle. */
float critical_cos = sqrt(1.0 - ior * ior);
@ -69,6 +84,7 @@ vec3 lut_coords_btdf(float cos_theta, float roughness, float ior)
/* scale and bias coordinates, for correct filtered lookup */
coords.xy = coords.xy * (LUT_SIZE - 1.0) / LUT_SIZE + 0.5 / LUT_SIZE;
coords.z = coords.z * lut_btdf_layer_count + lut_btdf_layer_first;
return coords;
}
@ -95,19 +111,7 @@ vec2 bsdf_lut(float cos_theta, float roughness, float ior, float do_multiscatter
return vec2(btdf, brdf) * ((do_multiscatter == 0.0) ? sum(split_sum) : 1.0);
}
vec3 coords = lut_coords_btdf(cos_theta, roughness, ior);
float layer = coords.z * lut_btdf_layer_count;
float layer_floored = floor(layer);
coords.z = lut_btdf_layer_first + layer_floored;
vec2 btdf_brdf_low = textureLod(utilTex, coords, 0.0).rg;
coords.z += 1.0;
vec2 btdf_brdf_high = textureLod(utilTex, coords, 0.0).rg;
/* Manual trilinear interpolation. */
vec2 btdf_brdf = mix(btdf_brdf_low, btdf_brdf_high, layer - layer_floored);
vec2 btdf_brdf = sample_3D_texture(utilTex, lut_coords_bsdf(cos_theta, roughness, ior)).rg;
if (do_multiscatter != 0.0) {
/* For energy-conserving BSDF the reflection and refraction lobes should sum to one. Assuming

View File

@ -1316,6 +1316,23 @@ float4 utility_tx_sample_lut(sampler2DArray util_tx, float2 uv, float layer)
return textureLod(util_tx, float3(uv, layer), 0.0);
}
/* Sample GGX BSDF LUT. */
float4 utility_tx_sample_bsdf_lut(sampler2DArray util_tx, float2 uv, float layer)
{
/* Scale and bias coordinates, for correct filtered lookup. */
uv = uv * UTIL_TEX_UV_SCALE + UTIL_TEX_UV_BIAS;
layer = layer * UTIL_BTDF_LAYER_COUNT + UTIL_BTDF_LAYER;
float layer_floored;
float interp = modf(layer, layer_floored);
float4 tex_low = textureLod(util_tx, float3(uv, layer_floored), 0.0);
float4 tex_high = textureLod(util_tx, float3(uv, layer_floored + 1.0), 0.0);
/* Manual trilinear interpolation. */
return mix(tex_low, tex_high, interp);
}
/* Sample LTC or BSDF LUTs with `cos_theta` and `roughness` as inputs. */
float4 utility_tx_sample_lut(sampler2DArray util_tx, float cos_theta, float roughness, float layer)
{

View File

@ -297,6 +297,23 @@ vec2 brdf_lut(float cos_theta, float roughness)
#endif
}
/* Return texture coordinates to sample BSDF LUT. */
vec3 lut_coords_bsdf(float cos_theta, float roughness, float ior)
{
/* IOR is the sine of the critical angle. */
float critical_cos = sqrt(1.0 - ior * ior);
vec3 coords;
coords.x = sqr(ior);
coords.y = cos_theta;
coords.y -= critical_cos;
coords.y /= (coords.y > 0.0) ? (1.0 - critical_cos) : critical_cos;
coords.y = coords.y * 0.5 + 0.5;
coords.z = roughness;
return saturate(coords);
}
vec2 bsdf_lut(float cos_theta, float roughness, float ior, float do_multiscatter)
{
if (ior <= 1e-5) {
@ -318,28 +335,9 @@ vec2 bsdf_lut(float cos_theta, float roughness, float ior, float do_multiscatter
return vec2(btdf, brdf) * ((do_multiscatter == 0.0) ? sum(split_sum) : 1.0);
}
/* IOR is sin of critical angle. */
float critical_cos = sqrt(1.0 - ior * ior);
vec3 coords;
coords.x = sqr(ior);
coords.y = cos_theta;
coords.y -= critical_cos;
coords.y /= (coords.y > 0.0) ? (1.0 - critical_cos) : critical_cos;
coords.y = coords.y * 0.5 + 0.5;
coords.z = roughness;
coords = saturate(coords);
float layer = coords.z * UTIL_BTDF_LAYER_COUNT;
float layer_floored = floor(layer);
#ifdef EEVEE_UTILITY_TX
coords.z = UTIL_BTDF_LAYER + layer_floored;
vec2 btdf_brdf_low = utility_tx_sample_lut(utility_tx, coords.xy, coords.z).rg;
vec2 btdf_brdf_high = utility_tx_sample_lut(utility_tx, coords.xy, coords.z + 1.0).rg;
/* Manual trilinear interpolation. */
vec2 btdf_brdf = mix(btdf_brdf_low, btdf_brdf_high, layer - layer_floored);
vec3 coords = lut_coords_bsdf(cos_theta, roughness, ior);
vec2 btdf_brdf = utility_tx_sample_bsdf_lut(utility_tx, coords.xy, coords.z).rg;
if (do_multiscatter != 0.0) {
/* For energy-conserving BSDF the reflection and refraction lobes should sum to one. Assuming

View File

@ -48,4 +48,11 @@ void ui_region_temp_remove(bContext *C, bScreen *screen, ARegion *region)
ED_region_exit(C, region);
BKE_area_region_free(nullptr, region); /* nullptr: no space-type. */
BLI_freelinkN(&screen->regionbase, region);
if (CTX_wm_region(C) == region) {
CTX_wm_region_set(C, nullptr);
}
if (CTX_wm_menu(C) == region) {
CTX_wm_menu_set(C, nullptr);
}
}

View File

@ -1988,7 +1988,6 @@ static void widget_draw_text(const uiFontStyle *fstyle,
/* We are drawing on top of widget bases. Flush cache. */
GPU_blend(GPU_BLEND_ALPHA);
UI_widgetbase_draw_cache_flush();
GPU_blend(GPU_BLEND_NONE);
if (but->selsta >= but->ofs) {
selsta_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selsta - but->ofs);
@ -2016,6 +2015,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
selection_shape.ymax);
immUnbindProgram();
GPU_blend(GPU_BLEND_NONE);
#ifdef WITH_INPUT_IME
/* IME candidate window uses selection position. */

View File

@ -106,12 +106,32 @@ static float get_aspect_scaled_extent(const rctf &extent, const UVPackIsland_Par
return std::max(width / params.target_aspect_y, height);
}
/**
* \return the area of `extent`, factoring in the target aspect ratio.
*/
static float get_aspect_scaled_area(const rctf &extent, const UVPackIsland_Params &params)
{
const float width = BLI_rctf_size_x(&extent);
const float height = BLI_rctf_size_y(&extent);
return (width / params.target_aspect_y) * height;
}
/**
* \return true if `b` is a preferred layout over `a`, given the packing parameters supplied.
*/
static bool is_larger(const rctf &a, const rctf &b, const UVPackIsland_Params &params)
{
return get_aspect_scaled_extent(b, params) < get_aspect_scaled_extent(a, params);
const float extent_a = get_aspect_scaled_extent(a, params);
const float extent_b = get_aspect_scaled_extent(b, params);
/* Equal extent, use smaller area. */
if (compare_ff_relative(extent_a, extent_b, FLT_EPSILON, 64)) {
const float area_a = get_aspect_scaled_area(a, params);
const float area_b = get_aspect_scaled_area(b, params);
return area_b < area_a;
}
return extent_b < extent_a;
}
PackIsland::PackIsland()
@ -1919,8 +1939,10 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
/* At this stage, `extent` contains the fast/optimal/box_pack/xatlas UVs. */
if (all_can_rotate) {
/* Attempt to improve the layout even further by finding the minimal-bounding-square. */
/* If more islands remain to be packed, attempt to improve the layout further by finding the
* minimal-bounding-square. Disabled for other cases as users often prefer to avoid diagonal
* islands. */
if (all_can_rotate && aabbs.size() > slow_aabbs.size()) {
rotate_inside_square(slow_aabbs, islands, params, scale, margin, r_phis, &extent);
}

View File

@ -21,12 +21,6 @@ BLACKLIST_UNSUPPORTED_RENDER_TESTS = [
'node_keying_screen.blend'
]
BLACKLIST_CRASHING_TESTS = [
'node_keying.blend',
'node_keying_edge.blend',
'node_keying_matte.blend'
]
ENABLE_REALTIME_COMPOSITOR_SCRIPT = "import bpy; " \
"bpy.context.preferences.experimental.use_experimental_compositors = True; " \
"bpy.data.scenes[0].node_tree.execution_mode = 'REALTIME'"
@ -67,7 +61,7 @@ def main():
idiff = args.idiff[0]
output_dir = args.outdir[0]
blacklist_all = BLACKLIST_CRASHING_TESTS + BLACKLIST_UNSUPPORTED_RENDER_TESTS
blacklist_all = BLACKLIST_UNSUPPORTED_RENDER_TESTS
from modules import render_report
report = render_report.Report("Compositor Realtime", output_dir, idiff, blacklist=blacklist_all)
report.set_reference_dir("compositor_realtime_renders")