Need suggestions on how to solve uneven pixels on sprites

So, I’m having a problem on the pixel perfect side of things for sprites, both normal and UI. The fact is that I’m using a fixed scale to have all sprites have the same scale on different resolution, using the Canvas Scaler for UI and doing the same calculation for the orthographic camera.

Now tthe problem only occur on certain resolutions, for some weird reason is all fine on 1920x1080, but my fixed resolution is on 320x240 so sit should scale better on 1024x768 but isn’t the case.

Here a screenshot to show the issue:

I f you look closer both fonts and certain sprite elements are not scaled correctly. Can be seen especially on the health bar, each fragment is of different effective pixel sizes.

For the font I use a non dynamic font, that I import at runtime reading from external files, is a pixel perfect font that is never scaled and all the components are set t obe a fontSize of 16. If I zoom in the scene editor window all sprites and fonts are fine, is just the rescaling of resolution that mess things up.

I tried many approaches to avoid that, messing with Match width and height on the canvas scaler, trying to recalculate half pixel offset and all that, but to no result. The Canvas Scaler is set to fixed scale of 320x240 iwth a pixel to unit reference of 32. The same goes for orthographic camera, I do this simple operation to calculate the size:

fixedResolution.height / pixelsToUnit / 2; beign in my case 240/32/2.

What kind of approach should I use to fix the jagged pixels on the sprites?

I was going to suggest it looks like you’re on an lcd/led screen, and the native resolution isn’t able to exactly scale as a multiple, to fit into 1920… so some pixel columns/rows are doubling up, which is normal. But then, this is a screen grab and internally this doesn’t apply.

Most likely the width of the sprite in terms of how many pixels it is, versus how many pixels the geometry is spanning, are different, and this can happen with pixel snap on because it calculates on a per-vertex basis and not on a maintain the exact number of pixels width and height basis, in the shader.

Could be that sprites are of no power of two size? For example the health frame is 70x15 and the meter 29x7. Rect transform positions are all rounded, so no float offset there.

Is pixel snap activated as default? As I’m not using any material for the sprites, just the standard sprite diffuse and I’m not sure if is set to pixel snap.