Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a project setting to control 3D line drawing thickness #91171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Apr 25, 2024

This setting affects all lines drawn in 3D, including gizmos in the editor and debug draw options. This can be used to make debug drawing more visible, particularly when using a high-resolution viewport.

This relies on hardware support, so it's not available on all platforms and GPUs (see maximum supported line width). It's also only supported in the Forward+ and Mobile rendering methods.

This could technically be implemented in Compatibility with glLineWidth() (on desktop platforms only), but I haven't managed to do this yet.

Preview

Line width = 1

Screenshot_20240425_191230

Line width = 2

Screenshot_20240425_191206

Line width = 1 with half-resolution viewport

Effective line width is identical to line width = 2. This shows how thicker lines are helpful on high-resolution viewports, such as hiDPI displays.

Screenshot_20240425_191236

TODO

  • Expose an editor setting to control line width in the editor while keeping the project setting for the running project.

@clayjohn
Copy link
Member

If we want to expose this for GPUs that support it, we need to check for the wideLines feature and then properly warn users when its not available and fall back to a width of 1.0.

From the Vulkan spec:

wideLines specifies whether lines with width other than 1.0 are supported. If this feature is not enabled, the lineWidth member of the VkPipelineRasterizationStateCreateInfo structure must be 1.0 unless the VK_DYNAMIC_STATE_LINE_WIDTH dynamic state is enabled, in which case the lineWidth parameter to vkCmdSetLineWidth must be 1.0. When this feature is supported, the range and granularity of supported line widths are indicated by the lineWidthRange and lineWidthGranularity members of the VkPhysicalDeviceLimits structure, respectively.

@Calinou Calinou force-pushed the project-settings-add-line-drawing-width branch from 4f7b641 to 250abdd Compare October 31, 2024 00:23
@Calinou
Copy link
Member Author

Calinou commented Oct 31, 2024

Rebased and tested again, it works as expected. Note that I didn't implement the wideLines check yet.

If we want to expose this for GPUs that support it, we need to check for the wideLines feature and then properly warn users when its not available and fall back to a width of 1.0.

I can see wideLines being mentioned here:

Error RenderingDeviceDriverVulkan::_check_device_features() {

The question is, how do I expose this information so it can be read in RenderSceneClustered and RenderSceneMobile? Preferably without adding Vulkan-specific checks to those classes, that is.

(Also, what about Direct3D 12? I suppose nearly all GPUs on D3D12 support line widths greater than 1.0 anyway.)

@Calinou Calinou force-pushed the project-settings-add-line-drawing-width branch from 250abdd to 01c53c0 Compare October 31, 2024 00:25
@clayjohn
Copy link
Member

clayjohn commented Nov 7, 2024

The question is, how do I expose this information so it can be read in RenderSceneClustered and RenderSceneMobile? Preferably without adding Vulkan-specific checks to those classes, that is.

Either through limit_get() or has_feature() I guess

doc/classes/ProjectSettings.xml Outdated Show resolved Hide resolved
doc/classes/ProjectSettings.xml Outdated Show resolved Hide resolved
doc/classes/ProjectSettings.xml Outdated Show resolved Hide resolved
doc/classes/ProjectSettings.xml Outdated Show resolved Hide resolved
This setting affects all lines drawn in 3D, including gizmos
in the editor and debug draw options. This can be used to make
debug drawing more visible, particularly when using a high-resolution
viewport.

This relies on hardware support, so it's not available on all platforms
and GPUs. It's also only supported in the Forward+ and Mobile rendering methods.
@Calinou Calinou force-pushed the project-settings-add-line-drawing-width branch from 01c53c0 to d5c7104 Compare November 11, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow changing the line width of 3D gizmos
4 participants