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

Glitching happens when the camera moves continuously, on sprites or ColorRects with hard edges #91947

Open
LuxyCeremy opened this issue May 14, 2024 · 2 comments · May be fixed by #92023
Open

Comments

@LuxyCeremy
Copy link

Tested versions

Reproducible in 4.2.2

System information

Godot v4.2.2.rc (2fdeeea) - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 SUPER (NVIDIA; 31.0.15.3713) - Intel(R) Core(TM) i9-14900KF (32 Threads)

Issue description

When camera moves continuously(for example, moved by the position of mouse cursor), any sprite or colorrect start glitching obviously.
glitch
Currently, My way to fix this is use a "pre-rendered" soft edge rect, with several pixels of blur edge. (It performs like below)
temp_solution
屏幕截图 2024-05-14 203329

I am curious if any one can make "build-in linear render" possible.

Steps to reproduce

Here is the "pre-rendered" sprite:
rect_blur_edge

Minimal reproduction project (MRP)

N/A

@Calinou
Copy link
Member

Calinou commented May 15, 2024

This is expected, as rects are drawn without antialiasing. This makes them perfectly crisp without any blurriness, but it means that they'll appear to jitter when they slowly move. You need to draw rects with antialiasing if you want them to be able to move with subpixel movement. This is possible since 4.3 thanks to #84523.

ColorRect node currently doesn't expose this form of antialiasing, so you'll have to use the _draw_rect() method instead. Alternatively, you can enable MSAA 2D in the Project Settings to have all rects be antialiased (including Sprite and ColorRect).

Sprite can't expose this form of antialiasing as it's meant to draw a texture, not a single color. 2D MSAA will affect its edges though.

@LuxyCeremy
Copy link
Author

This is expected, as rects are drawn without antialiasing. This makes them perfectly crisp without any blurriness, but it means that they'll appear to jitter when they slowly move. You need to draw rects with antialiasing if you want them to be able to move with subpixel movement. This is possible since 4.3 thanks to #84523.

ColorRect node currently doesn't expose this form of antialiasing, so you'll have to use the _draw_rect() method instead. Alternatively, you can enable MSAA 2D in the Project Settings to have all rects be antialiased (including Sprite and ColorRect).

Sprite can't expose this form of antialiasing as it's meant to draw a texture, not a single color. 2D MSAA will affect its edges though.

Great.

I believe the optimal solution is to enable antialiasing for those nodes, similar to "StyleBoxFlat". Relying on pre-rendered sprites is an unorthodox method.

Using MSAA 2D is beneficial, but it consumes a significant amount of performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants