Baked Directional Gravity (WIP)
This project aims to make directional gravity faster to process for multiple objects by baking it into the level data.
3D Platformer
Relative Gravity
In 3D platformer games such as Super Mario Galaxy and Psychonauts, there is a game mechanic where gravity changes relative to the surface the player is standing on.
This is traditionally done by getting the normals from mesh triangles. For known geometric shapes, volumes can be used to apply gravity to the player using mathematic equations. Spheres, toruses, cylinders, capsules, disks, and other shapes have an equation derived without having to access mesh data.
Over the past decade, games have been rapidly adding to the average number of physics objects loaded, especially with destructible environments becoming more and more popular. The extra calculations for finding the direction of gravity at a location would start to accumulate.
Vector Fields
Baked Directional Gravity uses the mathematical concept of vector fields to interpret the direction of gravity. Because the data is saved directly in terms of (position, gravity direction), it doesn't have to do any calculations to get the gravity direction. The only downside is that it uses 3D textures, which have to be loaded into memory, instead of the already loaded level geometry. This is mitigated by subdividing the vector fields and only loading them in once they get close to the player.