How to interact with Foliage using Physics, Rigid Bodies & Skeletal Meshes in UE

  Рет қаралды 6,447

Ghislain Girardot

Ghislain Girardot

Күн бұрын

Пікірлер: 39
@ghislaingirardot
@ghislaingirardot 6 ай бұрын
A couple of things from all the feedback I gathered: 1 - Static instances could be simply scaled to (0,0,0) for the skeletal swap, instead of removing/adding instances! You'd then need to store that index in the skeletal blueprint so you can revert that instance's scale back to its initial (x,y,z) scale to swap back with the static instance. 2 - Static instances could be configured to have a simple spherical collision and overlap events could be triggered on your character to get instances you'd be overlapping with. The 'OtherComp' hit component could be cast to an FoliageInstancedStaticMeshComponent and the 'OtherBodyIndex' would thus point to the instance's index, to trigger the skeletal swap. That would allow you get rid of the 'get instances overlapping sphere' method and solve the spatial query problem by letting Chaos handle that optimization on its own. 3 - The dual character capsule setup is unecessary. You can call 'IgnoreActorWhenMoving' function on the character's main capsule and provide the spawned skeletal actor to prevent the two-way interaction! Thanks to all of you for your very valuable feedbacks!
7 ай бұрын
I made similar thing about month ago and had most of the same problems and found few things. You don't need to replace skeletal meshes with static meshes, there is render static bool on skeletal mesh component, that renders it without bones and you can change it in runtime. I placed them in level as bp with sk components and tried to turn off tick on bp, but through insights I found that skeletal meshes are still ticking separetly, so you have to turn them off too, that was quiet heavy on CPU. There is also only tick pose when rendered option on sk component and you can also turn off simulate physics, when you are far from it. Disabling skin cache for sk asset can get you some performance, because you don't need it when its interactive.
@ghislaingirardot
@ghislaingirardot 7 ай бұрын
Oh, very interesting! Thanks for the info, I'll check that out.
@CAyou
@CAyou 6 ай бұрын
Crazy tip!!
@trevor4664
@trevor4664 6 ай бұрын
Are you available for hire? I could use some help creating a good interactive foliage system
@ghislaingirardot
@ghislaingirardot 6 ай бұрын
@@trevor4664 me? nop
@trevor4664
@trevor4664 6 ай бұрын
@@ghislaingirardot no the guy who started the comment thread
@kettenotter
@kettenotter 7 ай бұрын
I had the same experience with lightweight instances! What a pain. But in theory they can do things which are very hard to do by yourself. If I remember correctly they will do some conversion under the hood if you trace against them they will get converted as soon as you acess the underlying actor. So the pointer will point to an actor which doesn't exist yet. Or was it on trace hit? No idea. And no idea if it actually works. But sounds pretty cool especially if you don't have to replace line trace code and such.
@ghislaingirardot
@ghislaingirardot 7 ай бұрын
Yup, I've seen something like that using a trace hit. But what if I don't want to do traces? :D Or maybe the way to go is to do a multi-capsules trace in place, at the current's character position, and check hit actors :shrug: I dunno, it felt soooo sketchy to use haha. I'm sure it'll improve though.
@Ziboo30
@Ziboo30 7 ай бұрын
@@ghislaingirardot I really don't think it would be unmanageable to make it work large scale. I'm not super familiar with FoliageInstanes, but I am with ISM and tracing + switching is pretty fast. What I would do instead of a BVH, is to simply chunk all instances into cells (volumes), so you wouldn't iterate over all of thems, but only the ones in cell the player is currently in. Sure it will be a little more drawcalls depending on your cell size, but would definitly be worth it :) In 5.4 if you can use PCG and enable runtime partition generation, it will chunk them automaticly based on the Grid Size you choose :)
@ghislaingirardot
@ghislaingirardot 7 ай бұрын
@@Ziboo30 Yup! The way I see it, there are two ways this could be scaled up: 1) to support a large world, in that case yeah there are solutions like you mentioned it. ISMC could be used to create a grid, like you said. You could also make your foliage have simple collision and rely on overlap events on your character to get the ISMC & instance index upon overlap, and let Chaos do the heavy work of partitionning/spatialization. Definitely doable! 2) to support a large 'simulation context', meaning, have many actors interacting with the foliage or a large scale simulation to support wind etc. In that case this technique is definitely not scalable.
@sigxfs
@sigxfs 6 ай бұрын
Amazing tutorial. Would you consider doing a tutorial for making an interactive snow material / system? I tried making one using parallax occlusion mapping and render targets but never got it fully working.
@JeckleCed
@JeckleCed 6 ай бұрын
Au lieu de supprimer une instance et l'ajouter de nouveau plus tard, il est possible de passer une transform avec un scale de zéro ( via la fonction UpdateInstanceTransform ) C'est une technique utilisé communement
@ghislaingirardot
@ghislaingirardot 6 ай бұрын
Ah ben oui je suis con! Je suggérais de faire ça dans le vertex shader mais on peut juste faire ça en effet xD
@QuakeProBro
@QuakeProBro 6 ай бұрын
I would love to see you implement this with the actor pooling you've mentioned. I might give it a shot aswell if I have the time. This could be like an automatic solution for limiting the amount of skeletal meshes you want to simulate at once, if there are multiple pawns interacting with foliage, since the system is dependant on the amount of pooled actors you have spawned in the beginning. We may need to implement prioritization around the player, since this is the area we want to see the effect all the time. And what about using two LODs of the skm, one with more bones and one super simplified with for example only the root bone, that is only used if another pawn in medium distance is interacting with the foliage? I have no idea if that would even be worth it regarding the extra work and the visual effect tho.
@ghislaingirardot
@ghislaingirardot 6 ай бұрын
Yup, doable. I did that at one point. The thing is, it adds quite a bit of nodes to implement the pooling thing, and even more so if you want to add a priority & LOD system, so because of the massive blueprint overhead, it can actually cost more to run that logic in BP than the performance gain it gives... In CPP that'd be a different story
@QuakeProBro
@QuakeProBro 6 ай бұрын
Hmm yeah that makes sense. I thought of comparing player position & instance transform inside the foliage actor, if it’s over a certain threshold we notify either the LOD0 pool or the LOD1 pool via an interface, see wether there is a skeletal mesh available and place it. The interface only sends over the transform to the pool. But I guess we would also need to store indices to return the correct skm to the pool + looping through the pool array to either compare transforms, get a bool or int, whatever we use to determine if a skeletal mesh is available or not. That indeed feels a bit much compared to simply spawn & destroy 😅 I‘ll test if this works for my project or not. I‘m still sad, that the lightweight instance system isn’t really working, since it sounds great on paper. Great video as always!
@ghislaingirardot
@ghislaingirardot 6 ай бұрын
@@QuakeProBro Yeah something like that would likely work. Pooling shouldn't too big of a hassle to implement tbh :) Good luck!
@perfectionist724
@perfectionist724 5 ай бұрын
Could you tell me how you setup the root? I set mine to kinematic. No collision. No gravity. I always get an error from ue. Saying physics is not enabled. But it is. Thanks if you can help
@ghislaingirardot
@ghislaingirardot 5 ай бұрын
That's likely unrelated to the bones/physics bodies. I'm sure it has to do with your skeletal component's collision settings
@perfectionist724
@perfectionist724 5 ай бұрын
@ghislaingirardot ok thanks
@Peter-u9r1o
@Peter-u9r1o 2 ай бұрын
I have experienced the same pain in creating a simple physical plant as you have. I thought I was lonely. Excuse me, have you ever tried to add wind to a physical skeleton with constraints? I don't understand why force doesn't work, I Googled everything I could, why they created Chaos and didn't give documentation to it. Tell me if you know how to set it up, but I'm missing some kind of checkbox
@brycegeurts3345
@brycegeurts3345 Ай бұрын
I created a system like this earlier this year. I used a box collision to detect what grass to do the physics on. Then I wrote the physics from scratch in c++, and sent the physics calculations to the shader and used the vertex shader/position offset in the material. I had hundreds of thousands of grass meshes, and it ran at 60 fps. Not a win or a fail. Mediocre results tbh. Doing physics on the CPU is a deadend.
@ghislaingirardot
@ghislaingirardot Ай бұрын
I'm assuming you tried multithreading? Physics in game engines is always done on the CPU so I wouldn't call it a dead end. To simulate grass tho, hmmm maybe :p Still, 60 fps doesn't sound too bad. Impressive!
@nindyatisa2759
@nindyatisa2759 5 ай бұрын
how i make variation plant interact foliage?
@cinemarellik
@cinemarellik 2 ай бұрын
Sorry, I was thinking about a full wind simulation of one of my hero plants. (without WPO, only wind physics) My guess is that: the physical wind that exists in UE has no effect on physical bodies and their constraints. If I put force 50 or force 50000, it looks the same. Could you rebut that, or confirm it? I see a wind simulation of a complex physical plant just impossible inside the UE (I can ask in the Discord this question, but I do not know should buy for 3, or 10 euros patreon as I for 3 is just reading the Discord?) excuse me. thank you so much
@ghislaingirardot
@ghislaingirardot 2 ай бұрын
Afaik, the global wind effector has long been deprecated in UE, but I could be wrong! I don't suspect it to work with physical bodies no but I didn't confirm it. Nothing's preventing you from looping over all physics bodies and adding a force directly in BP though.
@abdoulraoufgambo
@abdoulraoufgambo 7 ай бұрын
Merci pour le bon contenu !
@ghislaingirardot
@ghislaingirardot 7 ай бұрын
Merci à toi pour ton retour! 👍
@LyriaStudio
@LyriaStudio 6 ай бұрын
Hum, et si on utilise le lightweight instance, qui permet de changer automatiquement un ISM en actor correspondant, ce serais pas plus pratique ?
@ghislaingirardot
@ghislaingirardot 6 ай бұрын
Il y a toute une partie de la vidéo qui est dédié à ce sujet 🤷
@LyriaStudio
@LyriaStudio 6 ай бұрын
@@ghislaingirardot Mince, j'ai du looper, pourtant j'ai vue la vidéo entière 🤔
@ghislaingirardot
@ghislaingirardot 6 ай бұрын
@@LyriaStudio ben y a un chapitre LWI à 9:35 - Lightweight Instances :D
@tmdquentin5095
@tmdquentin5095 7 ай бұрын
Est-ce qu'il ne serait pas simplement possible de faire un capsule trace sur le tick ou sur un timer et de simplément convertir les objets qui sont dans le hit?
@ghislaingirardot
@ghislaingirardot 7 ай бұрын
Tout à fait possible. Il a été porté à mon attention que tu peux configurer les static foliage asset pour avoir une simple primitive de collision et utiliser un overlap event sur ton character pour récuperer les instances avec lesquelles tu dois interagir! Tu peux cast le hit actor to FoliageInstancedStaticMeshComponent et le OtherBodyIndex corresponds ducoup a l'index de l'instance! Bien mieux que ce que j'ai montré dans la vidéo :)
@tmdquentin5095
@tmdquentin5095 7 ай бұрын
@@ghislaingirardot exactement, quelque chose de la sorte. Je crois que le mieux serait d'utiliser une interface au lieu d'un cast.
@evanlane1690
@evanlane1690 6 ай бұрын
Yesssssss
From Beginner to Expert: Niagara's NeighborGrid3D
1:26:17
Ghislain Girardot
Рет қаралды 9 М.
An unusual technique to create cheap fluid VFXs...
31:03
Ghislain Girardot
Рет қаралды 7 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
I Made a Wave Function Collapse Castle Generator in Godot
25:30
RachelfTech
Рет қаралды 87 М.
Using Physics to Improve your Shots in Unreal Engine 5
11:35
William Faucher
Рет қаралды 318 М.
How Not To Make An Environment
24:43
caponeart
Рет қаралды 28 М.
Experimenting with a novel technique to create 2D wind in UE5
35:30
Ghislain Girardot
Рет қаралды 15 М.
Spawning Actors in UE... It's complicated.
14:46
Ghislain Girardot
Рет қаралды 3,6 М.
When Your Game Is Bad But Your Optimisation Is Genius
8:52
Vercidium
Рет қаралды 1,6 МЛН
Adding features to UE with Scriptable Tools: let's paint some FLOW MAPS!
42:00
A deep dive into Volumetric Clouds & Systemic Weather in UE
3:34:00
Ghislain Girardot
Рет қаралды 3,5 М.
How I implemented a Radar System in UE
22:09
Ghislain Girardot
Рет қаралды 2,2 М.