Sign in to follow this  

Foliage Collision

This topic is 823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone,

Does anyone know how the foliage collision/bending works in cryengine? Its a nice effect which I want to create in my own applications.

 

https://www.youtube.com/watch?v=rGZTLnxofBw

I'm not talking about wind or just simulated movement, I'm talking about the physical bending when the player/object goes into the foliage.

I have a few ideas how they have implemented it, like doing CPU side simulation then uploading the matrixes but this seems awfully expensive if you have lots of collisions going on. I was hoping to get this effect on mobile...

It just needs to look vaguely accurate, so I don't mind any shortcuts! tongue.png I'm currently gathering research on this topic so I can think about the implementation for later :)

Thanks
 

Share this post


Link to post
Share on other sites

when researching my "amber waves of grain" question posted here on gamedev, i came across something about their foliage system, and i think it covered the deformation system. but i dont have a link handy, sorry. keep googling - i'm pretty sure the info is out there.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

If your foliage is made of many rotated and scaled meshes which are quads with textures on them you could have a "squashed" set of them which look like something is on top of them. Each time a physics object moves over that area you can mark it as deformed by changing the texture perhaps, and set it back through a set of animations via a timer.

 

I don't have any experience with cryengine so my ideas might be a bit abstract, I am purely thinking how I'd approach the problem in an engine agnostic manner.

 

Let me know if this helps! 

Share this post


Link to post
Share on other sites

They are likeing using an approximation for it. They likely made use of Nvidia's hair to do this, which works based on tesselation.

You won't be able to get that without a pretty penny, but you could use AMD's solution to hair.

Share this post


Link to post
Share on other sites


I have a few ideas how they have implemented it, like doing CPU side simulation then uploading the matrixes but this seems awfully expensive if you have lots of collisions going on. I was hoping to get this effect on mobile...
Do that on the GPU side. Put the foliage bones into a floating point texture, and use a pixel shader to run the physics update routines on them. Do collsiion detection with a sphere/capsule (from a cbuffer or another texture) for the player.

Share this post


Link to post
Share on other sites

Well, does this work with multiple spheres? Does it work with other types of objects?

One thing you could look at doing is a texture that gets projected from above (a heightmap) and you could have a buffer to draw into, with a sphere, and you render the sphere with front face culling so the bottoms of the objects render that are lowest to the ground. Then you output the height of the pixel above the height of the terrain height map. You could also for every pixel output some rotation angle from the center of the object (you may be able to use the normal for something like this).  Since it does seem like you can run a blade of grass from all angles and it doesnt just move down, but it rotates.

Unless they have a generic object like a statue that can be thrown on the grass, it may just be something simpler. The rotation part is what throws me off and would take me a while to think about doing it efficiently.

Share this post


Link to post
Share on other sites

In Crysis 3 they are converting all physics shapes to multiple spheres. If you split grass instances to chunks you can just cull colliders per chunk and it's also easier to update distance chunks less often. Trying to update all grass once might not be best for flexibility and performance.

Share this post


Link to post
Share on other sites

Thank you all for your ideas, plenty of ideas to work with!

The link that tonemgub has a really useful description in it for a more simpler approach. I'm currently not sure how much foliage will be in the application I want to make, so that will affect what I can do with it and how realistic I can afford to make it...

And yeah kalle_h, I think I will need to do that anyway for the simpler systems. Doing sphere collision is quick and easy in a shader :)

As long as I can get it looking vaguely good that should be enough haha!

Thanks again guys :) Hopefully I can start working on it when I have some time :P

Share this post


Link to post
Share on other sites

This topic is 823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this