Added Wire/Edge width in the theme (3DView and UV/Image Editor)

I found a post on Right-Click Select UV island outline about the option to adjust the thickness of the edges in the UV-Editor.
While the post was about making the edges that outline an UV-island, I went with the basic option to adjust the width/thickness first and found, that it even had a “/* TODO: Theme. */” comment.

While I managed to get it working for 3D View and UV-Editor, I wonder if the result when increasing the thickness in the UV-Editor is pleasing enough. Increasing the thickness too much ended up looking really bad, so I first limited it to 5, in the newest patch to 32. The black bands left and right of the edge still seem to get too thick. It may not look good on normal resolution screens if maxed out, but a user mentioned that there are users that use resolutions, that profit from higher then 5 thickness.

With the smallest/default thickness of “1”:

While with thickness of “5”:

I am not sure exactly where the specific drawing for the black border comes from, so I hope someone could give me a tip.

I would like to continue on the challenge with the UV-islands, but for starters I think getting the look of the adjusted thickness is more important.

The responsible code for the thickness can be found in:
“\Blender-git\blender\source\blender\draw\intern\draw_common.c”

  gb->size_edge = U.pixelsize *
                    max_ff(0.5f, UI_GetThemeValuef(TH_EDGE_WIDTH) * (float)M_SQRT2 / 4.0f);
  gb->size_edge_fix = U.pixelsize * (0.5f + 2.0f * (1.0f * (gb->size_edge * (float)M_SQRT1_2)));

The above code is what I use in my attempt, the “TH_EDGE_WIDTH” is also implemented for this cause.
While I pretty much reused the code for the vertex size related code that can be found in the same file just above where the “gb->size_edge” is adjusted.

Update: Not the focus of the patch, but for completeness sake the 3DViewport got the option as well:
3DViewport Edge Width

The patch on review can be found here: Added Edge Width option in preferences for 3DView and UV/Image Editor

UPDATE: After the move to a new system the contribution can be found under Pull Request #104741

UPDATE: Thanks to the comments and suggestions this patch got finally merged

Thanks for the interest and helpful comments.

9 Likes

I wish we could adjust the viewport edge thickness. It looks so thin on a 4k monitor. Having only the options for thin or thick (which makes the whole interface thick and ugly) is not my favorite.

1 Like

@GabrielMoro While it was not my focus, I mentioned in my first post that I also added the “Width” option for the edges in the 3D View, while limited to the values from 1 to 5 pixels, it should help remedy your high resolution thin line problem. I’m gonna update the post to make it more clear.

2 Likes

This has been annoying me for years now, I hope the patch gets approved. Thank you so much!

1 Like

I’m struggling completely to implement this in Blender, didn’t find any file called draw_common.c maybe because I’m on Linux. Could you give me a hand?

The "file “draw_common.c” can be found in the “source/blender/draw/intern/” folder.

Here the link to the folder in the official source homepage:
your-blender-source-folder/source/blender/draw/intern/

I do not know if Linux is supposed to use different or less files, but I hope this helps.

1 Like

Thanks for your help mate. Do you think this tool could be implemented in a addon? I’m looking forward to have this feature in blender, could pay someone to code an addon and solve this problem for me.

Well, if all goes as I hope, there will be a review and the functionality will be added to master. With a lot other contributions already waiting I can only hope it will happen soon. The differential got some more attention, so with some luck it might happen sooner then later.

As it’s not using the python API, I’m rather certain (not 100%) it’s not something an addon would solve.
I’m not saying that nobody may be able to write an addon to achieve something similar, but why if the functionality can be put where it belongs, in the core of Blender just like the thickness for the “Vertex Size” or the “Outline width”.

1 Like

I hope it happens, cause damn, it’s so hard to see these thin lines when I’m modeling, especially in the orthographic view, it’s a nightmare. Thanks for all your effort, btw

did you already post a differential for this? Because you might need to re-create that as a PR now that we’ve switched to gitea.

@Baardaap The differential is archived, yes, will have to look later when back from work, thanks for pointing that out.

1 Like

Added a Pull Request after some work and a successful testbuild.
Can be found under Pull Request #104741
Hope it get’s a chance after the change to the new system.

2 Likes

For it to have any chance of being included in mainline blender, you’ll need to go and look for reviewers. This is always a bit difficult if you’re new and you don’t know many people/ don’t know who to contact.

What I always do for a new area of the code is:

  • use git blame to find out which other people have mainly worked (most recently) on the area I worked on.
  • try to find out if those people have an account here or on https://blender.chat
  • ask them (here or on chat) if it’s ok to add them as a reviewer or if they could suggest someone else if not.
4 Likes

In case you still want to tweak this a bit, I had a look around since I remember facing similar issues with node links.
The relevant shaders for drawing the edges in UV edit mode seem to be

overlay_edit_uv_edges_vert_no_geom.glsl
overlay_edit_uv_edges_geom.glsl
overlay_edit_uv_edges_frag.glsl

And related to the outline issue is this section:

  /* Enlarge edge for outline drawing. */
  /* Factor of 3.0 out of nowhere! Seems to fix issues with float imprecision. */
  half_size += (lineStyle == OVERLAY_UV_LINE_STYLE_OUTLINE) ?
                   max(sizeEdge * (doSmoothWire ? 1.0 : 3.0), 1.0) :
                   0.0;

The size of the outline is currently scaled by sizeEdge. Simply removing the sizeEdge factor makes the outline a fixed size, but then it also doesn’t scale with the scale of the rest of the interface anymore, which might be problematic.
So maybe that’s a place for you to explore some options.

Wishing this gets reviewed and implemented, it’s literally the thing in the UI that would help me the most daily. Thanks for building it. <3

2 Likes

Clément Foucault just agreed and assigned himself as reviewer, happy progress.

6 Likes