Computer Science Canada Ray Tracer With Reflections and AA |
Author: | wierdo1111 [ Thu May 01, 2014 2:30 am ] | ||
Post subject: | Ray Tracer With Reflections and AA | ||
I made this to improve my algebra. So basically this is a "real-time" ray tracer if you consider 1/20 fps with one light and object real time. This version includes AA by super sampling, I also made another version which does MSAA which is maaaaany times faster. Originally all calculations where done through functions but that was slow so I removed them and added an extra 100+ lines of pure calculations, and before you ask I know what a for statement is but there slow. I left in original functions and commented out there calls so you could see what what was happening instead of random calculations. The GUI only display info you can't change anything except AA level, so all change will have to be manual. AA takes a long time to do, luckily that time is can easily be calculated. Time with AA is ~= to time without AA it would have take multiplied by 2^(n) when n > 1, where n is your AA level which should be a positive integer, but funny story I never tested for negatives or put in any checks so I don't actually know what happens. Camera variables are at line 502 and 503, only change camPos and look_at. Object and Light data can be found right below camera. Quick tut on setting up object and lights, because I added no comments.
Other things to note, using Open Turing more than doubles rendering speed and compiling as .exe further ups that by 5~10%. Funnily enough the direction of planes while have no difference on colour or reflections can greatly effect speeds, in the version I include if you invert the normal and r-values it will add an extra 30 seconds of rendering time. Also throwing in a .exe compiled with Open Turing if you didn't believe about the speed. Just added MSAA version in zip, comes with 3 pics; no AA 8x MSAA and 8x SSAA. |
Author: | DemonWasp [ Thu May 01, 2014 5:22 pm ] |
Post subject: | RE:Ray Tracer With Reflections and AA |
That's pretty awesome! It looks like your shadows aren't working correctly. You're taking the magnitude of the light-direction vector as the distance to the light, but you're doing it after you normalize, so your shadows don't work quite right. It also looks like your reflected rays are just taking the brightness of the object they hit (that is, they ignore shadowing / lighting). If you fix the shadow bug first, this second bug will become a lot more obvious, especially on the very-reflective objects. Great work! |
Author: | wierdo1111 [ Thu May 01, 2014 10:37 pm ] |
Post subject: | Re: RE:Ray Tracer With Reflections and AA |
DemonWasp @ Thu May 01, 2014 5:22 pm wrote: It also looks like your reflected rays are just taking the brightness of the object they hit (that is, they ignore shadowing / lighting). If you fix the shadow bug first, this second bug will become a lot more obvious, especially on the very-reflective objects. Thanks, I never even noticed the lighting issue till you mentioned it because it doesn't look overly wrong. From what I can tell fixing the shadow bug has no impact on speed and colour, but I fixed it anyways. |