Render to target and save to files with high resolution.

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
lvgeng
Posts: 38
Joined: Fri Aug 14, 2015 4:35 pm

Render to target and save to files with high resolution.

Post by lvgeng »

Hi there I am here again. Recently I was trying to render high resolution version of the scene and save them to files.
I was using trunk.
Here is how I define the render target.

Code: Select all

    video::IRenderTarget* renderTargetAllSubimages = 0;
    video::ITexture* renderTargetTex = 0;
    scene::ICameraSceneNode* fixedCam = 0;
    renderTargetTex = videoDriver->addRenderTargetTexture(core::dimension2d<u32>(initialParametres->widthOfRenderzoneByPixel, initialParametres->heightOfRenderzoneByPixel), "RTT1", video::ECF_A8R8G8B8);
    video::ITexture* renderTargetDepth = videoDriver->addRenderTargetTexture(core::dimension2d<u32>(initialParametres->widthOfRenderzoneByPixel, initialParametres->heightOfRenderzoneByPixel), "DepthStencil", video::ECF_D24S8);
    renderTargetAllSubimages = videoDriver->addRenderTarget();
    renderTargetAllSubimages->setTexture(renderTargetTex, renderTargetDepth);
And how I save files.

Code: Select all

void savetex(ITexture *texture, std::string filename, IVideoDriver* videoDriver) {
    video::IImage* image = videoDriver->createImageFromData(
        texture->getColorFormat(),
        texture->getSize(),
        texture->lock(irr::video::E_TEXTURE_LOCK_MODE::ETLM_READ_WRITE),
        true  //copy mem
        );
    videoDriver->writeImageToFile(image, path(filename.c_str()));
    texture->unlock();
}
And I call the function with

Code: Select all

savetex(renderTargetTex, "SingleFrameRenderingResult.png", videoDriver);
In most cases, it works fine. But when I setted the resolution to a quite high resolution (still, I have the device with the same resolution), like 19200*10800, the program worked but the out put cannot be opened. And I think it should be wrong according to the size of the output png file.

I ran some test and it appears that it can still work well until 7680*4320.

Cannot help but wondering, is that the problem caused by the file format or irrlicht? (I also tried bmp, and it looks almost the same except the size of the output file, which was reasonable. And I tried using SingleFrameRenderingResult.tif as the file name to use tiff format, but it appeared that the file cannot be recognized.)

Any ideas?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Render to target and save to files with high resolution.

Post by Nadro »

During the lock a texture is rendered to FBO, so 19200x10800 is too big... 8192x8192 or for some GPUs 16384x16384 is max.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
lvgeng
Posts: 38
Joined: Fri Aug 14, 2015 4:35 pm

Re: Render to target and save to files with high resolution.

Post by lvgeng »

Hi I am back with some interesting result.

I tried several parameters. 10999*10999 still works fine. But 11000*11000 won't.
The result came from a fedora machine with titan x.
Not so sure why, but I decide to test on windows too.
Nadro wrote:During the lock a texture is rendered to FBO, so 19200x10800 is too big... 8192x8192 or for some GPUs 16384x16384 is max.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Render to target and save to files with high resolution.

Post by Nadro »

You can download OpenGL Extension Viewer (it doesn't support Linux):
http://www.realtech-vr.com/glview/download.php
and go to:
Extensions->Capabilities->Implementation specifics->Framebuffer properties/Various limitations
where you can find some info about your hardware capabilities. Eg. My Radeon 380 handle up to 16384x16384 viewports size during render to FBO.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Render to target and save to files with high resolution.

Post by hendu »

Titan Black is 16384, so X is probably the same.

Can you isolate whether the issue is in the RTT or the data/png part? Draw the RTT on screen using one of the draw2d calls, etc.
Post Reply