Had some issues in my data collection and I never would have noticed had I not paid attention to the numbers. Fortunately, I was able to smooth out those issues and, even better, ChatGPT affirmed that my data collection method was mostly sound for training a model. It did recommend that I add an extra column for each metaball with a binary value to indicate whether or not that metaball exists in the scene. It also recommended that I normalize my data using min-max scaling to bring all data within the range of [0,1] in order to improve convergence rate and stabilize the model. Although it’s simple to implement, normalization adds an additional arithmetic operation per data value, so I’m not sure I want to do it yet because speed matters in a realtime program like mine. Therefore, I’ll try building the model first and coming back to normalization later if I run into issues predicting the metaball size data.


Had some more issues in my data collection that manifested their ugly rears as soon as I tried to train my model. Once I fixed them, I recollected data for the nth time today and actually trained my model!

Epoch 200/2000, Loss: 0.0149
Epoch 400/2000, Loss: 0.0095
Epoch 600/2000, Loss: 0.0082
Epoch 800/2000, Loss: 0.0075
Epoch 1000/2000, Loss: 0.0068
Epoch 1200/2000, Loss: 0.0063
Epoch 1400/2000, Loss: 0.0059
Epoch 1600/2000, Loss: 0.0056
Epoch 1800/2000, Loss: 0.0053
Epoch 2000/2000, Loss: 0.0050
Test Loss: 0.0043

The results weren’t super accurate, but that was to be expected due to the relatively crude dataset I provided the model with. Still, some pretty fine predictions were made!

Pretty quickly into testing, however, I realized that I’d overlooked a MASSIVE effect of metaball morphing: the distribution of mass during a multi-ball merge.

Frankly, I don’t see how I can possibly predict the correct sphere side anymore since the center position to place a comparison sphere for a given metaball moves off of that metaball’s center as multiple metaballs converge. In my 11/5/24 dev log, I emphasized how important it is to “consider potential issues that may arise down the line when building something.” Well, this one slipped through the cracks. At least I got to apply some of the ML training knowledge I’d acquired during that YouTube course I took! I was also really looking forward to the challenge of using ML inside Unity since so little documentation exists right now. On the bright side, I can now get back to the business of building an implementation of my energy ball project that uses metaballs instead of twiddling my thumbs in machine learning land.


Tags: gamedev ai metaballs unity vfx