How to correctly match sprite resolution to pixelation of a shader?

I’m pixelating a gradient noise that is applied to an outline shader, but I’m having a hard time figuring out how to match the resolution of the pixelation to the resolution of the sprite itself.


(The resulting pixelated UV is connected to a gradient noise outside of the screenshot)

As you can see, using the sprite height makes the pixels match in height but not in width, while using width leads to inverse results.
I’m trying to figure out a way to get the pixels to match any sprite that the shader is applied to. Achieving my desired effect is easy on a square sprite, but a rectangular sprite is where I get lost on how to do it. (In this example, the sprite is 64x80)

Thanks in advance.

I found a way to fix it. By dividing the width by the height and the height by the height and using that as tiling values for the UV, you get a perfect match in aspect ration for any sprite! (You can then use anything for the scale of pixelation, I chose to use the height)

1 Like