Hi!
I was trying to do a short experiment with variable sampling rate based on OptiX SDK 7.4’s optixpathtracing
example. I am using Ubuntu 22.04 LTS with NVIDIA-SMI 520.61.05 Driver Version: 520.61.05 CUDA Version: 11.8.
The idea is to define a circular region and if the pixels inside that region, use predefines sampling rate, else use another sampling rate. And it will be dynamic where the center is the cursor position.
For that I extracted the mouse cursor position with glfw
library and passed the data to __raygen__rg()
shader. The modified code snipped looks something like this:
const uint3 launch_index = optixGetLaunchIndex();
double center_x = params.cx; // received from glfw
double center_y = params.cy;
const int radius = 600; // defined radius size
float3 accum_color = ((((launch_index.x - center_x) * (launch_index.x - center_x)) +
((launch_index.y - center_y) * (launch_index.y - center_y))) <= (radius * radius)) ? result / static_cast<float>( params.samples_per_launch ) : result / static_cast<float>(params.periphery_per_launch );
// defined params.samples_per_launch = 4
// params.periphery_per_launch = 16
// rest of the code are almost same as optixpathtracer code
Now it is working. But the problem is, while moving the cursor and shifting the circular region, the previous circular region is still visible in its old position. Something like the figure below (top left corner, the brightest white circle is light source).
I think it is because somehow I messed up with the output buffer, or the buffer is just overlapping. I do not want to see this overlapping circles, and with movement of the mouse, there should be only one circle with variable sampling rate in and out. A close shot looks like this:
Could you please give some guidelines what I am doing wrong.