Adjust StyleBoxFlat antialiasing to account for Viewport oversampling#109358
Conversation
There was a problem hiding this comment.
Tested locally, it works as expected. Code looks good to me.
Since this uses TextServer now, it might be worth a second look from @bruvzg.
However, this has a strange effect on the MRP if you call this in _ready() in the MRP:
func _ready():
get_viewport().oversampling_override = 0.1Lines become much thicker and the antialiasing is mostly gone:
With the value set to 0.1, you can see the issue more clearly:
I'm not sure to which degree this is intended.
0731546 to
8703baa
Compare
|
@Calinou I think this is still correct when the provided oversampling value fits the render target's resolution. This is how the image looks like with oversampling override set to 0, but I scale the SubViewport's size to be 10% the resolution set in Size 2D Override.
The lines are just fighting to still be visible. With 0.5 scaling and filtering set to nearest to make the pixels more visible:
I think solving this so that the line doesn't fight but rather fades out when its width is less than the size of a pixel would require a separate PR. |
|
Could you rebase your PR? See our pull request guidelines for more information |
8703baa to
cc518e6
Compare
cc518e6 to
a29be8f
Compare
|
Done and tested. Sorry for not noticing the merge conflict earlier. |
Repiteo
left a comment
There was a problem hiding this comment.
No worries, and great job handling that so quickly!
|
Thanks! Congratulations on your first merged contribution! 🎉 |


Original proposal: godotengine/godot-proposals#12949
This adjusts the original antialiasing of
StyleBoxFlatintroduced in #92997 to account for the new per-viewport oversampling introduced later in #104872Previously the
StyleBoxFlattook the root window's stretch transform into account, independent of what the current render target was. Once per-viewport oversampling got introduced, text rendering scaled properly, but rounded corners did not, resulting in blurry edges.In the original proposal I suggested to move the
TextServer::set_current_drawn_item_oversamplingto theRenderingServerinstead, but looking into the implemention of theRenderingServerI am afraid that the newget_current_drawn_item_oversamplingwould introduce unnecessary synchronization, even though theRenderingServerwould only be used to temporarily hold adouble.Testing project:
test_styleboxflat_antialiasing_stretch.zip
Preview:
Before this PR:
After this PR: