VERSION 2: https://scratch.mit.edu/projects/709319751/ Press the flag, watch and wait. This is version 1. Version 2 will include an accretion disk. The grid in then background is made of straight lines, it's just that space is warped... #ray #madness #raycasting #raymarching #physics #black #holes #math #maths #wow
If you value your sanity, use this link: https://turbowarp.org/704339115/editor?turbo HOW THIS WORKS: This is based on the formula F=G*(m1*m2)/r^2, where r is the distance between two objects, G is gravity, m1 and m2 are the object masses, and F is the force of attraction between them. This casts rays from the camera (mass of 1), and some are warped towards and sucked into the black hole, whereas some make it past. Those that make it past form a grid, to demonstrate the warping of spacetime. So, for the ray direction, I made a velocity vector, by creating a new point in the desired direction 'pointing' towards it, then normalising the vector. For every iteration, the photon moves by velocity amount, then the force is calculated with the above formula, and the vector from the photon position to the black hole, rather than the target point, is multiplied by the force of attraction. That is added to the velocity vector, it is normalised again, and it repeats from there. I started by making a 2D version, which you can see here: