I’m working on a 2D Pixel Perfect game and realizing that I know very little about fixed aspect ratios and making a game work on all screen sizes. I’m looking for general knowledge and best practices on the proper way to keep a game at 4:3 on any (as many as possible) screen while allowing Letterboxing and Pillarboxing.
The below settings appear to be working, and the game’s composition/visible area seems to stay consistent as I resize the window. But, I’m still unsure if that’s really all there is to it. Are there any other things that I should be taking into consideration?
Pixel Perfect Camera Settings
Assets Pixels Per Unit: 16 (same as all of the sprites)
Reference Resolution: 4:3
Crop Frame: Stretch Fill
Filter Mode: Retro AA
Are there downsides to using Stretch Fill such as pixel quality loss? It’s the only way I could get the Pixel Perfect Camera to add both Pillar or Letterboxing based on the size of the window. But I’ve read that Stretch Fill can cause pixels to skew/warp a bit.
Project Settings - Resolution and Presentation
Default is Native Resolution: FALSE
Default Screen Width: 1920
Default Screen Height: 1440
I went with 1920x1440 so that it would launch at a reasonable size if not in full-screen.
Really what it is that I’m trying to solve is the shimmer that happens when the camera moves. Everything seems to have a shimmering heat wave effect as the camera moves. Form what I understand that’s due to sub-pixel movement. After investigating, it sounded like I needed to use the pixel perfect camera so that everything would be more clear and move in whole pixel increments.
I have an artist making the pixel art on a 16x16 grid at resolution of 240 x 180. And I’m not scaling any of the assets when I bring them into Unity and set their PPU to 16. I’ve also set up my grid in Unity to be 1/16 (.0625) so that I can ensure my game objects are snapped to the pixel grid.
I guess in short, “pixel perfect” to me is ensuring that all of the pixels line up to avoid any artifacts or distortion for a crisp visual.
You sure this isn’t just the monitor’s afterglow effect?
This can also happen, or even worsen, on high-end variable framerate gaming monitors. Some settings, particularly overdrive or “fast response” and such settings can pronounce contrast, oversharpen edges and cause afterglow.
Try setting up a black screen and let some white pixels float by at a constant rate. Just to see what the monitor does to moving pixels.
I’m not sure if that’s the case. I can give your test a shot and see what happens. I do know that when characters move and I’m still it doesn’t appear to happen. It seems to be only when the camera is moving.
Here’s an example of the white lines moving. It’s not near as jumpy in real-time. The recording adds some jitter to it, but the sort of glow that trails each white line is definitely there. Is that what you were referring to when you said “monitor afterglow”?
I would say so. The video looks perfectly alright to me. I’d have to look at it again on my desktop though. My Macbook screen is really good so there’s practically no afterglow in these lines. And the rest is just the brainfuck that makes me dizzy and even see thinner black bars within the white lines. Oh brains, brains …
This looks like aliasing of sorts. The gridded lines get thinner for a split second. I think this may be due to Camera movement not being pixel aligned or else the camera movement would feel choppy.
You could try disabling camera movement damping so that the camera follows the character instantly without dragging behind for a bit.
You can also give the camera a deadzone because it adjust even when the character simply looks in a different direction.
I’m assuming you’re using Cinemachine. If not you should use that because it also has a pixel-perfect component.
Yeah, I’m using Cinemachine. I actually discover that when using the Pixel Perfect Camera component (even with Cinemachine) you also can’t zoom properly due to the way the pixels all need to stay proper sizes. So what I’ve done is the following and I think it’ll work for me.
Completely ditch the Pixel Perfect Component
Set Damping to 0
Clean up my player movement to use Rigidbody2D.MoveTwoards vs RigidBody2D.setvelocity since I’m no really needing any physics
Ensure that every single one of my game objects is snapped to the pixel grid I divided Unity’s Scene grid setting by 16 (1/16 = 0.0625) so that the grid works with my 16 PPU sprites.
Used a custom LetterBoxer/PillarBoxer script to enforce the 4:3 aspect ratio rather than using the Pixel Perfect Camera Crop mode.
Everything seems pretty solid now with no pixel distortion. I can go ahead and close this ticket since any additional questions for aspect rations and resolutions will no longer directly related to using the Pixel Perfect Camera.