Normal Map From Float2 With DDX/DDY Nodes?

I am procedurally generating grayscale bump/height data (so I’m NOT sampling a texture here – thus cannot use NormalFromHeightMap, I don’t think) that I need to convert to a Normal map.

ChatGPT suggested I do the following, using DDX and DDY and DeriveNormalZ to create the Normal Map, but (1) I don’t trust ChatGPT and (2) the results are stlil a bit odd/flashy-looking:

I feel like I’m on the right path here but can anyone offer input to improve this? Especially a few things I wonder:

  1. Do I need to scale the values to -1 to 1 before the DDX/DDY? Or is it okay to use 0-1?
  2. Would I Normalize to a unit vector before or after DeriveNormalZ?
  3. Any general input is greatly appreciated. I understand basically what DDX and DDY are doing but obviously applying them for this purpose I’m kind of lost.

Not that anybody else cares about this (lol) but I found a YouTube from good ol’ Ben Cloward that covers using DDX/DDY for my purposes:

Ultimately UE has a PerturbNormalsLQ material function that can be used for this. I still don’t understand the inner workings as much as I’d like to (I wish he went into more detail about how it’s set up, I’d like to learn) and I still end up with some flashy artifacts. So I’m still hoping someone jumps in with a “bro. here’s exactly what to do” :wink: but maybe this is at least useful info.

This guy helps: https://www.youtube.com/watch?v=80vOtsNg-9g

He shows you how to calculate one from a sine’d gradient, last half of the video.

Hopefully helps.