I've masked the foam to the blue channel of the normal map so that it has some detail rather than just being an ugly grey splodge.
It's thresholded by the heightmap so that it only shows up when the waves are strong enough.
Time for a release!
Parallax Mapped Water
[Download]http://www.mediafire.com/file/794l4pb5as8arb3/Parallax%20and%20Foam%20Water%20Shader.zip[Download]
Includes a 2 sets of uncompressed normal maps with 1024, 512 and 256 versions. Uses 512 choppy version by default.
Compression kills the quality of the water but uncompressed takes up more memory. High, medium and low res versions are if you need extra performance.
Red and Green channels are normal map.
Blue channel is a foam mask.
Alpha channel is the height map.
Controls
float DetailScale0=0.25; //flow normal scale
float DetailScale1=1.0; //normal scale
float DetailScale2=3.0; //normal scale
float FlowBump=0.0125; //extra flow/warp normal power 0.025
float Bump=0.25; //normal power 0.25
float DetailBump=0.25; //normal power 0.25
float depth=0.05; //relief mapping .05
float FoamAmount=1.0; //foam strength 1
float FoamThreshold=0.25; //foam threshold 0.25
float FoamPower=1; //foam power 1
float WaterBump=0.33; //index of refraction -1
float2 WaterScale={1200,1200};
float4 WaterSpeed={-0.01f,0.01f,0.03,-0.02f};
float F0=0.000f; //fresnel FO
float Roughness=0.00f; //UE4 reflection roughness, for limiting reflection intensity
If something compiles on the first try. Something is terribly wrong.