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.
Asked
Active
Viewed 178 times
1
-
1Projecting gives you a location in space, but not a direction as you would need for a normal. For the round outside you could use the normalized difference between the hit point and the projected hit point on the cylinder axis. For the end you would need extra code. – Gnietschow Mar 01 '19 at 23:12