Jump to content

Proper way of generating/saving images


photo

Recommended Posts

Hello,

I'm trying to render then save multiple images to file and I struggle to have image of the quality I see on the main render saved as PNG.

Currently I'm using a component that implements the "update" method. In my component's update I call this "saveImage" function multiple time :

int ImageGen::saveImage(std::string path) {
    ImagePtr image = Image::create();
    viewport->renderImage2D(player->getCamera(), image, 400, 400);
    image->save(path.c_str());
    Log::message("saving image to :  \"%s\"\n", path.c_str());
    return 0;
}

However the saved image is always badly rendered like so

image.png.e2ad8f09da4617472a7db41160da728b.png

image.png.bd79a54fef4d1dd2fd83732f8ac8b616.png

There is no sky is the saved image and they often look like the render didn't properly finish or like another render started before the image was saved.

What would be the correct way of saving images to file ?

Link to comment

Damien,

This artifacts are expected for the first frame grabbed (because no previous frame was ever existed / it contains some garbage).

Please, check the C++ samples in SDK Browser regarding the viewport and textures rendering:

  • Render -> Screenshot
  • Render -> GBufferRead

I believe these two samples should be enough to generate perfect images :)

Thanks!

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

Link to comment
×
×
  • Create New...