pouët.net

Raymarch Simple Question

category: code [glöplog]
Hmm, yeh I think you're right. Some bias is needed somewhere.

Will continue playing with it.
added on the 2014-10-12 18:35:04 by dila dila
When you cast the shadow ray, move the origin of the ray by a little bit (in the direction of the normal of the surface, or the direction of the ray). That should fix it.
added on the 2014-10-13 08:10:42 by iq iq
Same is needed if you want to have mirrors...after you reflected the ray, you need to walk some small distance on it. Try it, you only need to put "rayDirection=reflect(rayDirection, normal);" after you found an intersection and calced your pixelColor, then travel a small distance (i use my epsilon=0.001, i also use as a bailout anyway, as in "if(distance<epsilon) HIT!" ) , then do another intersection-test, pixelColor+=mirrorStrength*mirrorPixelColor, et voila, Mirrors! :) While mirrorPixelColor is just another color you calculate like your pixelColor from your first Hit, so you add the color of the mirrored object; mirrorStrength is just sth like 0.25 or 0.5, as you dont want to mirror 100% normally.
Yep, that was the problem. I've tried mirrors in a new toy, it's working well thanks :)

BB Image
added on the 2014-10-13 19:38:26 by dila dila

login