optixPathTracer: is it possible to resize realtime?

I would like to ask if it is possible to resize the window of the optixPathTracer in realtime mode. In the sample, the renderer is awaiting the user to finish dragging the window edge(release the mouse button) before re-rendering the scene in the new size. Is it possible to resize the scene in realtime mode, so the scene is re-renderered without the user releasing the left button?

That is solely a GLFW question and depends on how you handle window events.

Just search the web for glfw resize event and the first hit finds the GLFW Window guide chapter below and the second hit explains different solutions .

Please read the Window guide chapter here: https://www.glfw.org/docs/latest/ and look for glfwSetWindowRefreshCallback.

Thanks for your reply, I would like to ask if from the optixPathTracer side the pipeline is combatible with such functionality (like responding to glfwSetWindowRefreshCallback).

Looking at the update functions I see that the only related lines are:

void handleCameraUpdate( Params& params )
    camera.setAspectRatio( static_cast<float>( params.width ) / static_cast<float>( params.height ) );
    params.eye = camera.eye();
    camera.UVWFrame( params.U, params.V, params.W );


void handleResize( sutil::CUDAOutputBuffer<uchar4>& output_buffer, Params& params )
    output_buffer.resize( params.width, params.height );

    // Realloc accumulation buffer
    CUDA_CHECK( cudaFree( reinterpret_cast<void*>( params.accum_buffer ) ) );
    CUDA_CHECK( cudaMalloc(
                reinterpret_cast<void**>( &params.accum_buffer ),
                params.width * params.height * sizeof( float4 )
                ) );

Should I modify the optix pipeline as well in order to handle the realtime resize event from GLFW?

I am trying to build a custom test renderer based on optixPathTracer and resize works properly (just like the optix sample) when renderer stops+restarts on resize. However when I resize in realtime mode as I described above, the aspect ratio is obviously wrong, i.e. resizing on y-axis makes a cube look taller or the actual position of the cube is wrong.

(This is a cube resized on y-axis, somehow it looks like the camera doesn’t pick up correctly/synced the resize events, especially when they rapid/radical)

The sample’s pipeline is already doing what you need. The only thing missing is the resize events during drag, which is what Detlef has linked to. The non-uniform scaling is just happening because the app isn’t getting resize events during drag.


1 Like