# Implementing near plane clipping

Is there an easy way of clipping geometry with a near plane? I simply dont want to intersect/render geometry in between the eye and a near plane. Currently i’m using the sutil camera from the examples and working with a modified version of the optixPathTracer example.
So far i tried raising tmin in optix trace for my radiance trace. That messes things up performance wise and intuitively shouldn’t be good option since it also modifies traces after the first one.
I would be thankful for any hints. Thanks in advance!

Inside the ray generation program you would need to calculate the intersection of only the primary rays with your near plane manually. https://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection

For that you would need to add the necessary plane equation (anchor point and normal) to the launch parameters. That’s actually supporting arbitrary clipping planes.
For a near plane perpendicular to your camera view direction (W) you would only need a single float for the near distance.

Then change the optixTrace() arguments accordingly.
Either shift the ray.origin to that start point on the near plane, keep the t_min at zero.
Or keep the ray.origin and set the t_min to that intersection distance between camera position and near plane.
In either case the ray.direction stays the same you calculated for the projection of the pinhole camera.

Both methods would limit the primary ray intersection calculations to happen only for geometry behind that near plane. Secondary rays would still be able to see things in front of it though.

1 Like

Thanks for the quick answer! I will implement a near distance in the camera and launch params. Shifting the origin should be even easier in my case, since i use an orthographic projection.

Yeah, for an orthographic projection there is not a single problem with that.

Mind that not doing this half-space clipping plane calculation for secondary rays as well means, you will not get light into closed objects which have been cut open with that near clipping plane because shadow rays would be blocked.
That would really require to do this plane equation and offset calculation for every ray.
That in turn will break volume effects like absorption and also refraction because previously closed objects are not closed anymore.
Things get a little complicated when the clipping plane should be handled as boundary between volumes.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.