Next I'll try to explain how the two normal results are calculated, or more specifically, interpolated at the material normal input. The same concept from the variation mask texture explained above applies here: UVs coming from a pixel world space coordinates projection are scaled by appropriate parameters and these are fed into a Motion_4WayChaos using a Normal map texture object and a given speed to create a randomly moving normal map. The first of this normal results simply uses a small waves normal map. There is a parameter to control the 'strength' of these wavelets and is pretty much an alpha value that lerps the result from the 4WaChaos result and (0,0,1). This result with the small wavelets will end up forming the deeper parts of the lake (the pieces of surface that don't show much variation and looks almost stationary). The second normal result ends up forming the shallow parts of the lake (the pieces of the surface that shows more variation and looks like its moving faster). This second normal result is calculated by mixing (adding) the result of plugging a Medium size waves normal map to a 4WayChaos node and plugging a Small size waves normal map to a 4WayChaos. The (1,1,0) modulating the small wave intermediate result, before its added to the medium size wave result, is because we want to perturb the medium size wave with the small size wave but only on the x and y directions. The z is kept the original as obtained from the 4WayChaos that is plugged to the medium size waves normal map.
Another new concept is that of switches nodes inside the shader. There are two: Add Sea Foam (X) and Add Reflection Map (Y). They provide two alternative outputs based on whether they are set to true or false. The calculation of the last input in this shader material is Base Color and its result relies heavily on these switches.
When X is FALSE and Y is FALSE: We take the Fresnel water color calculated earlier with the help of the normal map result converted into world coordinates. These are used as the normal input of the Fresnel node and we are done.
When X is TRUE and Y is FALSE: We take the Fresnel water color from above and linearly interpolate it with the moving foam texture by using the foam texture's green channel (1 where its 100% foam and 0 where its 100% ocean). Let's call this Fresnel Foam color. This Fresnel Foam color is linearly interpolated with the regular Fresnel water color using the moving Height Texture (after it has been scaled by using different math parametrized nodes) red channel. This means that the base color will be fully Fresnel foam color where the wave rises the most and fully Fresnel water color where the wave rises the least.
When X is TRUE and Y is TRUE: We take the result from above and add it to the result of the reflection cubemap network. The cubemap network takes the result of sampling the reflection cubemap and modulates this against the result of multiplying the moving foam texture green channel, the moving wave elevation texture red channel and the Fresnel output (the one calculated with the moving normal maps).
When X is TRUE and Y is FALSE: We take the result from above and add it to the result of the reflection cubemap network. The cubemap network in this case takes the result of sampling the reflection cubemap and modulates this against the resulting Fresnel water color.
CamWorldBiasPos + [(PixWorldBiasPos - CamWorldBiasPos) * (SceneDepth / PixelDepth)]
Where PixWorldBiasPos - CamWorldBiasPos = Cam2PixWaterSurfaceV = Vector from camera to water surface
CamWorldBiasPos + [Cam2PixWaterSurfaceV * (SceneDepth / PixelDepth)]
Note what happens at the shore: SceneDepth / PixelDepth = 1.0 aprox. Hence CamWorldBiasPos + Cam2PixWaterSurfaceV is a ray from camera to water surface where the z component of this vector is zero.
Then the z component of this resulting vector math is taken and passed through a 1-x node. In our shore example, 1 - (0) = 1. But then this is divided by 'shore depth' parameter to control the alpha between 0 opacity and the base opacity. This creates a smooth transition between water and shore. When the water is deep, x is less than zero and so 1 - x is always greater than one ensuring a full base opacity in the lerp.
This 1 - x is also used to influence the lerp between the deep water color and the shallow water color in a similar manner as the opacity with the exception that a divide by parameter factor and power using parameter exp nodes have been added in the middle to add customization. Eventually the result of the deep vs shallow water lerp will be taken into account for the material's base color input calculation.
For the normals and the roughness inputs of the material, the exact same node network described for the lake water material is used. Same idea of using the macro variation texture along with the medium and small normal maps.
The most complicated network in this material is the base color input network. It gets complicated because this implementation also calculates refraction values in the base color as opposed to using the refraction input of the material. At a high level the author describes that the intent for the refraction is to built in a refraction behavior where shallow parts of the water don't distort as much and deeper areas of the water do. In order to do this he leverages on the normals (x,y) final result to index into a render-to-texture texture (here called SceneTexture:BaseColor). Basically he gets the pixel screen coordinates and reads back its result from the SceneTexture:BaseColor. This by itself would not do anything since this would only read back the value set before and set it again. The key in understanding this is that these screen coordinates u,v's are distorted using the final normal x,y values (which themselves have been rescaled using the depth factor mentioned at the beginning). Because distorted normals are added to the screen space pixel u,v's the result is that the value read at pixel u,v will contain contributions of the neighboring pixels at (u+x, v+y). This is how the distortion works. And because of that depth factor the distortion is greater at deeper water. This distortion value is modulated by the Shallow water color vs Deep Water Color lerp. This result is further modulated by a Fresnel result between two water colors. This Fresnel node output also controls the alpha of the final lerp to the base color input. This final lerp takes into account the reflection cube result vs the final calculated color. Hence the reflections are greater when the camera is almost perpendicular to the surface.