Ways(or Best Way) of Declaring Orthographic Projection

Hello, I am wandering what the best way to setup a orthographic projection(left, right, bottom, top) is? I know of the (-1, 1, -1, 1) way and the (0, windowWidth, windowHeight, 0) way. Are there any other know/popular ways to define it(Whats the standard)?

  • The first one means that all position coords(absolute values) would possibly need to be converted down to screen coords, eg. position [2, 1] would have to be converted to [0.2, 0.1].
  • The second would mean that i have to use large values for movement velocity(or multiply movement velocity’s by a predetermined scalar).

I could, mix both, eg. (-10, 10, -10, 10), from what i can tell this means the two points above wouldn’t be a problem.

Any suggestions or input appreciated?

There is no standard for this.
This is like asking for a standard on which skrewdriver to use. It depends on your use case.
Exactly the thoughts that you are doing right now will lead you to a solution that works best for your application/usecase.

Alright, thanks.

Why not use some sort of a virtual screen? ie, 640x480 then just scale and add letterboxes to keep aspect ratio?

From my current experience:

-1…1 approach - good if you want to maintain similar look on different resolutions. Trade-off: on large screens and resolutions graphics will look blurry unless proper precautions will be taken.
Screen width and height approach - good for UI’s, pixel art and other things that needs to be pixel perfect. Trade-off: on small resolutions UI/game area can be too small, while on large ones this can be exact opposite.

Keep in mind that you can for example render game using first approach and then switch to second projection and render UI - it is good idea to mix these two (and maybe even some other) approches. :slight_smile:

(-window_width/2, window_width/2, -window_height/2, window_height/2)

Scales properly for pixel art and keeps (0, 0) at the centre of the screen (which makes manipulating the camera easier).

Thanks, what i am going to try using is (-10f, 10f, -10f / Window.ASPECT, 10f / Window.ASPECT) i may even change the 10’s to 100’s.

So its like the -1, 1 approach but so screen coords are between 0 and 10 instead of decimal values. And then i had a squashing problem on the Y-Axis which i fixed with the ‘-10f / Window.ASPECT’’.
Also so 0 is center of screen(dunno if i will keep it like that).