Special thanks to Riccardo Antonelli's blog post for going over the complicated math behind geodesics!
The geodesic equations describe the motion of particles and light in curved spacetime. For a Schwarzschild black hole, these equations are derived from the Schwarzschild metric, which represents the spacetime geometry around a non-rotating, uncharged black hole. The equation looks like this:

To simplify this, I first work with polar coordinates. I then work from the plane of reference of the photon/ray. This plane is described by the cross product of the direction of the ray and the vector joining the origin of the ray and the center of the black hole. A Schwarzschild black hole guarantees that the photon will necessarily only traverse on this plane.

In the above equation, n is vector describing the plane, A is the ray origin, B is the singularity, and d is the direction vector of the ray.
From this plane, I also derive the azimuthal angles which I later use for reconstructing the ray in 3D space.
Skipping a few steps here; following our substitutions, the equation describing the geodesic takes the form of newton's conservation of energy, and the final form the equation is:
