# Normal Map From Float2 With DDX/DDY Nodes?

**URL:** <https://forums.unrealengine.com/t/normal-map-from-float2-with-ddx-ddy-nodes/2053691>\
**Category:** Rendering\
**Tags:** normal-map, unreal-engine, heightmap, Shaders, question\
**Created:** [October 4, 2024, 11:40pm UTC](https://forums.unrealengine.com/t/normal-map-from-float2-with-ddx-ddy-nodes/2053691 "2024-10-04T23:40:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjiggidy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mjiggidy/32/600480_2.png) [@mjiggidy](https://forums.unrealengine.com/u/mjiggidy)\
**Post date:** [October 4, 2024, 11:41pm UTC](https://forums.unrealengine.com/t/normal-map-from-float2-with-ddx-ddy-nodes/2053691/1 "2024-10-04T23:41:00Z")

</div>

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/e/a/4ead2a6d554d2e7d9dcd7f52587f16bc2a7fdc28.png)

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.

---

<div class="post-metadata">

**Author:** ![mjiggidy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mjiggidy/32/600480_2.png) [@mjiggidy](https://forums.unrealengine.com/u/mjiggidy)\
**Post date:** [October 5, 2024, 10:52pm UTC](https://forums.unrealengine.com/t/normal-map-from-float2-with-ddx-ddy-nodes/2053691/3 "2024-10-05T22:52:54Z")

</div>

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:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/4/e444840c28802ca9ee7adc2de4819cfbc13ff5a1.jpeg "Derivatives DDX DDY - Shader Graph Basics - Episode 18") ](https://www.youtube.com/watch?v=1HTMoCaY0xw&t=752)

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” 😉 but maybe this is at least useful info.

---

<div class="post-metadata">

**Author:** ![Frenetic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frenetic/32/1142542_2.png) [@Frenetic](https://forums.unrealengine.com/u/Frenetic)\
**Post date:** [October 6, 2024, 2:42am UTC](https://forums.unrealengine.com/t/normal-map-from-float2-with-ddx-ddy-nodes/2053691/4 "2024-10-06T02:42:48Z")

</div>

This guy helps: [https://www.youtube.com/watch?v=80vOtsNg-9g](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.
