Metaball renderer complete
The metaball rendering now works as expected, after a lot of head-scratching and second-guessing. The images below displays a randomized example scene of the metaball surface being rendered within a bounding volume. The second picture is the same scene as the one above, with the metaball positions slightly altered.
The development went through multiple phases. First, there was a research phase, where as much material and inspiration for the implementation was collected. Then, the experimentation phase began, where different parts of the implementation were being tested separately to make sure that they worked one by one. After this phase, the implementation began with a naive approach, where all scalar field values were being calculated multiple times per frame, and no pair of triangles in the mesh shared even a single vertex.
Computing the scalar field values for each frame separately from the actual marching cubes algorithm is assumed to have given a certain speedup. At first, the eight values for each grid cell was being computed for each grid cell, disregarding the fact that any two grid cell share at least four grid points. The difference in the amount of computation is likely most noticeable when the number of grids points and metaballs increase.
The second optimization, letting triangles share vertices, presumably makes the rendering less expensive for Unity, and the memory needed is decreased dramatically, especially at higher grid resolutions. The most noticeable difference is the visual. When no vertices are shared, only flat shading is possible, whereas with shared vertices, the default material in Unity automatically computes something that looks like Gouraud shading.
Having completed this milestone, a large part of the implementation is complete, now there is the issue of adding collisions with terrain, cohesion forces and other physics simulations in real time!
Github commit for this progress: f968afc74b6508ce3feab299c09ddf5d36c77e86
The development went through multiple phases. First, there was a research phase, where as much material and inspiration for the implementation was collected. Then, the experimentation phase began, where different parts of the implementation were being tested separately to make sure that they worked one by one. After this phase, the implementation began with a naive approach, where all scalar field values were being calculated multiple times per frame, and no pair of triangles in the mesh shared even a single vertex.
Computing the scalar field values for each frame separately from the actual marching cubes algorithm is assumed to have given a certain speedup. At first, the eight values for each grid cell was being computed for each grid cell, disregarding the fact that any two grid cell share at least four grid points. The difference in the amount of computation is likely most noticeable when the number of grids points and metaballs increase.
The second optimization, letting triangles share vertices, presumably makes the rendering less expensive for Unity, and the memory needed is decreased dramatically, especially at higher grid resolutions. The most noticeable difference is the visual. When no vertices are shared, only flat shading is possible, whereas with shared vertices, the default material in Unity automatically computes something that looks like Gouraud shading.
Having completed this milestone, a large part of the implementation is complete, now there is the issue of adding collisions with terrain, cohesion forces and other physics simulations in real time!
Github commit for this progress: f968afc74b6508ce3feab299c09ddf5d36c77e86


Kommentarer
Skicka en kommentar