Jump to content

[SOLVED] renderImage2D() images are darker than camera


photo

Recommended Posts

Posted

Hi,

 

We're working on an "instant replay" by using engine.render.renderImage2D() to capture frames and then play them back a moment later. The routine is pasted below. But when we play back the images they're significantly darker than the view through the camera in the main Unigine window.

 

Is there something we're missing about how to use renderImage2D() ?

 


void buffer_and_playback() {


  Image images[0];


  Player play = engine.game.getPlayer();
  Camera cam = play.getCamera();


  log.message("Start capture\n");
  forloop(int i = 0; 75) {
    images.append(new Image());
    engine.render.renderImage2D(cam, images[i], 0);
    sleep(1.0f/25.0f);
  }
  log.message("Capture done. Playback start\n");

  sleep(2.0f);

  WidgetSprite ws = new WidgetSprite(engine.getGui());
  engine.gui.addChild(ws, GUI_ALIGN_OVERLAP | GUI_ALIGN_LEFT);

  forloop(int i = 0; images.size()) {
    ws.setImage(images[i]);
    sleep(5.0f/25.0f);
    delete images[i];
  }
  engine.gui.removeChild(ws);
  log.message("PLayback done\n");
}
 
Posted

Hi Angus,

 

More likely engine.render.* is not taking in account some post effects.

 

We recommend to use renderImage2D() method from VIewport class: https://developer.unigine.com/en/docs/2.3.1/api/library/rendering/class.viewport?rlang=usc&words=renderimage2d#renderImage2D_Camera_Image_void

 

You can control which effects will be skipped by setting Viewport's SKIP flags (enumeration is available at the very end of the page).

 

Thanks!

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

Posted

Hi Silent,

 

I get the same "it's darker" result, from using viewport.renderImage2D(cam, images, 1024, 576, 1); (although the images are a little different). I've tried the shorter viewport.render(cam, images) too, just to check. And with the HDR flag set to zero to see if that was it.

 

I don't have any post materials set, and the render settings are the default for new projects. 

 

It's not a killer issue, but I'd like to get to the bottom of things. 

Posted

Sure thing. I've attached an "out of the box" Unigine project with a couple of buttons using engine.render and viewport.render.

 

What I'd love is just a way of accessing the framebuffer of the finally rendered image. It seems wasteful to call another full render() to get the frame.

 

Cheers.

example.zip

Posted
Hi,
 
It's seems that Adaptive exposure causes such effect.
 
Please, try to set Exposure Mode value to Static (Windows -> Render settings -> Camera effects tab -> Exposure tab -> Mode values) and Exposure value to 1.

Thanks!
Posted

That's great. Yes - that does indeed fix things and now the images are the same.

×
×
  • Create New...