How do you achieve resolution independence?

Started by
12 comments, last by BornToCode 11 years, 2 months ago

The way i have handle that in my 2d engine i wrote 2 years ago whas to rendered the whole screen into an texture. then Create a Screen aligned quad that is the same size as the display you want. Then apply the texture to fit the whole quad. That way you can always render your game in an 800x600 resolution and you can upscale or downscale with that technique.

That will still cause you to have aspect ratio artifacts when it changes from 4:3 to 16:9 or 16:10 or anything else though. Your best bet is to render into a -1..1 range for your render target and then use the projection matrix on the rendertarget and final render to correct how square the pixels in each step need to be.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

Advertisement

Or apply the aspect ratio to the width or height (depending on whether you rely on horizontal fov or vertical) to correct it. For example if (like most games these days) your 16:9 image sees more on the sides than a 4:3 image, apply w/h to h to get a correct, square result.

Why not just use an ortho projection? Build the correct projection matrix, load it, draw. There's no rule that says that the inputs to such a projection must be the same as your screen resolution, so you can use this to achieve a virtual coordinate system entirely on the GPU. Dear old Quake did it in 1996, you can do it today.

@NormanBarrows : video RAM is not slow. Transfers between the two different types of memory (system and video) can be slow, but if everything is kept in video RAM all of the time it is not slow. Why else do you think vertex buffers, texture objects, etc exist?

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

The way i have handle that in my 2d engine i wrote 2 years ago whas to rendered the whole screen into an texture. then Create a Screen aligned quad that is the same size as the display you want. Then apply the texture to fit the whole quad. That way you can always render your game in an 800x600 resolution and you can upscale or downscale with that technique.

That will still cause you to have aspect ratio artifacts when it changes from 4:3 to 16:9 or 16:10 or anything else though. Your best bet is to render into a -1..1 range for your render target and then use the projection matrix on the rendertarget and final render to correct how square the pixels in each step need to be.

That makes no sense, because first of all when you render your quad to be screen aligned you will need to set up an orthographic projection which will use the screen resolution. So when you create your quad that is the same Width and Height as your resolution it will be an 1:1 representation, so when you apply the texture it will mapped 1:1 as well. So i do not see the scale issue you are talking about.

This topic is closed to new replies.

Advertisement