glue-viz / glue-ar

BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Combine sides in voxel exports #54

Open Carifio24 opened 1 week ago

Carifio24 commented 1 week ago

Something that we should consider to make the voxel files more lightweight is to pre-alpha-composite sides of adjacent boxes. While this won't be helpful on boundaries, this should still lead to a significant reduction in vertex and triangle count.

To be more specific, suppose we have two boxes $A$ and $B$ that are adjacent. This means that they meet along a common face. Call this face $F_A$ in A and $F_B$ in B. $F_A$ and $F_B$ are spatially coincident, but may have different opacities due to the data. What we can do is instead replace this by one common face $F_AB$ whose opacity comes from alpha-compositing together the materials of the original two faces.

This would require some modification of the geometry, but we're only dealing with rectangular prisms so this shouldn't be too difficult.

Carifio24 commented 1 week ago

I'm actually not sure whether or not this will work due to visibility issues from various sides. Currently all of the normals for the "box" geometry point out - if we want a single side to be visible from both directions (as we would want here) then we would need to double-triangulate anyways, so maybe any gains to be had here aren't worth the effort?