Simple refraction with chromatic aberration

I was playing with UV offsets, figured out a shader that does a simple refraction (not depth-dependent) with chromatic aberration.

It works best with convex surfaces, and it’ll look odd if you use it for a window, but it works for jewels, crystal balls and the like.

The basic idea is to refract based on the surface normal and spread the colours into a spectrum as you do so.

Here the cube shows the 5 colour spread:

Here’s how I calculate the refraction and aberration (note: I ping-pong the screen-space UVs to stop them going out of range):

Then I mask and combine the spectrum proportionally to get the final result:

They layer up quite nicely, sorting by object distance:

Enjoy, and let me know if you can make it better

Hi ,
cool idea .
I’ve tried to replicate it myself , though i cannot seem to find the MF_PingPong node ? I’m using 4.13.0 . Is that a custom node of yours ?
I noticed that there’s a jump in the refraction when panning /zooming the camera around , because of that node i’m missing ?

I believe this is obvious but if you’re using a thirdperson camera view , the render of the character gets included in the chromatic aberration .

Did anyone ever manage to figure out how this ping-pong material function works?

Any idea how to make this work? Some more insight into the Pingpong function would help!

Maybe you using Screen Position stop UV go out ,right?