0
$\begingroup$

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 "pure" model (only voxels) I can generate prety decent shadows (ignore the circular artifacts):

enter image description here

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

enter image description here

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):

enter image description here

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.

$\endgroup$
1

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ I'm not sure this is totally robust. What happen if we have 2 adjacent cubes forming a rectangle and our ray slightly penetrates one cube near the shared boundary of both these cubes, while we ignore the cube we penetrate we can still hit the neighbour cubes side on the way out to the light. For this case (cubes) it may be easier to determine which cube face the initial ray enters and only consider the voxels on the opposite side of that plane altogether. $\endgroup$
    – PaulHK
    Commented Jul 24, 2018 at 8:37
  • $\begingroup$ Yeah, I still think getting the offset right is best, especially if the non-voxel raytracer is spawning rays from the real geometry to be traced against the voxelisation. That's never going to be perfect. $\endgroup$
    – Dan Hulme
    Commented Jul 24, 2018 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.