Compositor setting in Blender Internal: How to properly make a split RGB effect on further objects using Z?
One challenging aspect of this effect is that the strength of the color shift increase with the distance from the object that is in focus. This is solved in the compositor by using the depth and a user supplied distance that is considered in focus, to calculate the intensity of the applied color shift.

Before


After


Unfortunately the color shift produces artifacts at the image border. Cropping by the number of shifted pixels may be necessary for good looking results. The proper solution would be to mirror the image along the borders before performing the shift to avoid artifacts in the border region.

Cropped




The Depth Color Shift node setup uses the normalized depth as input to the Gaussian function. This allows to have a nice spread of the intensity values instead of a sharp peak for the depth that is in focus. The output is normalized and inverted, since the effect is supposed to be the smallest at the given depth.

The Gauss Function implements the Gaussian function.

The Shift Color shifts both the individual color channels and the intensity values. The latter is used as blending factor to ensure that the effect strength is applied correctly  depending on the distance.

The parameters of the Depth Color Shift node are:


Focus Distance: Distance where the effect is the weakest (is used as $μ$ in the Gaussian function)
$σ$: Parameter of the Gaussian function, controls the variance
R Shift X: Shift of the red color channel along the x-axis
R Shift Y: Shift of the red color channel along the y-axis
G Shift X: Shift of the green color channel along the x-axis
G Shift Y: Shift of the green color channel along the y-axis
B Shift X: Shift of the blue color channel along the x-axis
B Shift Y: Shift of the blue color channel along the y-axis









The Intensity output of the Depth Color Shift node allows you to see the strength of the effect (black = no strength, white = full strength)








The example file below is for Blender 2.80, however the same node setup should work in 2.79 as well.