Hi,
when I add a blend (transparency) to a model with multiple meshes, the z-sorting is lost.
If I use Cutoff instead of Blend, as suggested here, it has no effect.
I still have a question about transparency:
When I put a transparent black layer over my scene, the colors under the layer increase in intensity instead of decreasing.
This behaves similar to Photoshop when the layer is set to āoverlayā instead of ānormalā.
here is a demo patch: Transparency.vl (20.4 KB)
A sphere of 100% white overlaid with 90% black. The sphere should be rendered with 10% white, but it is 33%.
In your screenshot youāre sampling from the CMYK color model. Have you tried the same with RGB and also making sure your document has the correct color settings before pasting it in?
Another thing might be the whole color thing in Stride, where it might not exactly work as youāre expecting it to work. @motzi was cooking something up on this ā¦
i had a look and it seems, you have a wonderful clash of sRGB/linear conversion and wrong expectations of AlphaBlending here, but the math is right (as can be seen from the output of the pipet. the problem is: this output is in linear space and not in sRGB space that is shown on screen (which is the origin of the problem).
i can give you only a short answer right now of what i think is happening:
overlaying the black texture with alpha in stride happens in linear space. since the color comes from Skia (which works in sRGB space) it will be gamma corrected automatically when converting from Skia to Stride. the problem is: this will only happen for the RGB components, not the alpha. but our RGB components are all zero/black, so no effect of the conversion will be visible.
AlphaBlending just does a weighted adding of RGB of the destination (whats there already) and RGB source (what will be painted over it). usually those weights come from the sourceās alpha channel or its inverse - but they will manipulate colors. two issues arise:
the alpha was not gamma corrected before, the results of the weighting will be wrong
your aim is to reduce the destination intensity, however AlphaBlending is about weighing colors and adding them. so standard AlphaBlending might not have been the right method to begin with.
so here is a quirky solution that seemingly produces the right/expected results for sRGB. iām using a different blend mode here that weighs the destination color with the source alpha (which is what you actually want to achieve, if iām right). also, i assume the alpha value to be not black with 90% opacity but rather to be the inverse (10%) of the original color that should pass through. i guess this here only works under this assumption (so donāt use colorized overlays, just black with alpha).
here you go, sorry iām too tired now for longer explanations in the patch. Transparency_2.vl (52.0 KB)
PS: iād be curious if there is a more elegant solution to thisā¦
thatās what I did initially. however, when looking for a way to only darken where only the overlay texture is visible (in cases where this is a partial mask and not covering the screen fully), this approach fails as it applys it on everything. therefore i wanted to see if there is a āblend onlyā solution and thatās what I got. (also blend-only should make it cheaper compared to the TFX).
not sure if āwrongā is the right word - i think the math is right. itās just unexpected considering there are many more things going on here compared to photoshop (which, iirc, also did not blend correctly for a long time).
indeed, this is where the second unexpected thing kicks in - the way that AlphaBlending works does not fit for this usecase. hereās the formula again:
simplified for this case where Src.RGB is black/zero:
Color = Dst.RGB * (1 - Src.A)
so the resulting color will be weight by the inverse of the alpha of the black overlay.
in the end it just means, weāre darkening by some amount (which happens in linear space). however, for the Src.A, no automatic gamma conversion is applied (unlike for Src.RGB), so we have to do this manually to get the expected darkening of the color.
therefore created my own blend mode that looks like this:
Color = ONE* Src.RGB + Dst.RGB * (Src.A)
// ONE* Src.RGB will be zero for black
but Src.A will be gamma2linear(1-Src.A).
this works as the idea is just to darken existing pixels with gamma correction applied to the alpha.