I’ve been trying for the last few days to replicate the behavior of the tall grass in Horizon:ZD as seen below:
It seems far more complex than any foliage interaction I’ve seen before
I’ve tried to approach three ways so far and couldn’t really get anything decent:
Vertex anim in material. You can get some neat effect with that but I couldn’t really get that rotation effect, like a spring bending around. I’ve tried to use, among other things, rotateaboutaxis and get the angle between the normalized dot product of the player and the actor location and spheremasks to push vertices from the player but there’s clearly more to it.
Replace the grass with a physic asset when the player interact with it. This seemed the most promissing ways but I just couldn’t get a soft constraint on the bone that behaved properly AND that didn’t affect the player ability to move. The physic simulation affects both the grass and the player and depending on the strength of the spring constraints I used, the player couldn’t even get through it.
Custom blueprints that calculate a spring-like behavior of one particular grass clump. I got somewhat decent results with that approach, calculating the rotation of the angle that drove the bone of a posable mesh (or that could drove a material instance parameter and rotate it with vertex offset) and when it could get back to its idle position and when to interact with the player. It’s tedious
and there was a few bug but it was close. Biggest issue was that I just couldn’t figure out a way to populate a lot of grass efficiently. I didn’t see placing a blueprint for each grass clump in the scene, happening.
Tried with physic assets again but really can’t get it right. In some scenarios I can even jump on the grass. I couldn’t get the physic asset to interact properly with the player without having the player slowed or blocked anyway. I want the interaction to be totally transparent to the player
So I stuck with a custom blueprint solution that somewhat works, but it’s buggy in some extreme case and isn’t a nice implementation anyway. Each grassclump is a blueprint using a unique material instance to drive the vertex rotation scalar value so I don’t see using 500 of thoses in a map happening.
I did not look really in depth into this tutorial series but I bought the project from Sander Vander Meiren on gumroad, which looks extremely similar, and studied it in depth.
It looks nice and all but it’s very jiggly and from the few tests I ran, only works for smaller foliage. I just couldn’t have a simulation with a larger physical volume that is both reacting very gently and without interferance with the player.
I’m guessing it’s some really advanced shader techniques similar to the foliage in Uncharted 4. They did mention that it’s all done in the shader, but I’m not entirely sure if all plants were done that way. And at 1st glance, this too looks like its using physics
I have been experimenting with grass/foliage interaction as well, but more with the pivot painter stuff.
I implemented what I think Naughty Dog did in Uncharted 4 for foliage a little while ago. It works pretty well, but has limitations. See the comments for a brief idea of how to go about it. Oddly enough this conversation came up in the Discord last night too.
Not seen the Pivot Painter method before but it looks good. In my case I have many pawns and many things affecting the grass so I use the RT to determine object position. Perhaps there’s a good combination here somewhere.
IMO, the best way to solve this is with shaders. Physics and true “collision” is just way to expensive to be useable.
Ah I did see your video. I did try to do the RenderTarget way, but wasn’t sure how to get the object position and use it with the sphere mask and RotateAboutAxis. Atm my shader only works with one actor using the Location. Can you share any more info on how you managed to calculate the position using the Render Target?
I’m certain NaughtyDog did use the Render Target approach for getting the position. I remember seeing one of their tech demos with a render target preview
The render target method isn’t so much about getting the position, it’s more about getting the offset. You just draw the offsets in around the position of the effector. In my case I have a “normal” map material which is just a pinched point, and that draws into the render target each frame. The grass reads back from the render target as if it’s been mapped to the world and offsets verts accordingly. You can combine it with wind etc. too if needs be.
Not sure how well it works in UE4 or if we even have something like this in UE4 but touch bending vegetation is nothing new, Crysis 3 and the old Cryengine 3 had this implement as a standard feature. Back in the days they handled it like in this tutorial…https://youtube.com/watch?v=L0fD_CCbjnI
Something similiar like this in UE4 would be nice.