Grotius

Hi there,

I've made a couple of games in GSE now, and in each case I programmed the game in 800 x 600, which is rather silly given that I have a monitor that supports resolutions all the way up to 2560x1600. I understand that I can get the user's window size and adjust my game to fit it at startup, though I haven't really played with that yet. But what about textures Is the best practice to include one texture for "maximum" resolution and then let Windows scale it down to size depending on the user's window size Or do developers include several copies of the same texture for different resolutions

Likewise, I'm wondering how to handle different aspect ratios. To release a game that supports both 4:3 and "widescreen" modes, presumably one has to include art assets that come in those different shapes Or not

Many thanks for any general advice on this. It strikes me as the sort of thing I'd better sort out before I get too far into making textures for a game that I want to support multiple resolutions and aspect ratios.



Re: XNA Game Studio Express Newb question: different textures for different resolutions?

Jim Perry

You're talking about mipmaps. You might want to start here. I haven't seen much on doing it in XNA, unless it's done automatically. The Texture class has a GenerateMipMaps method. There's also the SamplerState class and SamplerStates collection of the graphics device to look into.




Re: XNA Game Studio Express Newb question: different textures for different resolutions?

Jon Watte

If there is memory on the graphics card for the higher-resolution textures, there's (almost) no penalty in uploading the high-resolution textures, even if the top level MIP map never gets used. This is assuming that your textures are MIP mapped (which they should be).

For different aspect ratios, you usually compensate using the projection matrix. You have the choice of letting widescreen see more than 4:3 sideways, or see less than 4:3 up/down. Or perhaps a blend of both. No new assets needed.

Some peple develop two or three sets of UI bitmaps, though, to avoid a filtered look. Then they choose the UI bitmaps that best fit the current screen resolution.

If you do not have space for the high-resolution textures on all graphics cards, then you can load each texture, then create a new texture with one less MIP map, and copy the surfaces from the loaded texture into the new texture, dropping the top level MIP map. Then delete the loaded texture. This allows you to adapt to available memory, without having to ship two sets of assets.






Re: XNA Game Studio Express Newb question: different textures for different resolutions?

Grotius

Many thanks for those helpful replies. The Wikipedia link led me to lots of useful info on mipmaps in 3D games. I'm still pretty new, so I was thinking of 2D applications more than 3D. Still, I gather mipmaps can be used for, say, a wargame screen that you want to present at different resolutions

Jim Perry wrote:
The Texture class has a GenerateMipMaps method.

I'll check it out. So are mipmapped textures generally generated by code, as opposed to being created in Photoshop or 3ds Max or whatnot





Re: XNA Game Studio Express Newb question: different textures for different resolutions?

Grotius

Thanks for your reply, Jon. On aspect ratios, I think you're talking about solutions for 3D games -- change the projection matrix. (I haven't done much 3D yet, but I have played with projection and view.) How about in 2D games Just change the viewport dimensions to accommodate different screens When I play many hex-based wargames, they end up looking stretched horizontally on my widescreen -- an effect I'd like to avoid for my game.



Re: XNA Game Studio Express Newb question: different textures for different resolutions?

Jon Watte

Games in 2D stretch if you assume that they're always X pixels wide by Y pixels tall. If you tell the ortho projection matrix that the screen is X by Y pixels where X and Y are the actual resolution, then the data will not stretch. However, you'll see more on a higher-resolution display.

To solve that problem, you decide that the screen is supposed to be H virtual pixels tall. Then, when you get the real resolution, you tell the matrix that the screen is H pixels tall, and H * Y / X pixels wide. You'll still get a slight improvement in field of view on widescreen displays, but the aspect ratio will be correct.






Re: XNA Game Studio Express Newb question: different textures for different resolutions?

Grotius

Thanks, Jon. I'll try that.

Back to mipmapped textures: I gather these are generated by programmers, not artists I can't find any reference to mipmapping at all in Photoshop's docs.





Re: XNA Game Studio Express Newb question: different textures for different resolutions?

j0hn00

Did you have any luck with this I would really appreciate a sample of the code if you did. Thanks!




Re: XNA Game Studio Express Newb question: different textures for different resolutions?

Jon Watte

The easiest way to generate MIP maps is to save out to DDS format using the NVIDIA Photoshop DXT plug-in. It has an option to "generate MIP maps" using a variety of filters, alpha and fading options.

When going straight to game, you typically want to generate DDS files in DXT5 or DXT1 formats; when going to the content pipeline, you might want to save in plain RGBA format to preserve quality.