Fast Foliage Collision & Impulse Response

Spent today building a system for allowing foliage & misc objects to interact with any number of objects and impulses from explosions / forces etc.

Thought y’all would like this!
https://youtube.com/watch?v=TDLbjF0dRog

Wrote a whole new manager for animating dynamic material params based on a curve, which also interfaces with the impulse stuff. Looks cool!

Dead chuffed with this.

Nice. Is it coming to the Marketplace ?

Maybe at some stage (probably post game release if at all), currently it requires / relies a bit of project-specific code and some other systems etc.

How is the displacement texture aligned?

It’s aligned in world space (though it doesn’t exist in the world anywhere).

The playable area bounds are defined by a custom world settings class, and are saved to a Material Parameter Collection when initialized. Any material can then “read” from the texture for a given world position.

ah, nice
I had this very idea some time ago, when trying to come up with a solution to interact with foliage (since all other solutions including DistanceFields don’t seem good enough)

luckily for you, you only need small encompassed areas (i.e. all fitting in a room).
how would you do it in a more open world though? having it in an area around the player and having the texture move with the player would require rewriting every frame. or maybe instead of moving with the player it could just be having the world divided into sectors, and only update the textures of the sectors near the player and switch the used textures in the shader (but then it’d mean passing 9 textures instead of 1, which would mean quite some texture samplers)

I think if I was doing open world or large scale (which I will have to do eventually, since I want to use this for a few different game ideas) - I would update the bounding area for the render target based on player position (really easy and nearly free to do). I might even fade out the edges of the RT to nominal values as well. All materials that want to read from the RT need to know the Min/ax bounds to get the correct “area” of it anyway - so there’s no cost other than updating a few floats in an MPC each frame.

All effects would still be drawn in world-space to the render target, but you may need to fade them out quicker or make specialised ones to eliminate ghosting as the RT moves. Alternatively you could step-relocate the render target, and each time you step it - you store the current RT in another material instance, clear the original render target then draw the old version back on top based on the translated position - then continue playing all of the existing impulse effects.

Of course this solution wouldn’t work for highly angled surfaces either- but if you really wanted to you could probably create a special draw material that takes a world normal in, and changes the shape to compensate for parralax. In theory just scaling the X and Y independently in my result by the Dot of the Normal would probably work!