Chapter 7: Putting it all together Jun 16, 2022 8:32:06 GMT
Post by vityafx on Jun 16, 2022 8:32:06 GMT
Hello everyone. I am writing one in Rust and I am really upset. Since the first chapters I was using the Rust's glm library but then noticed it was old and changed to glam. Now, what has been happening with glam a lot is that it is oriented column-wise rather than row-wise as glm in c++ and in Rust. I had to rewrite all the matrices to support that. Then, the next problem was that I was too lazy to write some matrices like rotation, translation and scaling as I had already known that there was a function in the glam library to just create a matrix out of of a translation/scale vector and same for rotation, so I decided to use those. I did write all the tests from the book and all were passing. Sometimes the tests instead of having `0.0f32` had a very close value to zero, like -2.0444226e-8 and others like that. I don't like that happening but I can't explain why it is happening and is this even a real problem to deal with. Another problem is that sometimes there are precision-wise changes. For example, some tests which want to test a point after some transformation to have a coordinate of -sqrt(2)/2 don't have the exact answer, but just first four digits after the dot sign and others are different. When I change something in the code, these last digits after the first four may also change and I have literally no idea why it could be so. I am confused and frustrated, I wish it was explained in the book, or it just had more tests.
Now, the problem I am writing this post about is that once I got to the 7th chapter and got all the tests passing (and via a lot of different transformation, I even rewrote the code to avoid using glam's library transformation in favour of the ones in the book but still the result is not as in the book). The walls in the last paragraph don't show up or show up surprisingly silly, like they were improperly rotated or translated, I don't know. I tried all the possible combinatorics-wise combinations of multiplying matrices, all the ways to create the transformation matrices, all the time the tests are passing, but the behaviour is different and always incorrect (not as in the book). Also weird that the other spheres appear correctly all the time. I went through the book since the transformations chapter like 10 times already and still have no clue what might be wrong here. I am so upset seeing everyone else has it working fine that I am really depressed and want to stop reading the book. Please help me out.
Here is the screenshot:
The code for this test world: github.com/vityafx/raytracerchallengeproblem/blob/master/rt.rs#L945 (rt.rs, Line 945)
P.S. The book itself is awesome and I love it.