Home | Documentation | Atomic Chat | Github

PIXEL_SIZE and Ortho Cameras


#1

In most 2D engines I’ve seen, the user can easily and intuitively set their virtual screen to something like 800x600 and then design to that.

Atomic goes a very different route with all sizes being multiplied by 0.01, and requiring “Orthographic Size” and “Aspect Ratio”. In the end, the numbers are all basically the same, but this seems much less intuitive. Additionally, you need to keep the PIXEL_SIZE scaling in mind so that your assets are 800x600, but your world is 8x6.

Is there some reason I’m missing for the PIXEL_SIZE scaling?


#2

Are you talking about pixel-perfect rendering?
I don’t see the problem in using some arbitrary scale (preferably approximately 1unit=1meter because of physics) and adjusting your camera to deal with different aspect ratios, but I’m not 100% sure if I’m getting your point.
If you’re talking about using screen coordinates (Cocos/XNA) you could easily convert to it… back in my blitzbasic days “virtual resolution” was a feature that allowed you to display a stretched render on a higher resolution screen, mostly used for pixel art games, and can easily be achieved by using a render texture in other engines.
Pixel perfect is probably going to be a bit annoying though.


#3

PIXEL_SIZE is a constant which maps pixels to world coordinates, to keep the numbers within a range that mixes well with 3D content (which is also provided by the scene, unlike pure 2D solutions). It also keeps Box2D physics coordinates in the recommended range for accuracy.


#4

One other note, completely agree that this constant shouldn’t be exposed in public API or required in user code. It is inherited from upstream and if you find in files for it, it isn’t sprinkled through the core 2D enough to make that a terribly difficult refactor.