![](https://static.wixstatic.com/media/3db731_8bed2b32dbd947e6ae0cc43aff396acd~mv2.jpg/v1/fill/w_1920,h_1080,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/3db731_8bed2b32dbd947e6ae0cc43aff396acd~mv2.jpg)
Baked Directional Gravity (WIP)
![SIP_Logo_Transparent.png](https://static.wixstatic.com/media/3db731_0aa9f4a7d7cf41e79e8b092b487bcde4~mv2.png/v1/fill/w_600,h_450,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/SIP_Logo_Transparent.png)
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.
![image.png](https://static.wixstatic.com/media/3db731_f86b5dc86138441cbbb566581c4ace74~mv2.png/v1/fill/w_416,h_228,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/3db731_f86b5dc86138441cbbb566581c4ace74~mv2.png)
![ControlDestruction](https://static.wixstatic.com/media/3db731_495f4e03d21a423da6378534243f778c~mv2.png/v1/fill/w_390,h_330,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/ControlDestruction.png)
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
![image.png](https://static.wixstatic.com/media/3db731_11ae351bb4a74b9ab21cec8cd7f33df8~mv2.png/v1/crop/x_159,y_2,w_599,h_486/fill/w_282,h_229,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/image.png)
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.