0

I have a 3D texture containing voxels and I am ray tracing and, everytime i hit a voxel i display the color. The result is nice but you can clearly see the different blocks being separated by one another. i would like to get a smoothing color going from one voxel to the other so I was thinking of doing interpolation.

My problem is that when I hit the voxel I am not sure which other neighbouring voxels to extract the colors from because i don't know if the voxel is part of a wall parallel to some axis or if it is a floor or an isolate part of the scene. Ideally I would have to get, for every voxel, the 26 neighbouring voxels, but that can be quite expensive. Is there any fast and approximate solution for such thing?

PS: I notice that in minecraft there is smooth shadows that form when voxels are placed near each other, maybe that uses a technique that might be adapted for this purpose?

tigeradol
  • 259
  • 2
  • 16
  • How are you raytracing? Do you have some kind of lighting model that assumes the volume to be gaseous? Can you post a screenshot? – Nico Schertler Jul 02 '14 at 18:02
  • No as soon as I intersect the box-voxel I color it based on the content of the 3d texture. Just a flat color. – tigeradol Jul 02 '14 at 18:05
  • Then there are three relevant neighbours (+ the box itself). Can you just interpolate the color across the hit surface? – Nico Schertler Jul 02 '14 at 18:10
  • I did something like that but the result isn't really good. I took the voxel and the 4 neighbours (for simplicity i tested only x - z parallel faces) forming a cross shape and interpolated by taking the value from the voxel and the 2 neighbours on the x and then the same thing for th z direction and averaged the 2 results. I get a smoother effect but the countour of the voxel is still very visible. – tigeradol Jul 02 '14 at 18:14
  • That's not what I meant. I have to correct myself, you need eight voxels. Then you can do trilinear interpolation. – Nico Schertler Jul 02 '14 at 18:18
  • so you mean center and diagonals top and bottom? – tigeradol Jul 02 '14 at 18:19
  • 1
    No, if you hit a voxel, you take the voxel itself. If the hit is right of the voxel's center, you additionally take the right neighbour. Otherwise the left neighbour. If it is in front of the center, you take the front neightbour, otherwise the back neighbour. And so on. At last use the diagonal so you have a 2x2x2 block of voxels. – Nico Schertler Jul 02 '14 at 18:21
  • tested it, it has a bunch of nested if statements but the result is exactly what I wanted. – tigeradol Jul 03 '14 at 15:40

0 Answers0