# vtk ospray pathtracer setmaxframes accumulate for OSMesa how

**URL:** https://discourse.vtk.org/t/vtk-ospray-pathtracer-setmaxframes-accumulate-for-osmesa-how/12871
**Category:** Support
**Created:** [December 8, 2023, 9:31pm UTC](https://discourse.vtk.org/t/vtk-ospray-pathtracer-setmaxframes-accumulate-for-osmesa-how/12871 "2023-12-08T21:31:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Spacetracker](https://discourse.vtk.org/user_avatar/discourse.vtk.org/spacetracker/32/8121_2.png) [@Spacetracker](https://discourse.vtk.org/u/Spacetracker)
#### Post date: [December 8, 2023, 9:31pm UTC](https://discourse.vtk.org/t/vtk-ospray-pathtracer-setmaxframes-accumulate-for-osmesa-how/12871/1 "2023-12-08T21:31:50Z")

</div>

Post Submission Update: I looked at the source code to vtkOSPRayRendererNode

Does setting both of these parameters to the same count do what I want?  
SetSamplesPerPixel(64, renderer)  
SetMaxFrames(64, renderer)

I have been using vtk OSPray for many months but using only the scivis renderer so far. When I specify the pathtracer renderer, I only get the first frame rendered, even if I use SetMaxFrames. How do I let it accumulate over the number of frames I specify before “refreshing” and writing out the final image? I am using OSMesa so I guess this has to happen inside OSPRay before it returns the final image to OSMesa.

I can watch the accumulation of OSPray frames and the improved final image in the ospExamples.

I have looked at the vtk rendering Examples and tried to find the vtkOSPRayRendererNode settings to do this.

I just found this on the OSPRAY site that describes what I want it to do in OSMesa. Is the VTK interface setting the framebuffer up this way and how do I set the parameters in vtkOSPRayRendererNode, vtkRenderer, vtkRenderWindow, etc., for a specified number of refinements?

## Rendering

### Asynchronous Rendering

Rendering is by default asynchronous (non-blocking), and is done by combining a framebuffer, renderer, camera, and world.

What to render and how to render it depends on the renderer’s parameters. If the framebuffer supports accumulation (i.e., it was created with `OSP_FB_ACCUM`) then successive calls to `ospRenderFrame` will progressively refine the rendered image.

To start an render task, use

```auto
OSPFuture ospRenderFrame(OSPFrameBuffer, OSPRenderer, OSPCamera, OSPWorld);

```

This returns an `OSPFuture` handle, which can be used to synchronize with the application, cancel, or query for progress of the running task. When `ospRenderFrame` is called, there is no guarantee when the associated task will begin execution.

Progress of a running frame can be queried with the following API function

```auto
float ospGetProgress(OSPFuture);

```

This returns the approximated progress of the task in [0-1].

Applications can cancel a currently running asynchronous operation via

```auto
void ospCancel(OSPFuture);

```

Applications can wait on the result of an asynchronous operation, or choose to only synchronize with a specific event. To synchronize with an `OSPFuture` use

```auto
void ospWait(OSPFuture, OSPSyncEvent = OSP_TASK_FINISHED);

```

The following are values which can be synchronized with the application

Thanks
