How to get 'steepness' / slope from a height map?

Hello!
Is it possible to get a slope value from a heightmap in the materials?
I’ve tried the NormalFromHeightmap node and comparing (using dot product) the result to (0,0,1) vector - that works, but it ignores one side of every hill, etc:

Then, I’ve found this:
https://gamedev.stackexchange.com/qu…ight-map-cells
… So now I’m trying to implement it in UE in materials, but in the comments, they say that it should sample from x-1 and y-1 as well - maybe that’s the issue and why one side is ignored here?
I’m trying to implement that now, but maybe some of you will know if that’s possible at all? Or maybe there are some engine functions that do this already in UE?
Thanks in advance, I’d be grateful for any tips.

Update 1: I’ve found this: https://www.parallelcube.com/2017/12…-introduction/
… It looks like it might work - I just need to check if we can control the slope detection ‘sharpness’/angle with that…
Update 2: No luck, it doesn’t seem to work with e.g. simple gaussian gradient.

Normal maps use negatives for the opposite sides which your code may not be accounting for.

You can use this to flip the negatives into positives, do it for both the red and green channel, then append them back into a vector 3 before doing your dotproduct.

That should help it not ignore one side, if the negative was the problem (hard to understand what you want)

Thank you, that’s exactly the thing I was missing. I’ll try that soon.
In the meantime, I’ve made a heightmap -> slope map function too, so for anyone with similar needs, here it is: