Can anyone help to translate this shader in UE4 material?

Hi, I’m trying to reproduce the shader used by CD Project on The Witcher 3.
The goal of this shader is to “pixel blend” two material by using normals info instead of creating an heightmap texture (save some memory and more customization)
I know how to height blend two layers with a heightmap texture but I just can’t read this code :

No idea? I think it’s a really usefull shader for landscape and all height blending I’ve seen was always using a heightmap texture with only contrast as customization.

Take a look at the Kite Demo’s terrain material, that does the same thing with a normal blend based on slope.

You mean slope of the terrain or slope of the nornal texture? Because I don’t think there is such shader in Kite demo
Here is the full pdf from the conference https://www.gdcvault.com/play/1020197/Landscape-Creation-and-Rendering-in
It starts at the “Texturing - solutions” section.

The code is pretty much self explanatory. If not, you can copy paste it into custom node as is.

For someone who can read this kind of code but I’m not good with this. I copy the code in the “code” section of a Custom node, then?
Here’s the code in text if someone wants to try :


// Combine vertex normal with background /overlay material normals
float3 combinedVerticalNormal = CombinedNormalsTangent( vertextNormal, verticalNormal, worldTangent, worldBinormal );
float3 conbinedHorizontalNormal = CombinedNormalsTangent( vertexNormal, horizontalNormal, worldTangent, worldBinormal );

// Apply dampening to the background normal
float vertexSlope = dot( vertexNormal, float3( 0, 0, 1 ) );
float3 flattenedCombinedVerticalNormal = lerp( combinedVerticalNormal, float3( 0, 0, 1 ), vertexSlope );
float3 biasedFlattenedCombinedVerticalNormal = normalize( lerp(combinedVerticalNormal, flattenedCombinedVerticalNormal, slopeBaseDamp ) );

// Compute slope tangent for the dampened background normal
float verticalSurfaceTangent = ComputeSlopeTangent( biasedFlattenedCombinedVerticalNormal, slopeThreshold, saturate( slopeThreshold + horizontalToVerticalBlendSharpness ) );
float3 fullNormalCombination = CombineNormalsDerivatives( combinedVerticalNormal, combinedHorizontalNormal, float3( 1.0f - slopeBasedNormalDamp, slopeBasedNormalDamp, 1.0f ) );

// Use slope to lerp between vertical and horizontal surface colors, normals and material params (spec, gloss, fallof)
float3 finalColor = lerp( horizontalColor, verticalColor, verticalSurfaceTangent );
float3 finalNormal = lerp( fullNormalCombination, combinedVerticalNormal, verticalSurfaceTangent );

I would also like to see this shader in action inside UE4