Distance Fields "dynamic" grass tweaking


**Hey everyone, **

I’ve set up a material that uses distance fields to fake interaction when the character walks through it - based on this - (the blueprint has an invisible cylinder that generates the DF, since skeletal meshes don’t).

So far it’s kinda working, stuff is moving, as you can see here:

**Without it: **

With it:

Here is my material setup:

The issue, as you may have noticed, is that ALL the grass is affected and deformed, even just on a flat floor and not near a moving mesh, as you can see here (grass is placeholder and ugly, but you can notice the unwanted effect):

As you can see the whole mesh is just kinda offset, twisted and bent in funky, uneven ways.

My theory: They’re being affected by the floor ? (it’s a landscape) Or maybe they’re even affecting each other ?

I have a no idea where to start fixing this, so I was hoping you guys would have an idea :slight_smile:

Thanks in advance !


I had the same problem. The landscape has its own distance field.
Try to reduce or eliminate the z value by multiplying it with a vector(1,1,0)

Hey Mars007, thanks for your answer

I actually tried that, to no avail, the results remain messed up.

What I find to “fix” the problem was setting the scale range of the grass strictly over 1. If i set the scale range below 1, the grass will get messed up.

“fix” is between quotes because I’d like to be able to set the range below 1, so this is only a temporary fix.

Still looking for insight on this :slight_smile:


You could try to mask the effect by vertex color, so that the bottom vertices don’t get affected by distance field offsets. You could also try a vertex color gradient like you’d do for wind animation.

To properly fix it, you need disable the distance fields from landscapes/floor meshes. Afaik there is no way to distinguish objects within distance fields.

I do have vertex colors so the bottom is not affected, that’s not where the issue comes from i believe.

About disabling the distance fields from the landscape: I can’t seem to find any way to actually do that! Maybe I missed it?

Use gradient information in which direction closest surface is. When it’s pointing down then disable the bend.
Something like this:

float bendIntensity = clamp(1.0 + DirectionToClosestSurface.z, 0.0, 1.0);

Thanks for your answer, not sure where exactly I should put this line of code though ? (I’m an artist :o)

Hey Phil, try using a component mask with R&G channels enabled, B channel disabled, between your clamp output pin and your material WPO pin.


Hey Hippo !

Thank worked wonders! Thanks so much!

Cheers :slight_smile:

Just going to say, I don’t mind people using my work, it’s why I posted it, but the least you could do is credit me instead of saying you made the material yourself.…eld-touch-bend

In any case, glad you got it working! :slight_smile: This was done a long time ago before a LOT of changes to distance fields, I’m surprised it’s still useful.

You may also want to play around with how wide the radius is. I never quite got it to a good universal setting, you may need to configure it a bit to get it looking right and not have the illusion of a phantom force around it.

Hey ! I fiddled with this for so long and tried so many things that I lost track of what I took from where. But you’re right it’s definitely based on your post, so all credits goes to you. (edited the first post)

Thanks :slight_smile: