godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.74k stars 21.12k forks source link

2D Viewport Blend Function darkens pixels (3D Blend is OK) #84787

Open thygrrr opened 11 months ago

thygrrr commented 11 months ago

Godot version

4.2.beta 4.1.3.stable

System information

Windows 11

Issue description

2D portions of Viewports are blended in a way that causes pixels to darken (maybe it's SRC_COLOR = 1-SRC_ALPHA or something along these lines)

(Edit: May also be some sort of render target downsizing artifact, blending dark surrounding pixels into it - the viewport has a different size from the window here; but even if I set them to the same, there is visible darkening/thinning of the font)

image

image

Notably, the 3D labels don't seem to show these darker pixels after blending, hinting at a different (better!) blend function being used there. It is not possible to directly compare the fonts as the 3D system seems to use a different font resource by default.

image

Steps to reproduce

  1. start project's reproduction scene
  2. observe font problems :)

Minimal reproduction project

dark-blend-repro.zip

thygrrr commented 11 months ago

It's exacerbated by downsampling, but does not fully go away when viewport is the exact resolution of the window:

image

Calinou commented 11 months ago

For correct appearance, you need to use the premultiplied alpha blend mode using a CanvasItemMaterial when displaying a transparent viewport.