• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
hlee

How to save a scene in higher resolution?

21 posts in this topic

I am trying to make posters for secens from my program.  I can grab the screen by using IDirect3DDevice9::

GetBackBuffer.  However it is limited to the screen resolutions of my display, 2560x1600.  The new 4K displays can go up to 3840x2160, but even that is not good enough for large posters.  I would like to have images of 6000x4000 or higher.

 

Is this possible?  Do I need to use a software device to render in a higher resolution than the display?  If so, how?

0

Share this post


Link to post
Share on other sites

When choosing to capture a frame, you could wait to next frame (and activate some kind of trigger), then resize the display to something bigger, and then capture the frame?

 

If you have dynamic resolution on e.g. ssao... Then you could multiply each single resolution by f each frame, which you can change, to a higher/lower value when needed.

 

PS. Sorry if this is a bit messy, but it's a bit late over here. happy.png

Edited by Migi0027
0

Share this post


Link to post
Share on other sites

Migi0027, thanks for the suggestion, but how do you resize the display beyond the capability of the harware?  Which resizing function should I call?

0

Share this post


Link to post
Share on other sites

If you want to support arbitrary resolutions and not be limited by either the size of the viewport or the render target, there are two possibilities I know of:

 

1) render the scene in tiles, e.g. 2x2, 3x3, 4x4, altering view- and projection-matrices accordingly, stitching together the results of the different renders.

2) use subpixel rendering, more or less. there's a bit of information here, and there's an article in game programming gems 4 as well.

 

note that both methods will likely cause problems with fullscreen effects, which have to be treated separately. your renderer/engine needs to be aware of the fact that it renders high-resolution screenshots, and e.g. treat all fullscreen effects differently.

 

hth,

-tiv

2

Share this post


Link to post
Share on other sites

I'm guessing that you can change the back buffer size to the size you want for the screenshot and capture the scene then return the back buffer size to its initial size.

0

Share this post


Link to post
Share on other sites

@Ravyne,  I've tried your suggestions and created a temporary render target with larger surface, but it does not work.  The rendered scene is clipped to the same size as the backbuffer.

 

@Medo3337, how can I change the backbuffer size?  I use DXUTCreateDevice to create the D3D device, which limits the width/height to the maximums of the display adapter.  SetViewport does not change the backbuffer either.

0

Share this post


Link to post
Share on other sites

@Ravyne,  I've tried your suggestions and created a temporary render target with larger surface, but it does not work.  The rendered scene is clipped to the same size as the backbuffer.

 

 

Did you adjust your projection to fill the render target?

0

Share this post


Link to post
Share on other sites


Did you adjust your projection to fill the render target?

 

Yes.  I get the whole scene if the render target is smaller than the adapter limit.  Larger, then the scene is clipped.

0

Share this post


Link to post
Share on other sites

D3D definitely supports rendering to targets that are bigger than the screen. I suspect your problem is one of:

 

- Your depth buffer is smaller than the render target. You'll need an appropriately sized one of those as well.

- Scissor rectangle is too small.

- Viewport is too small.

2

Share this post


Link to post
Share on other sites


D3D definitely supports rendering to targets that are bigger than the screen. I suspect your problem is one of:

You are absolutely right about the depth buffer.  After creating a depth stencil surface that matches the render target I can now get the full frame.  Thank you so much!

 

However, MultiSampleType must be set to D3DMULTISAMPLE_NONE for the render target, otherwise the GetRenderTargetData would return D3DERR_INVALIDCALL.  Without multisample I might as well just capture the screen with a lower resolution but with anti-aliasing.  Is there a way to use multisample in this method?

0

Share this post


Link to post
Share on other sites

Well, I don't know what extra advice to give you that hasn't been said before, but you have inspired me to add a super screenshot mode to my engine. A special hotkey that when pressed will save a superb quality screenshot with normal or super-high quality/resolution. I'm estimating that at the highest quality setting the engine will consume about 2 GiB or RAM and spend 5-10 second creating one screenshot smile.png.

 

