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

Use screen-aligned quads for origin lines to avoid issues on NVidia #83895

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

clayjohn
Copy link
Member

@clayjohn clayjohn commented Oct 24, 2023

While we are at it, use alpha-antialised lines to make them look nice

Fixes: #37016

I can't reproduce the issue on my device as it is a driver bug. But this PR should avoid it completely as it doesn't use rasterized lines.

Importantly, this PR does make the lines slightly thicker in order to antialiase them. That is a tradeoff that we have to pay.

CC @aaronfranke please try it out and let me know if you are happy with the solution

For posterity, the technique is based on the one described here: https://wwwtyro.net/2019/11/18/instanced-lines.html

Master: no antialiasing
Screenshot from 2023-10-24 18-14-01

This PR: no antialiasing
Screenshot from 2023-10-24 18-14-53

Master: MSAA 8X
Screenshot from 2023-10-24 18-14-14

This PR: MSAA 8X (note how this looks the same as no antialiasing)
Screenshot from 2023-10-24 18-15-00

While we are add it, use alpha-antialised lines to make them look nice
@clayjohn clayjohn added this to the 4.x milestone Oct 24, 2023
@clayjohn clayjohn requested a review from a team as a code owner October 24, 2023 16:20
@Riteo
Copy link
Contributor

Riteo commented Oct 24, 2023

Why are the lines always antialiased?

@clayjohn
Copy link
Member Author

Why are the lines always antialiased?

The linked issue comes from the lines aliasing. The solution is to antialias the lines. But since we don't want to force the viewport to always use an antialiasing solution, we apply one directly to the lines

@clayjohn clayjohn changed the title Uses screen-aligned quads for origin lines to avoid issues on NVidia Use screen-aligned quads for origin lines to avoid issues on NVidia Oct 24, 2023
@PZerua
Copy link
Contributor

PZerua commented Oct 24, 2023

Just curious, the ~0.5ms increase in GPU time comes from this new method?

@aaronfranke
Copy link
Member

@PZerua It's probably just random jitter, so I would not worry about it. It's a line, it should be nearly instant to render.

@clayjohn
Copy link
Member Author

Just curious, the ~0.5ms increase in GPU time comes from this new method?

No. It's just random. You can see that the performance actually increases when using MSAA compared to MSAA on master.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on a RTX 4090, it works as expected (including when FXAA, TAA or FSR 2.2 is used). Using camera presets or orthogonal camera keeps the expected appearance.

That said, resolution scales lower than 1.0 will appear to make the lines thicker (this is also an issue with hardware-based lines, such as grid lines).

Regarding performance, it's pretty much identical (tested with identical ~4K viewport resolution, Prefer Maximum Performance power profile in nvidia-settings and Update Continuously enabled in editor settings):

Before After (this PR)
Screenshot_20231026_155657 Screenshot_20231026_155617

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Oct 27, 2023
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@akien-mga akien-mga added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Oct 30, 2023
@akien-mga akien-mga merged commit 0cdb530 into godotengine:master Jan 4, 2024
@akien-mga
Copy link
Member

Thanks!

@clayjohn clayjohn deleted the origin-lines branch January 5, 2024 19:48
@YuriSizov YuriSizov removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Jan 25, 2024
@YuriSizov
Copy link
Contributor

Cherry-picked for 4.2.2.

@atirut-w
Copy link
Contributor

Importantly, this PR does make the lines slightly thicker in order to antialiase them. That is a tradeoff that we have to pay.

In my opinion, it looks very much better than before this PR. Can it be extended to other things?

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.

Y Axis Gizmo randomly disappears at some angles
8 participants