Find a cylinder normal based on hit vector from camera

188 Views Asked by At

I am working on a raytracing shader that tests for hits from cameraRays to a cylinder of radius R and center C, using cameraPosition as RayOrigin. The cylinder raytracing works fine, but I am struggling to find the Normal of the hit position. I thought about projecting the cameraToHitPoint (point is the hit point on cylinder) vector on the cylinder axis, normalizing it, but it doesn't seem to work. Any idea? Thank you.

0

There are 0 best solutions below