Pixelated image when using SkShader, SkRuntimeImageFilter and canvas scaling

181 views
Skip to first unread message

Robert Icusca

unread,
May 17, 2022, 9:02:10 AM5/17/22
to skia-discuss
I'm drawing a image as a fill for a shape by converting the SkImage to an SkShader, using also a transform matrix so it can fit within the shape. I also apply some scale to the canvas and everything looks good. 

When I add a SkImageFilters::RuntimeShader image filter I get a pixelated image, even if the shader used shouldn't change anything. Please see: https://fiddle.skia.org/c/587e2eb957c7c5940ed8cbfc297b32fd

Something similar I get when using SkMatrixImageFilter: https://fiddle.skia.org/c/af553c062f412fd7616a96754e89bb96

Is this the expected result ? Is there any general recommendation about how  RuntimeShader  should be used ? I understand the issue can be avoided by not scaling the canvas or the shader but I would try to avoid going down this path. 

Other filters like Blur, Tile work as I expected.


William Candillon

unread,
Aug 7, 2023, 3:54:11 AM8/7/23
to skia-discuss
This is also our experience and we recommend our users to use super sampling: https://github.com/Shopify/react-native-skia/pull/1737/files#diff-33c9176aadc57001d710fe5597023caca0be18583471be7e878b0e7e0cfb67a5R55

I would also be curious to understand the reasoning of why this is necessary.

Kind regards,

William

John Stiles

unread,
Aug 9, 2023, 11:53:48 AM8/9/23
to skia-d...@googlegroups.com
I found a known bug which might explain this: https://g-issues.skia.org/issues/40044507


It seems like the workaround is to avoid transformations other than basic X/Y translation when using the runtime shader image filter.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/3f0d2f69-d274-418b-9afc-9fca636852b9n%40googlegroups.com.

William Candillon

unread,
Aug 9, 2023, 3:06:06 PM8/9/23
to skia-d...@googlegroups.com
Thank you for providing this context, this helps us to document the behaviour to our users.

Kind regards,

William

You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/AF9owdQF9g8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/CANBPXuCVu9gScCf1kGrMbf%2BBZR%3D7eCUAvVDntrA5e%2BafKvJd8g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages