Jump to content

Grabbing single images - best practices


photo

Recommended Posts

Hi,

I am currently looking into how to grab single rendered images from Unigine during the game. These images will use different resolutions and players than the main viewport, and I'll need to render them at certain times during gameplay in "batches" of about 5-20, each image from a different player perspective. I guess I can live with each image being in the same resolution for performance and memory constraints, but the resolution will definitely be different than the main viewport. In addition, I want to enable a higher SuperSampling factor for those images. Basically similar to what the VideoGrabber in Editor mode is providing, with the following constraints:

  • I need the images in memory instead of written to disk
  • Screenshot rendering needs to be finished as fast as possible, with a higher priority than even the main viewport. Ideally, I'd like to generate screenshots at a rate of close to the current FPS, though I am aware this is probably not possible because I'll probably grab the image right away and thus stall the GPU since I'm jumping to another camera for the next rendering. It would be nice though to get something like ~10 images per second if my main rendering runs at 30 fps.

I'd apprechiate some pointers on how to best implement this. Intuitively, I'd create a new Viewport with TextureRender and use this to generate the grabbed images. Specific questions regarding this:

  • Is this the best way to do it, or am I missing something?
  • Is it in your opinion possible to change the TextureRender resolution for each image and still achieve decent speed (again - I know I'll not reach maximum FPS), or is it better to stick with a single resolution for all images?
  • Most importantly: How do I handle effects that use multiple frames to converge, such as HDR Tone Mapping, TAA, SSR, Motion Blur and SSRTGI? Is there a way to force Unigine to "fully converge" the effects for a single image? I noticed that there are quite notable artifacts when changing players with Motion Blur activated during the first few frames, how can I avoid this? Is it even possible to achieve the desired image generation rate given that most effects usually require quite a few images to provide the best results?

Thanks in advance,

Florian

Link to comment

Hi Florian,

Did you have chance to check a C++ sample Screenshot? It's located in Samples -> C++ API -> Render -> Screenshot. You can modify it and keep images in memory if you want.

To handle dynamic effects (such as TAA) you need to warm-up render about 30 frames (you can adjust this value if results are not good). Because of this delay any 'fast screenshot' method will be as slow as this delay. You can also try to disable main render during the capture to gain some GPU resources.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
  • 1 month later...

Hi Silent,

thanks for the hint, the sample was quite helpful. Regarding the warm-up time, is this something that could potentially be added to Unigine? Since I'm rendering a single still image the buffers should not change anyways during this time, would be really nice to instruct the engine to simply converge all effects with the same buffers at once. Is it possible to call all post-effects responsible for TAA, Motion Blur, SSR, HDR Tonemapping etc. multiple times by myself without re-filling the GBuffers?

Another sidenote: I was struggeling a bit with the documentation of the Viewport class https://developer.unigine.com/en/docs/2.7.3/api/library/rendering/class.viewport?rlang=cpp. The first source code example results in an exception raised on the "setColorTexture" call, apparently the texture_render also needs to be initialized with texture_render->create2D(...) for this to work.

Link to comment

Hi Florian,

Quote

 Regarding the warm-up time, is this something that could potentially be added to Unigine? 

It's hard to predict this time and since the solution (wait N-frames) is relatively easy to implement I would mark this request with a minor priority. 

 

Quote

Is it possible to call all post-effects responsible for TAA, Motion Blur, SSR, HDR Tonemapping   etc. multiple times by myself without re-filling the GBuffers?

You can control rendering pipeline with render callbacks and do whatever you want after you have a GBuffers filled.

 

Quote

 Another sidenote: I was struggeling a bit with the documentation of the Viewport class https://developer.unigine.com/en/docs/2.7.3/api/library/rendering/class.viewport?rlang=cpp. The first source code example results in an exception raised on the "setColorTexture" call, apparently the texture_render also needs to be initialized with texture_render->create2D(...) for this to work.

We will check and fix the code snippets ASAP, thanks for the info!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...