RuntimeShader has artifacts

32 views
Skip to first unread message

zhi li

unread,
May 23, 2024, 8:21:06 AMMay 23
to skia-discuss
There are artifacts in using the blur filter + RuntimeShader, if it is only a blur filter, there is no problem. fiddle: https://fiddle.skia.org/c/9274271b148bd36d205067de1b2650d3

I also found a way that works,do not use translate,like this fiddle: https://fiddle.skia.org/c/beb2fcfa20af3bf79733ca7945109854

9274271b148bd36d205067de1b2650d3_raster.png

Michael Ludwig

unread,
May 24, 2024, 9:25:19 AMMay 24
to skia-discuss
Image filtering respects the full canvas transform as best it can while operating in an axis-aligned coordinate space. This decomposes the transform into a scaling and transform matrix that modifies the geometric properties sent to the image filter shaders, and then a remaining matrix that is applied when drawing the output of the image filter.

However, right now there's no way to convey which uniform properties of a runtime shader are "geometric" and need to be updated to match the scaling transform.  In order to respect the canvas matrix without that ability, runtime shader image filters are forced to operate without any resolution scaling and the scale factor is included in the remaining matrix. In your fiddles, it's not just a translate, but a zoom scale factor that you're including.  If you remove the zoom from the canvas matrix but instead just apply it to the blur sigma, there are no defects. That is probably the best way to work around this for now.

Reply all
Reply to author
Forward
0 new messages