Camera lens distortion simulation

G’day all!

I’m trying to simulate lens distortion effect for my SLAM project.
A scanned color 3D point cloud is already given and loaded in opengl.
What I’m trying to do is render 2D scene at a given pose and do some visual odometry between the real image from a fisheye camera and the rendered image.
As the camera has severe lens distortion, it should be considered in the rendering stage too.

The problem is that I have no idea where to put the lens distortion. Shaders?

I’ve found some open codes that put the distortion in the geometry shader:

But this one I guess the distortion model is different from the lens distortion model in ComputerVision community.
In CV community, lens distortion usually occurs on the projected plane.

This one is quite similar to my work but they didn’t used distortion model.
https://github.com/mp3guy/ElasticFusion/tree/master/Core/src/Shaders

Anyone have a good idea?