3D rendering/raycasting from scratch