View Full Version : Strange pixel noise with my raytracing engine
allemensen
06-07-2007, 09:10 AM
I'm trying to build a raytracing engine, following a tutorial on flipcode (also on this site). But when I run it now it creates a very strange pixel noise. I have tried almost everything to solve it, but nothing works!
The zip file: http://files-upload.com/279424/Raytracer.zip.html
Reedbeta
06-07-2007, 09:24 AM
Can't you post a screenshot?
allemensen
06-07-2007, 09:35 AM
Here is a screenshot (scaled down by 50%)
http://img528.imageshack.us/img528/4104/screenshotjm3.png (http://img528.imageshack.us/img528/4104/screenshotjm3.png)
Reedbeta
06-07-2007, 09:44 AM
I assume you're not doing Monte Carlo raytracing. If you are, then you might just not be using enough samples.
If not, have you tried looking in a debugger to see what is going on at one of the black pixels?
Also, have you tried varying the shapes and materials in the scene to track down what situations trigger the bug? For instance, does it always occur on spheres? Does it always occur on reflective materials?
allemensen
06-07-2007, 10:25 AM
What is Monte Carlo raytracing? I just shoot a ray through every pixel in my screen. I haven't looked into one of the rays with the debugger yet but I'll try (since the black pixels fit in the same place every time). And black pixels occur only during reflection. I haven't tested reflection with planes yet (my engine only supports the primitives Sphere and InfinitePlane till now)
EDIT: I tried the debugger with one of the black pixels. I discovered that something went wrong in the function Intersect of the Sphere. t1 = 0.4 something and t2 = 0. My function should return HIT and t1, but it returns INPRIM and t2. This gives the point on the other side of the sphere, explaining the black pixel. See next post
allemensen
06-07-2007, 11:02 AM
I just found out that with the black pixels, the determinant of the formula to calculate t, is lower than 0. Could someone please check my formula's in Sphere.cpp
stonemonkey
06-07-2007, 11:14 AM
Could possibly be that when you test the reflected ray it's being calculated as intersecting the sphere it's meant to be reflected off, if that's the problem then either don't test that sphere or use some small positive value rather than 0 for the minimum distance from reflection point to new intersection. (sorry I've not looked at your code and probably wrong)
Judging only the images I believe that stonemonkey is right. If you recursively ray-trace, start the ray of the next recursion on `position + normal * small_value' instead of just`position'.
allemensen
06-08-2007, 08:15 AM
Thanks! That last tip worked! It now shows this image.
http://img58.imageshack.us/img58/5070/screenshotfj3.png (http://imageshack.us)
Rhino
06-08-2007, 10:28 AM
amazing that with just 2 spheres you've managed to make a test image which resembles a womans breast, complete with nipple.
I foresee a great future for you and your raytracer! :lol:
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.