Saving optixVolumeViewer depth

Careful with those depth value calculations though.
The OpenGL rasterizer depth is a parallel distance from the camera plane (defined by the frustum) while the primary ray intersection distance from a pinhole camera is a radial distance from the camera position.
These depth and distance values are not going to composite directly.
You must transform the ray tracing world space hit coordinates to OpenGL window depth values, or vice versa for what David described, using the OpenGL model-view projection matrix setup to be able to composite ray traced intersection distances against rasterizer depth values.

Again, all that is only going to work with opaque materials. If you have transparency inside your scene, things are getting complicated.

Also the optixMeshViewer is far from rendering volumes looking nicely, like real clouds. That needs a completely different lighting and integrator implementation than that simple example is using.

1 Like