I started with dunes tgd and kept plugging away and experimenting till I got it. Stumbled onto it, and am not 100 percent sure why it works, but it does work. I created a "mask" by setting first setting it all black and then produced the shore line by elevation constraints to be all white. Plugged it into the foam blend - trick was to also merge in the elevation and include compute terrain, so that the surface layer used to create the mask knew about elevation. Not being very clear, but the tgd speaks for itself.