Forum

Skia png image moire pattern on gradient

Hi, since preview version 4.0 - 282 the glow gradient is shown wrong. Moire effect and brighter than it should. the png is loaded with skia drawimage and transfered into a stride renderer. I’ll paste an example

skia test.zip (33.7 KB)

hey there!

Sorrily, it seems that transparency combined with a linear color space is a tricky topic. Not only in vvvv.

I am unsure why this problem didn’t surface with the old SkiaRenderer implementation, but now the SkiaRenderer is working on all graphics hardware. So that’s a big plus and we very likely will stick with that new implementation surfacing this new behavior.

I attached a modified version of your patch. It shows that if you go for gamma color space the problems vanish. For 2d applications, this is probably the way to go: skia test gamma color space.zip (39.0 KB)
If you want to have 3d app with high-quality lighting then linear color space is best. That’s also the reason why we use linear color space as the default.

We are still searching for elegant ways to combine the best of the two worlds. And we are not the only ones struggling with this topic as can be witnesses here: https://forum.unity.com/threads/urp-raw-image-transparency-problem-linear-vs-gamma-color-space.865603/
Anyway, if switching your whole app to gamma color space is an option for you then this is the easiest way out.

When working with linear color space you can see that this problem surfaces regardless of whether you use file textures (stride-only approach) or via SkiaRenderer. So our guess is that we need to find a solution that covers all those scenarios and it’s not so much a bug of the SkiaRenderer. But again: we are aware of the general issue and still trying to find a solution that may cover all the cases where transparency and linear color space get combined.

Hope that helps, sorry for the trouble.
Edit: note that this patch uses a node SetColorSpace that only is available in the newest gamma preview.

1 Like

I know it’s (probably a lot) more work to maintain, but if the old one deals with this scenario correctly I suggest you should keep them both. At least until the Angle implementation catches up (or it is possible to render a nice 2d GUI with text in stride on top of a 3d scene). In a lot of cases 2d/3d is not either or, but both.

there is an even easier solution, prepare the files for usage in linear space! unfortunately, photoshop doesn’t handle gamma correctly by default, but this can be adjusted, as you can read in numerous online debates. GIMP should do it correctly, by default.

in this particular case, the alpha is saved in sRGB space, which is even against the PNG specification… so it expects the viewing application to work in sRGB space as well.

however, we can add an input pin called “Alpha Is sRGB” to the FileTexture and this can then be adjusted when loading the file. in Skia this is a bit trickier, we don’t know yet where we could add such a feature. in the worst-case scenario, we have to modify the image data before handing it over to Skia.

2 Likes

thanks for your feedback. gregsn version with the gamma space works good.

Would be nice to have some (vvvv specific) step by step tutorial / blogpost / HowTo patch on how to do that.

1 Like

yes, an asset test patch is a good idea.

however, it still needs an option to tell the engine in what space the alpha channel is because you don’t always have access to the source material.

If I paste my hole application into this workaround I get several error messages
grafik

I just pasted the VideoPlayer help patch playing the https://durian.blender.org/download/ trailer video into that region using Gamma color space and it works just fine. Can you give us more details please? Or even upload a patch if possible?