0

I am trying to make the generation of voxel/cubes more efficient. First of all I calculate on the cpu which faces are not hidden by other voxels/cubes. Than I send the voxel/cube position and the face normal to the gpu / the vertex, geometry and fragment shader. So now I want simply to generate in the geometry shader a triangle strip from the voxel position and face normal. But now I have problems to calculate the four new vertices from these two informations, I can't find a solution without if and else functions. And since I use backface culling I have to pay attention to the order I emit the vertices from the shader, too. Whats the most efficient way to solve my problem? Or have someone a better idea than my approach?

The normal vector can only have 6 states, for each face of a cube: (0, 0, 1) Front (0, 0, -1) Back (0, 1, 0) Up (0, -1, 0) Down (1, 0, 0) Right (-1, 0, 0) Left

0 Answers0