[Shaders-UE4] Retrieve vertex normal after applying displacement

Hi there,
I’ve been trying doing this thing:
I’ve got this landscape, on which I am applying a displacement using a render target texture.

After I apply the displacement, I would like to sample a rock texture on the slope and apply additional displacement using its height, issue is: the vertex normal is not updated after applying displacement.

Do you have any idea on how can I calculate the right vertex normal vector to apply the second displacement?

I don’t care about setting it on the actual vertices, since I’ll be using a tangent normal in the end, but I need this just for the second displacement.

I’ve already tried using derivative from the height texture, resulting in a nice normal, but I can’t then apply it in the vertex shader (I got an error from unreal, related to mixing pixel and vertex shader instructions).

Hope I was clear, thanks anybody for the help :slight_smile:

You need recalculate normals. https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch42.html