Download

Edit mesh normals

Hi,

Is it possible to force the mesh normals to a direction in world space using the material editor? say, all the normals point upwards.

Yes. Well you won’t actually be modifying the normals on the asset, but you can use the vertex normal or pixel normal node to get the normal and apply any transform you want after that. You can also ignore the existing normal and just create a vector three and use it as you would use a vertex or pixel normal.

I’m a little confused. Can you please maybe post a picture?

This is a sphere on a plane. As you see all the normals of the plane point upwards so it has a uniform normal color to it. Now what I want to achieve is to have 1 uniform normal color on the sphere as well. But it is not flat surface so that’s where I’m stuck.

Edit: Problem solved. Thanks! :slight_smile:

Just use Linear Interpolate node to blend from Vertex Normal to 0,0,1. select material node and make sure bTangentSpaceNormal = FALSE.

Note this only works if you can supply the other vector. If you want to use terrain as the other vector, then you need a texture normal map of the terrain.

edit I did not see your edit that it was solved… doh :slight_smile:

Hi Ryan,

Thanks for the info.

As you see I have used DistanceToNearestSurface to generate a mask at the intersection for the sphere. With 0,0,1 the transition is seamless where the landscape is flat but as soon as the landscape start to have normals other than 0,0,1 the seam starts to appear.
Do you have a little easier to understand guide for improving this normals on the sphere at the intersection to match the normal from landscape better?

Thanks! :slight_smile:

Edit: Also a tip for blurring the generated mask would be welcome. (TempAA doesn’t do much good).

You shouldn’t have to blur the mask, just control how long the gradient is by dividing by your target gradient length before clamping. its all in worldspace so the divisor will be the gradient length.

As I said in the previous post, using 0,0,1 only works for flat ground. You could try using the “Distance Field Gradient” instead of 0,0,1, but the landscape will only contribute to that in 4.12. For anything else you will need to have a texture of your landscape saved, and you need to map it to the landscape extents manually in your material and use that texture instead of 0,0,1.

I’m on 4.12.
When using

Distance Field Gradient normals don’t match with landscape the way I have put it together. And you can guide me to see where I have made mistake. My knowledge isn’t complete with these. :wink:

I am not sure if you need to normalize the gradient first… maybe try that?

Also not sure why you are doing that 1 unit offset along vertex normal. the mesh you are checking needs to have distance fields disabled anyways so I am not sure why you need that offset.

It is hard for me to say what else could be wrong without an image of what that looked like between the actual normals and gradient result.

Note that landscape isn’t composited into the DF as an actual distance field value, it is only the height so the resulting normal may be a bit skewed compared to the real normal but I would expect it to be pretty close for gentle slopes. It might be pretty bad for steep cliff edges though.

Ok I just tested that out and the match is not great, but its in the ball park. The only way to get them to match perfectly is with my original suggestion of a saved out copy of your landscape world normals. you can bake it in the editor using the high res screenshot tool.

for gentle slops and very blobby terrain it works great. as soon as you have small features like your tiny sharp hill above, that will create mis matches since the distance fields are not high enough resolution to match exactly.

I disabled DF on the sphere. This is the setup and the result so far. With DFGradient it’s looking ok on the flat areas but it still goes off on the slopes.

It would be far more useful to see the actual normals rather than a lit image. But either way I am pretty sure you are doing it right. Here are my results.

the fade alpha:

normals look good from this side:

but from the back, with everything in the exact same position, things aren’t so great:

There may be some kind of clipmap bug creating the harsh seam in the middle, but the rest is pretty much as good as this is going to get.

you can tell its working if the colors of the normals kind of match.

edit just checked with daniel and the straight lines you see in my image above are indeed a heightfield DF bug.

Um sorry can you post a picture of your setup please? my result isn’t as good as yours yet. This is the World Normal view.

Everything seems fine now.

However SSAO ruins it all.

Thanks for the ongoing help Ryan. Really appreciated. :slight_smile:

Glad its working better for you.

About the ssao, it looks like those ssao settings are bad even for the landscape by itself without this distance field trick. You shouldn’t be seeing triangles outlined like that on the landscape.

I’m having a problem in which the basis shape key for my normal edited meshes looks exactly how I would expect, but when I change the face shape in UE4, I get unwanted shading artifacts (as can be seen around the eyes below). I’m hoping some form of normal manipulation as seen here can resolve this issue. I don’t have this problem in Blender or Unity, so I’m convinced this is an issue with UE4, but games like DBFZ and Guilty Gears Xrd have clearly worked around it.

Thanks