How to achieve correct Gerstner wave normals?

Hello everyone,

Similar to others who’ve had issues, I been working on converting the equations from [Nvidia’s GPU Gems Gerstner wave article][1] into a material function, specifically equations 9-11. I am confident that my displacement works (I had to switch around the x and y components for the direction though), however I’m not so sure that my normals are correct - at least, they don’t match UE’s standard lighting. For instance, here is how a singular wave looks (with a steepness of 0), with normals on vs normals off (I’m not sure why my normals are reversed - first image - but my greater concern is the sharp lines where there should be more of a blend):

Here’s my material function (I switched around D_x and D_y in order to fix an issue I had with the displacement - reverting them back only switches the direction of the normal):

Did I make a mistake in lining my nodes? How can I get better looking normals using these equations? Thank you for your help!
I also tried computing the normal via equation 12, but this gave me similar results. Here are the parameter values I use:

UV: TexCoords()

Direction: (1,0)

Rotation Center: (0.5,0.5)

Wavelength: 0.1

Steepness: 0

Amplitude: 50

I discovered the solution, but I’m not sure on the cause of the problem… it has to do with the UV input of TexCoords - changing that to my default of world-space gives the desired lighting effect. Aside from other minor tweaks to the material (I also I was using the wrong P for the dot product in the normal - it should be the result of the displacement, not the original position), this was the only change I needed to do to fix it. But I’m definitely stumped when it comes to why…