<p>You could do this. Basically what you would do is generate a cube for each voxel (or actually nearby voxels could share the edges). Not exactly sure what benefit you would get form this, unless your intersection algorithm is somehow extremely finely tuned. It could be useful for real time rendering or some sort of sparse structure. While your at it why not dispense of the voxel concept altogether and go all FEM on the problem.</p>

<p>The thing is you want a more uniform sampling across the volumes density function. Because your integrating over a volume functions you want the step size to be somewhat equally spaced so you can control the integration better. Random or pseudo random solution converges often better, but mainly you do not do cube oriented sampling this way as it will make the structure obvious which is not your goal in most cases. </p>

<p><a href="https://i.sstatic.net/HaXGH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HaXGH.png" alt="enter image description here"></a></p>

<p><strong>Image 1</strong>: Different sampling strategies. Images in RTL reading order samples along voxel grids,  Uniforms sampling and jittered ray length sampling.</p>

<p>Think of this as solving a ODE you sample the function uniformly and if your value changes too much you might do additional samples. This is probably the reason why you wouldn't really do collision to the voxels.</p>

CC BY-SA 3.0
2016-02-21T17:39:54.433Z
2016-02-21T17:39:54.433Z
joojaa
<p>Here's a very speedy 10 line maths fix for converting mesh to voxels... forget rays, dot products, square roots etc, edges, intersections do this:
<a href="https://gamedev.stackexchange.com/questions/136243/how-can-i-randomly-pick-points-on-a-triangle/136250#136250">https://gamedev.stackexchange.com/questions/136243/how-can-i-randomly-pick-points-on-a-triangle/136250#136250</a></p>

CC BY-SA 3.0
2017-01-25T09:12:49.897Z
2017-01-25T09:12:49.897Z
2017-04-13T12:18:54.697Z
bandybabboon
<p>I have been playing with voxelization for a little time, I'm still very new to this technique.
I am trying to use it for ray tracing but I've been stuck with one problem. There are some codes out there in the web that already perform voxelization however, for ray tracing I need to check the intersection between a ray and a triangle.
Therefore, I've been thinking about what would be a good approach to create a list of triangles for each voxel in order to query the triangles once I know a ray hits a particular voxel? Should I try to modify the code of the voxelizer to benefit from the overlap-test or is it better to create a space-partitioning structure?</p>

CC BY-SA 3.0
2016-02-17T15:14:39.980Z
I don't know a lot about voxel-based rendering, but I always got the impression voxel-based raytracers intersected the rays directly with the voxels, instead of constructing a polygonal representation of the voxels first.
Martin Ender
CC BY-SA 3.0
2016-02-17T15:26:39.277Z
Neither am I, I just read about rendering using voxelization so I might have a wrong idea on the technique.
BRabbit27
CC BY-SA 3.0
2016-02-21T00:49:57.720Z
You don't want to do voxel rendering, right ? since you would no longer need triangles. You wan't to do an optimisation structure sorting the scene triangles withing regular grid cells, right ? (but there are several variants, e.g. spliting the triangles or not. which is yours ?)
Fabrice NEYRET
<space-partitioning><voxelization>
How to build a triangle-voxel list from a triangle mesh?
BRabbit27
# How to build a triangle-voxel list from a triangle mesh?

(Asked by: username_0 on 2016-02-17)

I have been playing with voxelization for a little time, I'm still very new to this technique.
I am trying to use it for ray tracing but I've been stuck with one problem. There are some codes out there in the web that already perform voxelization however, for ray tracing I need to check the intersection between a ray and a triangle.
Therefore, I've been thinking about what would be a good approach to create a list of triangles for each voxel in order to query the triangles once I know a ray hits a particular voxel? Should I try to modify the code of the voxelizer to benefit from the overlap-test or is it better to create a space-partitioning structure?

**Tags:** space-partitioning, voxelization

> **Comments:**
> **username_1**: I don't know a lot about voxel-based rendering, but I always got the impression voxel-based raytracers intersected the rays directly with the voxels, instead of constructing a polygonal representation of the voxels first.  
> **username_0**: Neither am I, I just read about rendering using voxelization so I might have a wrong idea on the technique.  
> **username_2**: You don't want to do voxel rendering, right ? since you would no longer need triangles. You wan't to do an optimisation structure sorting the scene triangles withing regular grid cells, right ? (but there are several variants, e.g. spliting the triangles or not. which is yours ?)  

---

## 2 answers

### Answer by username_3 on 2016-02-21. Score: 2

You could do this. Basically what you would do is generate a cube for each voxel (or actually nearby voxels could share the edges). Not exactly sure what benefit you would get form this, unless your intersection algorithm is somehow extremely finely tuned. It could be useful for real time rendering or some sort of sparse structure. While your at it why not dispense of the voxel concept altogether and go all FEM on the problem.

The thing is you want a more uniform sampling across the volumes density function. Because your integrating over a volume functions you want the step size to be somewhat equally spaced so you can control the integration better. Random or pseudo random solution converges often better, but mainly you do not do cube oriented sampling this way as it will make the structure obvious which is not your goal in most cases.

[![enter image description here](https://i.sstatic.net/HaXGH.png)](https://i.sstatic.net/HaXGH.png)

**Image 1**: Different sampling strategies. Images in RTL reading order samples along voxel grids, Uniforms sampling and jittered ray length sampling.

Think of this as solving a ODE you sample the function uniformly and if your value changes too much you might do additional samples. This is probably the reason why you wouldn't really do collision to the voxels.


---

### Answer by username_4 on 2017-01-25. Score: 0

Here's a very speedy 10 line maths fix for converting mesh to voxels... forget rays, dot products, square roots etc, edges, intersections do this:
<https://gamedev.stackexchange.com/questions/136243/how-can-i-randomly-pick-points-on-a-triangle/136250#136250>


---

