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.
@ghislaingirardot7 ай бұрын
Oh, very interesting! Thanks for the info, I'll check that out.
@CAyou6 ай бұрын
Crazy tip!!
@trevor46646 ай бұрын
Are you available for hire? I could use some help creating a good interactive foliage system
@ghislaingirardot6 ай бұрын
@@trevor4664 me? nop
@trevor46646 ай бұрын
@@ghislaingirardot no the guy who started the comment thread
@kettenotter7 ай бұрын
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.
@ghislaingirardot7 ай бұрын
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.
@Ziboo307 ай бұрын
@@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 :)
@ghislaingirardot7 ай бұрын
@@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.
@sigxfs6 ай бұрын
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.
@JeckleCed6 ай бұрын
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
@ghislaingirardot6 ай бұрын
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
@QuakeProBro6 ай бұрын
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.
@ghislaingirardot6 ай бұрын
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
@QuakeProBro6 ай бұрын
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!
@ghislaingirardot6 ай бұрын
@@QuakeProBro Yeah something like that would likely work. Pooling shouldn't too big of a hassle to implement tbh :) Good luck!
@perfectionist7245 ай бұрын
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
@ghislaingirardot5 ай бұрын
That's likely unrelated to the bones/physics bodies. I'm sure it has to do with your skeletal component's collision settings
@perfectionist7245 ай бұрын
@ghislaingirardot ok thanks
@Peter-u9r1o2 ай бұрын
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Ай бұрын
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Ай бұрын
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!
@nindyatisa27595 ай бұрын
how i make variation plant interact foliage?
@cinemarellik2 ай бұрын
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
@ghislaingirardot2 ай бұрын
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.
@abdoulraoufgambo7 ай бұрын
Merci pour le bon contenu !
@ghislaingirardot7 ай бұрын
Merci à toi pour ton retour! 👍
@LyriaStudio6 ай бұрын
Hum, et si on utilise le lightweight instance, qui permet de changer automatiquement un ISM en actor correspondant, ce serais pas plus pratique ?
@ghislaingirardot6 ай бұрын
Il y a toute une partie de la vidéo qui est dédié à ce sujet 🤷
@LyriaStudio6 ай бұрын
@@ghislaingirardot Mince, j'ai du looper, pourtant j'ai vue la vidéo entière 🤔
@ghislaingirardot6 ай бұрын
@@LyriaStudio ben y a un chapitre LWI à 9:35 - Lightweight Instances :D
@tmdquentin50957 ай бұрын
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?
@ghislaingirardot7 ай бұрын
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 :)
@tmdquentin50957 ай бұрын
@@ghislaingirardot exactement, quelque chose de la sorte. Je crois que le mieux serait d'utiliser une interface au lieu d'un cast.