Neat!
As for performance, the old optimisation trick still stand, the fastest code is the code that doesn’t have to run!
In this case, that means moving calculations from fragment shader to the vertex shader, or perhaps as uniforms. See my answer to this forum post for a more hands on look at what I’m referring to.