manually calculating Moment of Inertia

Hi,

I know that the rigidbody component calculates the inertia tensor automatically from the colliders attached on the object,
but I am trying to find an algorithm that does that as well for some other purposes.
so far I was able to write an algorithm that works with some shapes but not all shapes (specifically spherical shapes because of the integration over volume is different, it still thinks its a cubic shape)
so I was wondering if someone could help.

Thanks in advance.

I haven’t done it myself yet, but I read a lot on that topic a few years ago. You can get the moment of inertia for a lot common shapes from this wikipedia page.

To combine them you would use the parallel axis theorem as mentioned on this SO post

I think this paper covers most of the math you need