Pixel perfect camera questions

Hello

I’m trying to recreate some of Enter the Gungeon’s pixel perfect features. I like that big sharp pixels, and “pixel grid” alignment. So i have two questions how to achieve simillar result.


You can notice that player character, gun, birds, shells, leaves all are 4x4 pixel grid aligned.

First question:
Camera movement in EtG is smooth. If you use upscaled render texture in Unity camera can only move in set pixel intervals, which causes bit less pleasant camera movement. You can notice on example screenshot that each pixel occupies 4x4 pixels on screen so 1920x1080 resolution is rendered to 720x480 and then upscaled. So i investigated a bit and discovered that they render to a bit bigger texture 722x482, which allows then to ‘slide’ it a couple of screen pixels depending on difference between camera actual position and grid position.


Here you can easily see that bottom and top of the screen dont actually have full pixels, thats why bigger render texture is needed.

So i think to achieve this in Unity with PixelPerfectCamera component i would need to change some source code. Change ortographic size of camera calculation, change render texture size (add additonal pixels like EtG), and calculate texture position offset. I started with trying to implement “slide” first, so i change m_Camera.pixelRect, but effect is different than expected:

By moving only x position, but not size of m_Camera.pixelRect it centers my texture in the middle, and i thought he should be cut in half (only seeing right part). What im forgetting here?

Second question:
You can notice that not all objects in EtG are pixel grid aligned. Examples are moving projectiles, UI or light. So i think at some point they upscale render texture and render other objects at screen resolution, so they are no longer bound to lower res pixel grid. How can i decide that some objects are rendered at later stage of pipeline and render on full screen resolution? They still would need to use depth data from lower resolution i guess so bullets can be drawn behind pillars or characters.


Here you can notice that projectiles are exception to grid alignment rule.


Magic bullet with orbiting blue orbs, and glowing lava are obvious examples of higher resolution rendering.

Bump,
I would also want to know how to render some things using pixel-perfect camera, and some things using the normal camera.

Second bump.

This video explains the method used.