Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


How to save a scene in higher resolution?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
21 replies to this topic

#1 hlee   Members   -  Reputation: 115

Like
0Likes
Like

Posted 06 September 2013 - 01:41 PM

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?



Sponsor:

#2 Migi0027 =A=   Crossbones+   -  Reputation: 1971

Like
0Likes
Like

Posted 06 September 2013 - 01:49 PM

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, 06 September 2013 - 02:01 PM.

Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to steal all their shaders!


#3 hlee   Members   -  Reputation: 115

Like
0Likes
Like

Posted 06 September 2013 - 02:21 PM

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



#4 Ravyne   GDNet+   -  Reputation: 7810

Like
3Likes
Like

Posted 06 September 2013 - 02:57 PM

You can render to a render-target, then you'll only be limited by the max texture size, rather than the display resolution, I believe -- to 8k+. If you want to go even larger, you can render in multiple sections at some high resolution. Bungie used to do this on their servers for premium bungie.net members (you could take a high-res shot from a captured gameplay video). You have to mess with the frustum/projection I think, since it becomes non-uniform. I think they may have done a whitepaper on how they did it.



#5 tivolo   Members   -  Reputation: 969

Like
2Likes
Like

Posted 07 September 2013 - 08:17 AM

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



#6 Medo3337   Members   -  Reputation: 674

Like
0Likes
Like

Posted 07 September 2013 - 08:54 AM

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.



#7 hlee   Members   -  Reputation: 115

Like
0Likes
Like

Posted 10 September 2013 - 01:28 PM

@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.



#8 Ravyne   GDNet+   -  Reputation: 7810

Like
0Likes
Like

Posted 10 September 2013 - 02:14 PM

@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?



#9 hlee   Members   -  Reputation: 115

Like
0Likes
Like

Posted 10 September 2013 - 05:13 PM


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.



#10 Adam_42   Crossbones+   -  Reputation: 2573

Like
2Likes
Like

Posted 10 September 2013 - 06:16 PM

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.



#11 hlee   Members   -  Reputation: 115

Like
0Likes
Like

Posted 11 September 2013 - 04:48 PM


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?



#12 DwarvesH   Members   -  Reputation: 471

Like
0Likes
Like

Posted 12 September 2013 - 09:14 AM

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, 12 September 2013 - 09:14 AM.


#13 hlee   Members   -  Reputation: 115

Like
0Likes
Like

Posted 12 September 2013 - 11:41 AM

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



#14 Adam_42   Crossbones+   -  Reputation: 2573

Like
0Likes
Like

Posted 12 September 2013 - 12:30 PM

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.



#15 hlee   Members   -  Reputation: 115

Like
0Likes
Like

Posted 12 September 2013 - 04:17 PM


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?



#16 Adam_42   Crossbones+   -  Reputation: 2573

Like
0Likes
Like

Posted 12 September 2013 - 05:03 PM

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.



#17 DwarvesH   Members   -  Reputation: 471

Like
0Likes
Like

Posted 13 September 2013 - 01:08 PM

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.



#18 Scoob Droolins   Members   -  Reputation: 238

Like
0Likes
Like

Posted 15 September 2013 - 11:06 AM

5. Use D3DXSaveTextureToFile to save RT2 directly to a file



#19 hlee   Members   -  Reputation: 115

Like
0Likes
Like

Posted 17 September 2013 - 02:59 PM

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?



#20 unbird   Crossbones+   -  Reputation: 5589

Like
0Likes
Like

Posted 17 September 2013 - 03:49 PM

How about using D3DXSaveSurfaceToFile wink.png




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS