Self intersection artifacts in 3D image raytracing I am developping a voxel raytracer for global illumination.
I have been successful in multiple aspects but there is a problem I am not sure how to solve.
The model works as most other Voxelization based algorithms work. We use rasterization to store the scene in a 3D volumetric structure and then we raytrace inside of said 3D structure.
In the &quot;pure&quot; model (only voxels) I can generate prety decent shadows (ignore the circular artifacts):

However when I try to create a combined scene (normal rendering for colors, voxels for shadows) I sometimes get self intersection based artifacts:

I can improve the image a bit by using an epsilon tolerance (considering that if we are too close to the original starting position we haven't collided with anything yet):

However doing this creates poor shadows by eliminating certain collissions (look at the archs for example, where the areas too close to the source should be darkened but are instead lightened).
I want to know if there is a better way to check for self intersection, other than checking the original position?
i.e I want to be able to get as close to the shadows in the first image as possible.
I want to know if there is a better way to check for self intersection, other than checking the original position?


Since cubes are convex solids, a self-intersection check shouldn't introduce artefacts in your case, while it would in a more general ray-tracer (see my answer about the shadow terminator problem for more about that). In general, it's a good idea for your ray object to have a reference of some kind to the object it came from, as well as the kind of ray it is (primary, shadow, reflection, refraction). Normally the reference should be to the exact polygon, not just the whole object; in your case, it should be the particular cube. You could identify it by the co-ordinates of the cube, if you're using spatial hashing to store your voxel grid.

Then, in your intersection test, if your ray is a shadow ray, you should check whether the origin cube is the same as the cube being intersected, and discard that intersection if so.