Here you go, the Z height mask works just fine in a light function.
here I made the shadow a line instead of a mask below Z since I used the ABS node. If you remove that it would return black anywhere under the Z value.
So for caustics, you just do this:
I skipped the Z shear and transform to keep the image simple. I should have just used LightVector.xy * Tiling which is actually correct for a lightfunction since you don’t need to do your own transform anymore. it automatically aligns with worldcoords transformed into the light vector for a directional light. of course I think of it just after posting the image :S
but yes, you are right that you lose the chromatic abberation and pay some perf. Personally I’d just use post process volumes to increase it underwater. Yea you wont get it when looking from above the water, but if you need to see the effect take a screenshot from below with higher abberation.
Sadly the only other way to get shadowing on it without a light function would be to render out your own math in the code lighting path and its hard to say how much you could make it faster without trying. Either that or you make the caustics themselves post process based and use a threshold using scenetexture so that only pixels that were already at X brightness get the effect, targeting the lit vs shadow color to exclude shadow areas. in practice it could work but I could also see certain content being a pain to adjust for it… ie it woudl equally detect bright textures and bright lighting so it would work best with somewhat low contrast content underwater. Not necessarily that limiting.