Sprite lines are drawn in different sizes

Hello

I have a grid that I have for a board game that I am making, but I have a problem, the lines are drawn in different sizes in the game view and in the game build, I attach an example.

9781122--1402644--Screenshot 2024-04-19 105958.png

The lines are created dynamically as spriteRenderers with the scale modified for example new Vector (2px, board size) or (board size, 2px) for vertical or horizontal. AT first I tried to do it in the UI, but it causes a lot of performance problems on large boards (greater than 20, usually my boards are 50x50).

I don’t know what this effect is called (is it jittering??? Moiré pattern??), I have tried using the PixelPerfectCamera component on my main camera, I adjusted the settings as follows and it seems to work, but in other resolutions it paints the dashboard another size, plus I lost the ability to zoom (modify the ‘size’ property of my main camera)

9781122--1402647--Screenshot 2024-04-19 112000.png

Is there a way without using PixelPerfectCamera? If it can only be solved this way, how should I configure it to work in other resolutions. I also tried to indicate the current resolution, but I don’t know how I can calculate ‘Assets Pixels Per Unit’.

Thanks in advance.

You mentioned it works with some resolutions. Are you scaling up or down the resolution in the game view? The size of the grid likely will only be even when at screen sizes that are multiples of your original 1920x1080 resolution. Resizing the screen/game view, especially using the pixel perfect camera tends to cause problems. It tries to keep everything consistent but when you “zoom in” its forced to change it to fit. You might want to just use a set number of few resolutions that keep your art aligned instead of having a dynamic resolution.

What I do is via script assign the current resolution, usually 1920x1080, but in tests with 1360x768 and others, the drawing looks much larger, so I manually adjust ‘Assets Pixel per Unit’ and they look approximately fine, except that since use integers sometimes there is no number that satisfies the appropriate size that should be displayed, for example if I assign a 15 it looks too small and with 16 it looks too big

I make the assignment in the following way:
pixelPerfectCamera.assetsPPU = 80;
pixelPerfectCamera.refResolutionX = (int)w;
pixelPerfectCamera.refResolutionY = (int)h;

But the number 80 in 1920x1080 was just a number I “found” by doing trial and error in the editor. But there are too many resolutions for me to explore every possibility, how would I calculate this value?

Or is there another way without using PixelPerfect?