dilevin / computer-graphics-ray-casting

Computer Graphics Assignment about Ray Casting
2 stars 7 forks source link

Eigen producing negative output #29

Open gabriellemadden opened 4 years ago

gabriellemadden commented 4 years ago

I used to be able to get the correct image using the Eigen solver alone, but now when I solve the system using the Eigen library the t parameter that gets produced is negative. I don't know what's causing this (I'm pretty sure I didn't change the code). I can get the correct output for the bunny and single triangle if I multiply t by -1 but leave the alpha and beta coefficients alone. Is this normal or is it possible that running the eigen library on a different machine will produce a different output (and not render the triangles)?

darren-moore commented 4 years ago

Recall that the triangle intersection lecture slides are a special case, with one corner sitting at the origin. My guess is that the way you generalized this introduced a sign change, but it's hard to know. There could also be a sign error in viewing_ray that you also compensated for in Plane and Sphere. Try to keep things consistent internally, but ultimately, your output should be consistent with the sample images.

I haven't encountered non-hardware-deterministic Eigen before.

For interest: Floating point computations are hardware agnostic since there is a well-defined standard. Sometimes the computations are not compiler agnostic though! If you've taken a course in numerical analysis, you know that floating point operations are non-associative. This can sometimes cause issues when compilers optimize code. This assignment shouldn't be problematic like that though.