Apply dirt/dust/mud texture to portion of a mesh dynamically chosen by overlap/collision). How to?

The idea of this comes from Red Dead Redemption 2, where when you push a human, or sth on a muddy road or similar dirty/sandy terrain the texture of the human is getting dirty/muddy but only the part of him that overlapped the terrain.

Anybody has any ideas of how to to detect this overlapping/colliding section of the mesh and apply the additional texture to that portion of the mesh only (effectively changing the dirt/mud level scalar parameter of the material to a higher level)?

Screencapture won’t do it because even if you know what parts the camera tells you to color, the texture will look Nothing like the actual character during ragdoll.

Instead, I would have the ragdoll effect trigger a state in which distance to nearest surface is used to draw a mask that gets used to apply the mud.

It would probably be something similar to reactive water where you actively draw a specific image to a render target over time.
Except what you draw is driven by the distance to nearest surface node so it should theoretically color parts of the texture which are in contact with the landscape as a mask use within the material…

I would work out the postprocess and render target brush materials for pheasibility before doing the mud material…

This may also be a better way to do snow trails that I hadn’t really considered before. I do hate that screen capture camera…

Ok, this is intresting. I’m not that advanced with materials shaders yet, but I expect that to change in the near future where I will revisit your answer and hopefully understand more of it and even try to implement it.

Im currently working on a solution that might be able to solve this. Might put it up on the marketplace or just put it up for free, requires c++ atm though. Basicly, get the preskinned location of the bones you want to add texture, feed that to the material and use spheremask at the location with the texture/effect. It works on animated skeletal meshes/static meshes and requires no rendertargets. Rendertargets cost to much performance imo, why i have been working on this for a few days now.

@Onarbest but how can you detect this impact/colliding location without eg a way such as the one MostHost LA mentioned? At any rate, I wish you success in your project.

I will test some stuff later today or tomorrow, il get back to you.

Sorry havent got to this part yet, i just worked out how to deform the texture so the “mud” or whatever you want to apply is offset to the skeletal mesh so it looks like its sticking in or out from the mesh.

But i have an idea in mind for recreating the effect from red dead with my overall solution, im gonna try that out soon for detecting the transform of the bones touching the ground where the mud is, the Z axis wont be as accurate as you would want but the direction to where to apply the material from will be im presuming. So it wont be as precise as you would want it to be. Anyhow im onto testing, might take a few hours or some days.

Sure, I don’t think the rdr2 one is too accurate as well. As with everything in this field, if the illusion is sufficiently well done, it should be perfectly fine for most (gaming at least) purposes. Good luck, keep us posted in your progress.

I believe these are the droids you are looking for?