Planar map texture at angle (for caustics rendering underwater)

This is my caustic uv math. It’s basically clip ray from world position towards light with water plane. This correctly works with all light types you just need to calculate normalized direction towards light. This is uniform for directional light but for spot or point you need to calculate that yourself.(I use dynamic material instance and send light position as vector param). This is optimized version of general ray plane intersection and this assumes water plane to point towards up.
Edit: Output distance is distance that ray travels water volume.
Edit: Only works for light sources above water level.