I'll let you know how it turns out.

Edited by DwarvesH
0

Share this post


Link to post
Share on other sites

Great.  Let me know how you do it and if you can turn on anti-aliasing in the high resolution screenshot.

0

Share this post


Link to post
Share on other sites

If you look at the documentation for GetRenderTargetData() you'll see:

 

 

This method will fail if:

  • The render target is multisampled.

 

The standard solution to that is to use StretchRect() to copy it to a non-multisampled render target.

 

However in your case I'd just increase the resolution and downsize the result in some image editing software - you'll get better quality that way.

0

Share this post


Link to post
Share on other sites


The standard solution to that is to use StretchRect() to copy it to a non-multisampled render target.

That's it!  This is what works:

1. Create a large multisampled RT, called it RT1, along with a depth buffer

2. Render the scene to RT1

3. Create a non-multisampled RT, called it RT2, the same size as RT1

4. StretchRect RT1 to RT2

5. Use GetRenderTargetData to copy RT2 to an OffscreenPlainSurce

6. Use D3DXSaveSurfaceToFile to save the OffscreenPlainSurce

 

Now I get a high resolution, multiampled scene.  Thanks so much, Adam!

 

But why does it have to be so cumbersome?  Why can't D3DXSaveSurfaceToFile save a mutisampled RT directly?

0

Share this post


Link to post
Share on other sites

The way multisampling works is that D3D internally creates an extra large render target and depth buffer (e.g. for 4X it's double the width and height).

 

However, when rendering to it the pixel shader isn't re-run for each extra pixel, but the depth test is. That gives significantly better performance than rendering to a double sized render target, at the cost of a bit of quality - it won't solve aliasing that's caused by the shader, which manually rendering at double the size then downsizing will do.

 

There's usually also some hardware trickery in there to accelerate the common case where all of the antialiased samples for one output pixel are identical by storing the data a bit differently.

 

The shader aliasing is why I said you want to just render to a bigger texture and downsize it yourself. Doing that also means you need less GPU memory.

 

The reason you need the StretchRect() step is that the GPU needs to decode and downsize the extra large render target to an antialiased one of the right size before you can read it back with either a shader or the CPU.

0

Share this post


Link to post
Share on other sites

StrechRect will work, but will probably perform poorly. You are effectively using SSAA at this point and there is a good reason most games don't offer this option.

 

But since you want to capture screenshots, I would recommend rendering your high resolution texture as a full screen quad and using high quality down-sampling filter implemented in the pixel shader. Or do it in an external program once the screenshot is saved.

0

Share this post


Link to post
Share on other sites

5. Use D3DXSaveTextureToFile to save RT2 directly to a file

D3DXSaveTextureToFile complains that RT2 is not a texture.  If I'd created RT2 as a texture then StrectRec would complain that RT2 is not a IDirect3DSurface9.  How can I make it to work?

0

Share this post


Link to post
Share on other sites

How about using D3DXSaveSurfaceToFile wink.png

That works!  I thought D3DXSaveSurfaceToFile requires the source being OffscreenPlainSurface.

 

That's one step saved.  I still think it is unnecessarily cumbersome.  Maybe D3D11 provide a more efficient method?

0

Share this post


Link to post
Share on other sites

 

How about using D3DXSaveSurfaceToFile wink.png

That works!  I thought D3DXSaveSurfaceToFile requires the source being OffscreenPlainSurface.

 

That's one step saved.  I still think it is unnecessarily cumbersome.  Maybe D3D11 provide a more efficient method?

 

Just noticed a side effect of skipping the step: the maximum resolution is reduced !

 

Somehow, by copying RT2 to an OffscreenPlainSurface before D3DXSaveSurfaceToFile, I can save a frame with higher resolution.  Does anyone have an explanation?

 

Since efficiency is not a concern for my purpose, I will add the step back.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0