1
\$\begingroup\$

I'm developing a game similar to Don't Starve - 2D billboards in a 3D world. Now I have encountered a problem with resolutions. I want the player to be able to change resolution, but I don't want to change how much of the world that can be seen on screen. This is how it works in Don't Starve.

So will the resolution just decide the size of the textures? Do I use a set internal resolution and then scale the textures according to the resolution? Do I then need to scale the world coordinates?

I want the field of view to be the same and also so the camera angle(it's looking down with an angle as in most strategy games). I might also mention I'm coding with Monogame.

\$\endgroup\$
1
\$\begingroup\$

A GPU works in screen-space coordinates which go from -1~1 for both x and y dimensions. The projection matrix (in combination with the view matrix) takes care of how 3D world coordinates are mapped onto two-dimensional screen space coordinates.

If you use the same field of view and aspect ratio for each resolution the player will never see more (or less) than he/she is supposed to. When you've designed your game for an aspect ratio of 16:9 (for example 1920x1080 resolution) some things might look stretched when the user selects a resolution with a different aspect ratio (for example 800x600 is a 4:3 aspect ratio). In this case you will need to add some post processing to un-stretch the image and add black bars on the top and bottom of the screen.

Now I don't know how you draw your 2D billboards. Do you by-pass the viewprojection matrix? If you're using the sprite batch to draw the billboards you will need to add your own math to address this problem as the sprite batch uses the resolution directly to position the sprite. Note you can add a Matrix to SpriteBatch.Begin() to transform all your sprites!

By the way:

See the related questions on the right, such as:

(Note the links I gave are for XNA, but Monogame is a direct port of it so all concepts there are valid for you as well)

\$\endgroup\$
  • \$\begingroup\$ Thank you, I learned a lot from your explanation. I draw my billboard with a custom shader. I actually had it half working, it was my graphics card drivers that made it look strange in fullscreen mode. You pointed me the right way =) \$\endgroup\$ – wheelinlight Jul 5 '14 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.