[SOLVED] Screenshot in higher resolution than displayed ViewPort

Apologies in advance if this has been answered elsewhere - I searched for quite a while but couldn’t find exactly the same scenario (though some were close!).

In a nutshell: I want to take a screenshot of a ViewPort but at a higher resolution than what’s displayed.

Example: if the ViewPort is 1024 x 768, I might want a (re-rendered) screenshot at 1920 x 1080. I also don’t want the bigger size to be limited by the screen’s max resolution (e.g. I might want the image to be super-huge, say for later hi-res printing).

I assumed JME would let me create an off-screen buffer / camera combo with the higher resolution, assign them to the renderer, and then use something like the ScreenshotAppState to get the higher resolution image. But if this is possible, I can’t figure out how to do it. (I HAVE read solutions on this forum that render at a lower resolution, but that doesn’t help me.)

Any advice would be greatly appreciated!

1 Like

Someone may have a better answer but in here you can find some code that generated an off-screen tree texture atlas by rendering the trees from various directions:

It definitely used a different size frame buffer than the screen. Hopefully it’s still compatible with newer JME versions but I haven’t run it in a while (3.1 maybe?)

No reason to bother with screenshotappstate, once you have the image then it’s pretty easy to get it to disk.

Thanks for the info!

I’ve looked into stitching together smaller or same-sized buffers into a bigger image / texture map; that is definitely an option, one that the linked code appears to use (if I’m understanding it).

Ideally, though, I’m asking if it’s possible to do a single render into a higher-resolution buffer, without all the image combining.

The example renders the tree multiple times from different directions but that’s not relevant to your question. It doesn’t do any “stitching”. It just makes a big buffer and renders into it. (I mean, it makes two buffers but you can ignore the second one). The CellView stuff is just so I keep track of which tree side I’m rendering. Read past it.

This buffer could have been whatever size:

Setting up a viewport for the buffer:

Setting the scene to the viewport:

Setting up the scene for rendering in the viewport:

…the render part happens automatically by JME.

My apologies: I only looked at the code briefly and saw that there were “Cells” involved (plus, I had tiling on the brain), and completely misread what it was doing. My bad!

I could have sworn I tried the approach you listed (by changing the camera size bigger than the existing ViewPort) and it didn’t work. But I mimicked this code, and it worked! I think previously I didn’t set the ColorTexture field, and apparently that made the difference.

So, thank you very, very much!!