Gradient computation in Bi-directional optical flow are described. In a representative aspect, a method of video processing including: modifying temporal gradients in a motion vectors refinement process of a video block or sub-blocks within the video block; and performing the motion vectors refinement process of the video block or the sub-blocks within the video block based on the modified temporal gradients.