Skip to content

Simulation of universal gravitation using compute shader (GPGPU) in Unity / compute shaderによる万有引力のシミュレーション

License

Notifications You must be signed in to change notification settings

mimisukeMaster/Simulation-of-Universal-Gravitation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simulation-of-Universal-Gravitation



Description

This repo is a sample project that simulates universal gravitation in Unity.

The main process is the calculation of the universal gravitation and first cosmic velocity based on physical formulae.

Environments

Unity version: Unity2023.3.21 LTS

This scene simulates only the state of universal gravitation between objects.

If the force is very small due to mass, universal gravitational constant, etc., adjust the value of the parameter COEFFICIENT in the UniversalGravitationController.cs from the inspector view accordingly.

About DemoScene

In addition to simulating universal gravitation, this scene reproduces a pseudo-solar system by giving an object an initial velocity at first cosmic speed.

The initial velocity given to the comet is calculated separately in CometLauncher, taking an appropriate value between the first cosmic velocity given to the planet and the second cosmic velocity at which it flies away from the star. This can be adjusted with the parameter COMET_COEFFICIENT in the CometLauncher.cs from the inspector view accordingly.

ATTENTION:

  • The sun's mass must be very large beyond the upper limit of Rigidbody.mass or it will move under the effect of the planets, so alternatively, the sun's Rigidbody.isKinematic is set to true.
  • The reason why the tracks are not neat and errors occur is that the distance between the planets is much closer than it actually is, and they are attracted to each other, which affects the direction of travel more greatly.
  • As this is only a simplified simulation, the planetary rotations, inclination of the orbital planes, mass and distance ratios between the planets, etc. are not reproduced or correct in this project.

LICENSE

This project is under the MIT License.

Adapted from wikipedia:

Permission is hereby granted, free of charge, to deal in this software on an unrestricted basis. However, the copyright notice and this permission notice must appear on all copies or substantial portions of the software. The author or copyright holder assumes no responsibility for the software.

Author

みみすけ名人 mimisukeMaster

Credits

Imported from an website or AssetStore:

About

Simulation of universal gravitation using compute shader (GPGPU) in Unity / compute shaderによる万有引力のシミュレーション

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages