-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Transparent background doesn't become transparent foreground when rendered in reverse video #7014
Comments
Oh yeah, we need to do an inverse alpha mask with the shaped text. It's expensive and something we chose to not to. |
Could we get that behavior through an optional flag ? |
Meh, I'd be inclined to implement it and not make it configurable -- it's more expensive on the engineering side than it is on the runtime side, I expect. 😄 |
@DHowett 👍 Great, can't wait to see it implemented then 😁 Especially since you can use it only when you have that specific attributes combination, the current code can be used for faster rendering in every other case, and that combination would definitely look more correct taking advantage of the acrylic effect. |
Notes: We can't use a geometry mask based on the glyph run, because we want to fill outside of the geometry and not touch inside the geometry[1]. We may need to use an alpha bitmap (1bpp black and white, converted to an alpha mask) like we did in Islandwood's CGImage and push a layer whose opacity bitmap is this guy. [1]: Nevermind, I just saw ID2D1Geometry::CombineWithGeometry; perhaps we can just create a Rectangle geometry, combine EXCLUDE the glyph geometries, and fill that... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hey @PhMajerus, |
That was fast, thank you @DHowett \(^_^)/ |
So, it's still got some issues. I want to make sure it works on non-native-scale displays, and follows the antialiasing mode set for the font, and uh it completely breaks hinting (because we're just getting the text geometry and not letting the rasterizer at it) |
@DHowett Sorry to bother you again and mess up this issue. How can you do that? I try to use
The test below I use black as the same as the background color (#000000) and the white color as the same as the foreground color (#FFFFFF) but it seems that |
@thanhph111 Write-Host arguments were designed for the Console API, they do not translate to the VT sequences we're using here. Of course these will show black on white in the current 1.2 preview build of Windows Terminal, which is the topic of this issue thread.
|
I didn't go see your code, but since there are only two colors, and in this scenario one of them is transparent, wouldn't bit-fiddling from the positive rendering be enough (and fast if you can run that in a GPU shader) ? It seems like your final pixels can be taken from the positive rendered cell: the positive rendered alpha reversed (A2 = 255-A1) and RGB fixed to the non transparent color for the whole cell. The alpha should be all that is needed to recover the exact opposite of the shape and RGB values of transparent pixels colors won't matter, so fixing the color for all pixels except for their alpha values should be faster and more reliable than trying to reverse the RGB values. |
So for efficiency's sake, I'm trying to avoid capturing the positive render as an image and then inverting it before it goes out. There's a world where we could easily render the text in black with grayscale AA on white to a temporary bitmap target then draw through that as an alpha mask (ala CGCreateMaskImage from WinObjC above^), but going there would slay performance and introduce a lot of buffer/target churn. We're also not set up to apply pixel shaders generically, and for doing it off the GPU I'm not sure we can easily grab the backing buffer and alpha-invert just the region we care about without jumping through rather a couple hoops, either. For the best bang-for-your-buck tradeoff I'm most comfortable with the negative geometry solution... even if it does break hinting. |
This is a trick that makes the text transparent when the _background_ would have been transparent. Fixes #7014
@DHowett Are there any plans to merge your changes in a future version? |
@jales not as yet; they are insufficient right now |
relates to #529 relates to #322 relates to #497 Windors terminal and Visual Studio Code do not work well with inversted ANSI sequences. This weak allows users to override the Tranparency to the terminal background color removing black elements in their prompt. Ideally we remove this once they are on par with other terminals, but that could take a while. See microsoft/vscode#111762 and microsoft/terminal#7014
relates to #529 relates to #322 relates to #497 Windors terminal and Visual Studio Code do not work well with inversted ANSI sequences. This weak allows users to override the Tranparency to the terminal background color removing black elements in their prompt. Ideally we remove this once they are on par with other terminals, but that could take a while. See microsoft/vscode#111762 and microsoft/terminal#7014
There is info about fix this bug in 1.15.18620 changelog:
I have installed PSReadline 2.2.6 by Related discussion: JanDeDobbeleer/oh-my-posh#2555 How to fix the issue as it done in this comment?: #7014 (comment) |
I can still reproduce this as well on 1.17.1023 |
Thanks for the report! That would be because it has not yet been fixed. |
Thanks for the report! Yes, this is not machine-specific and requires explicit work in the renderer. We recently put a lot of effort into the new rendering engine, and we think that it should be possible to do this properly. |
Yep. We'll make sure to update this thread when there are updates. If someone's interested in trying to fix this themselves, we'd be more than happy to point in the right direction! |
The new Preview 1.2.2022.0 seems to fix all the VT colors issues I observed before, except one last case:
When the background color is the default (49), it is correctly kept transparent, but if the foreground color is transparent, which is possible when the background is 49 and then the colors are reversed using 7, it is rendered as black instead of transparent.
echo -e "\e[31m\u2580\e[7m\u2580\e[m"
echo -e "\e[31m\u2590\e[7m\u25A0\e[27m\u258C\e[m"
In both cases, there should be no black square, the acrylic transparency should show through instead.
The text was updated successfully, but these errors were encountered: