Fix #111017: Gap between color square and frame of box in the color ramp #111168
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111168
Loading…
Reference in New Issue
No description provided.
Delete Branch "lichtwerk/blender:111017"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While not a real fix, I tracked the reason down to
ui_draw_colorband_handle_box
(in the non-filled case) somewhatmisbehaving:
-- [1] top line is shifted a pixel up
-- [2] right line is shifter a pixel out
-- [3] top right corner pixel missing
But it even acts wrong if you substitute
ui_draw_colorband_handle_box
with
imm_draw_box_wire_2d
.Both only act wrong in the context of the colorband though (and are
working fine elsewhere) which is a bit weired and I could not track it
down. Of course we could counter-act by adjusting the width and height
that is passed to
ui_draw_colorband_handle_box
, but that still doesnot solve the corner pixel missing.
In this case we can use a workaround though: just draw the box filled.
Nice little tweak! +1 from the design point of view.
Huh interesting... I just
-1
'd the black outline width... This is probably due to half pixel aligning. If visually passable it's gonna be alright.No strong opinion here (if it works reliably -- does it? would be strange if it works for some widths but fails for others...).
If we go this route, it should probably have a comment explaining the "one off" otherwise might be confusion and we risk someone changes is back later...)
Interesting... I haven't really tried but from the look of it, it seems all sizes have that extra 1 px that I don't think I fully understand the cause 🤔
Originally the extra pixel was used to align the arrow with the color ramp line. Additionally all these widgets suffer from not having a clickable area outside the main ramp, but I guess that's another story! 👍
@CharlieJolly But the line seems to be 1 pixel to the right of the center of the arrow with or without the 1px added...
This was one of my very first contributions to Blender so I have a vague recollection that the arrow and line used to line up.
I'm pretty sure this broke over time... probably from a drawing code refactor... hehe
@CharlieJolly I think what we could do is having a 2 px line so it always line up :P
Worth a try! Lol
That is reported in #103477
Still think we should not rely on the non-filled version (if it can be unreliable in regards to actual widths -- and also having this missing pixel in the top-right corner)
Just for sentimental reasons, the old color ramp.
@lichtwerk
When I look at these little things, in current master not your PR, I see them working or not, depending on the "Line Width"
If my Resolution Scale is set to 1.0X, then it shows the gap on the right when using default line width, but looks okay when set to "Thick" lines:
With my Resolution Scale set to 2.0X then it looks funny with Thin lines, looks fine at Default, and is a bit thick on the right when "Thick" lines:
So my guess is this will be related to U.pixelsize. But note that for regular GL lines many Macs can't make simple lines wider than a pixel. Which could make this complicated.
My gut feeling is that a way to fix this nicely might be to construct this so that it always uses single-pixel width lines and so do not get wider/narrower with line width. The other components, the triangle and the rectangle of color, could use offsets (like border around the color square) that respond to line width (U.pixelsize).
I might be not be seeing all the oddness with my old eyes...
This indicator consists of a square with a triangle on top. The square itself is drawn as a black outline, a grey square, and a smaller square inside with the color. The black outline should be the same size as what it is outlining, but it is too big. Fairly certain the outline drawn with (0,0,0) should be at the exact position and same size as the grey box drawn with (128,128,128).
So I see most of the oddness going away with:
Thx for all the experiments.
Still, it seems to me that:
Sadly, this is currently how all of our line drawing routines work for lines wider than a single pixel.
As in you can take any of our line drawing shaders, make a box, and if the line width is greater than a pixel it will be missing the pixels you point out. Luckily we don't do this often though so this isn't usually noticed.
And if you take those same positions and make a solid box instead it will do so with two solid triangles and it will look perfect.
The background to this is fairly interesting.
If you go back a while we just told OpenGL to make a line of 3 pixels wide or whatever, draw those lines and it will look fine without those missing corner bits. But... creating lines wider than a single pixel is an optional part of the standard and we had/have many Macs that do not make a line wider than a single pixel. Draw those on a Mac Retina display and those pixels are TINY.
So instead we have new shaders that create geometry as they draw. So we draw a single line but the shader expands that out to make wider lines. But our shader just expands out perpendicularly so we get problems at bending intersections. You can make Grease Pencil lines super wide and notice that there are gaps at tight bends.
The best solution to this particular problem if you want it perfect is to not use lines at all but only solid shapes. So the outer box outline is instead drawn as a black box, then the grey box inset by U.pixelsize, then the color box offset again.
Tada! Exactly what the patch is doing, no?
For sure. But the same issue happens with the triangles, which also have to be drawn filled. And I am trying to get "Line Width" working as expected. With the following I can get it like the following (Thin, Default, Thick):
Ah, the triangle part of the widget (forgot about that one).
Yeah, that should be done, too, agree with your changes.
Since we already took the deep dive (wasnt expecting this to swallow that much time -- but in the end this is good!), the one remaining thing that still confuses me is this part from my PR description:
So for maximum educational purposes, we could still investigate that (not necessary though, just a bonus), otherwise, I could update this PR with the relevant code, or you could take over (whatever you prefer).
Do you have an example of GPU_PRIM_LINE_STRIP working differently elsewhere? It was only recently that I noticed the line drawing (when greater than a single pixel) leaves gaps at the corners.
Replacing some of our base drawing routines for unfilled boxes would make some sense, using filled rectangles for the lines when over a pixel in width.
It mostly depends on how much you are enjoying this. If you have had enough of staring at these things you could update and we could be done.
But if you are having fun the next logical steps are to replace the filled boxes with UI_draw_roundbox_4fv. Using that could round off the corners a bit. And then as these are drawn smaller reduce some of the sizes/complexity when it gets too small. Right now it just gets super clunky and then disappears when scaled down.
If the above sounds like a more trouble than it is worth, just ignore it, update the PR with that we have and we can be done.
Or if you want the above AND you are also bored of this then I can take it and play with it on the weekend.
I just wasnt noticing any such issues with
imm_draw_box_wire_2d
(and that uses a very similar method, just with GPU_PRIM_LINES).I am pretty sure I even tested
imm_draw_box_wire_2d
for the colorramp then (and there it also misbehaved...)In any case, this is now superseeded by !111903 , so will close.
Thx taking over @Harley !
Pull request closed