Batching SkinnedMeshRenderer - 1000 Zombies over 60 FPS

  Рет қаралды 51,906

Dr. Shahin Rostami

Dr. Shahin Rostami

Күн бұрын

Пікірлер: 116
@ShahinRostami
@ShahinRostami 9 ай бұрын
For anyone visiting in 2024 - I ended up needing this in a recent project and it seems to still work. Deployed to iOS using Unity 2022 LTS.
@Rdp0300
@Rdp0300 9 ай бұрын
no this is not working in unity 2021
@Rdp0300
@Rdp0300 9 ай бұрын
materials became purple... maybe shader is not supported in URP?
@ShahinRostami
@ShahinRostami 9 ай бұрын
@@Rdp0300 That may be the case - I've only used the built-in renderer. I think I remember seeing URP discussed in their GitHub issues, and someone may have linked a modified version for that supports it. Worth checking it out if that's what you're after.
@pablomonfortgames6723
@pablomonfortgames6723 6 ай бұрын
@@ShahinRostami wants hdrp version if not useless stuff , im stuck between pipelines and this damn feature.
@amac333
@amac333 3 жыл бұрын
could you offset their animations and still have the batching?
@brianknox3778
@brianknox3778 2 жыл бұрын
Wow, that is really involved! I am thankful that you took the time to show us the steps! Thank you!
@gabrieltarzia5640
@gabrieltarzia5640 4 жыл бұрын
You saved my Life. Thank you so much. But i need to ask , can i use this to instantiate and change animations in real time for only single of the meshs? Or all the meshs Will copy what the base mesh is doing?
@icebear7857
@icebear7857 27 күн бұрын
Did you find an answer to this? I need to use GPU instancing in a game and the animations have to played when required.
@lawrence9713
@lawrence9713 3 ай бұрын
I almost got a heart attack when I looked at the bottom right to check the clock. Noway it could have been 18:19 already Great video. Saved to try it later
@ShikariVento
@ShikariVento 5 жыл бұрын
Looks like season IV of Overlord.
@The_CubeMan
@The_CubeMan 4 жыл бұрын
I am on Unity 2020.1.8.f1 and everything is working until I hit 5:39, the step where I need the Asset Bundle Browser, which is no longer available in the Unity Package Manager. From my understanding Asset Bundles are now deprecated. Is there an alternative solution to this that works on the current version of Unity?
@mitchellryandev
@mitchellryandev 3 жыл бұрын
Did you find a solution?
@ViatcheslavTarasov
@ViatcheslavTarasov 3 жыл бұрын
@@mitchellryandev The solution: docs.unity3d.com/Manual/AssetBundles-Browser.html
@okandemirkaya9066
@okandemirkaya9066 3 жыл бұрын
@@mitchellryandev You can dowloand via unity and upload unity using Package Manager.
@parsec3d
@parsec3d 3 жыл бұрын
Is there a way to make them use on the fly random variations or time offset sections of the animation?
@imaginationrabbit
@imaginationrabbit 5 жыл бұрын
Excellent walkthrough/tutorial- thank you!
@ShahinRostami
@ShahinRostami 5 жыл бұрын
Thank you, I'm glad you found it useful!
@influency4075
@influency4075 4 жыл бұрын
Does it work with URP ? Thanks :)
@Kalificus
@Kalificus 3 жыл бұрын
bump
@kevincomerford2242
@kevincomerford2242 3 жыл бұрын
@@Kalificus NO. At least not out of the box. It needs to be converted.
@Galathea000
@Galathea000 5 жыл бұрын
It would be interesting to see what exactly takes up all the cpu time in the non instanced version. I doubt that draw calls account for most of that.
@skydrowdev
@skydrowdev 3 жыл бұрын
Maybe something related with the bone transformations and the weights? Edit: after a bit of research, I found that all the skinning calculations are done in the CPU. That explains the bottleneck. Source: blogs.unity3d.com/2018/04/16/animation-instancing-instancing-for-skinnedmeshrenderer/
@al-iom
@al-iom 5 жыл бұрын
I'm realy waiting for the next video of you modify the shader to make compatible with the animation instancing.
@atakanarkan6745
@atakanarkan6745 5 жыл бұрын
I did it step by step but in game view character is invisible how can ı solve this?
@germiyanbey1
@germiyanbey1 5 жыл бұрын
Hi Dr. Shahin, any plan to cover modifying Standard Shader with adding vertex shader capability? It is mentioned at 3:33 in the video, but I couldn't find any tutorial or information about that, and Standard Shader is not accepting any edit. And Shaders that AnimationInstancing offers are very limited. Thanks for the great video, I will appreciate very much if there could be any Standard Shader support.
@ShahinRostami
@ShahinRostami 5 жыл бұрын
Hi - it’s something I’ve done myself using their documentation, but I haven’t made a video on it yet. Did you figure it out in the end?
@germiyanbey1
@germiyanbey1 5 жыл бұрын
@@ShahinRostami I followed forums and some unofficial tutorials and it was a difficult process and it gave various different errors during the process. After I erased all errors by searching each error in internet, then I have these errors preventing the Shader working (I see these below three errors on .shader object in inspector). And I couldn't find a remedy to these last problems at the end, therefore I stopped working on this completely sadly. Errors (3): 1-unrecognized identifier 'UNITY_INSTANCING_BUFFER_START' Compiling Vertex program with DIRECTIONAL Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR 2-unrecognized identifier 'appdata_full' Compiling Vertex program with DIRECTIONAL Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR 3-Duplicate #pragma vertex found, ignoring: #pragma vertex vertBase
@germiyanbey1
@germiyanbey1 5 жыл бұрын
Lastly, using Animation Instancing with Mesh Renderers seem to be very difficult process, which this method seemed to me not optimized for working with Mesh Renderers yet and need some modifications I think. If the Zombies in your video have swords or shields on the rigs (right hand and left arm) things easily go messy.
@louisedbrooke1189
@louisedbrooke1189 5 жыл бұрын
Brilliant tutorial Shahin, I'm looking forward to the next one in the series!
@Athomield3D
@Athomield3D 5 жыл бұрын
Thanks for the walkthrough !! Please don't forget attachements (non skinnedmeshrenderers like swords/weapons...) for the next video !
@ShahinRostami
@ShahinRostami 5 жыл бұрын
You're welcome! I'll make sure to include that in the following videos. It would be great if you had a particular model (asset store?) that you'd like me to use for the demonstration
@Athomield3D
@Athomield3D 5 жыл бұрын
@@ShahinRostami sorry for the late reply. I have a project which I'm working on in which I have failed to get attachments to work. If you need a model I can send u one from my game. Otherwise any skninned mesh with any normal mesh would work ie. A shpere for a helmet. -regards
@ShahinRostami
@ShahinRostami 5 жыл бұрын
@@Athomield3D That would be great if you could send a model, this way I can see the exact issue when trying to create the animation texture. My e-mail is hello@shahinrostami.com
@80sOGRE
@80sOGRE 4 жыл бұрын
Question - Which is more processor efficient ? 1) 100 chairs and tables combined as 1 object OR 2) 1 set of chairs and tables instanced 100 times and statically batched ?
@Rdp0300
@Rdp0300 9 ай бұрын
i cant see the asset bundle browser in package manager ? i am using 2021.3
@evaluator8906
@evaluator8906 Жыл бұрын
I have a character model that I wanna do this on but does the characters need to be able to batch if their Animator components are turned off? Because when I close them, they still don't batch...
@polygonware6469
@polygonware6469 2 жыл бұрын
What about the shadows video?
@Pablo-wi4gj
@Pablo-wi4gj 2 жыл бұрын
The animatorController does not appear on the gameObject during the playmode, even though that it is attached in my prefab. How can I fix that?
@Th3Shnizz
@Th3Shnizz 4 жыл бұрын
I mean it's really cool and all, but I wonder if it works the same way if all the animations aren't running at exactly the same time you know? Like seeing 1000 zombies all do exactly the same things at exactly the same times is not something that would be very interesting in game, however, if we look at a game like "World War Z" you can imagine how powerful this system would be if we can have 1000 zombies doing maybe a handful of different animations with each their own offset or whatever....
@okandemirkaya9066
@okandemirkaya9066 3 жыл бұрын
Everything okay in editor, when I build a game to android, I get "Object reference not set to an instance of an object'" error. How I solve this problem ?
@okandemirkaya9066
@okandemirkaya9066 3 жыл бұрын
I solved the problem. I load wrong bundle. We have load StreamingAsset->AssetBundle->animationtextures.
@zeggxr1539
@zeggxr1539 Жыл бұрын
is it working with the different animation variants, like one of the zombies were walking the other will attack an the other will stand on idle etc...
@Haxel0rd
@Haxel0rd 2 жыл бұрын
While this is a nice tutorial with great advice, it seems to not work for HDRP without modifying the shader (tested in Unity 2021.3.2f1, HDRP, got pink zombie and ingame it did not appear and made game laggy).
@ItsSherifff
@ItsSherifff Жыл бұрын
Is there any way to enable gpu instancing on this while using a custom shader graph?
@Trasqual
@Trasqual 2 жыл бұрын
This is great, thank you. But I have a problem while trying to change the color of my instantiated characters. I use property blocks to change color and it seems to work in the inspector but the renderered character is plain white. I tried changing the materialblock every frame but it didn't work either. Is there a work around? Thanks again
@nv7287
@nv7287 2 жыл бұрын
It would be nice to see how to modify a custom shader :) like toony colours shader and add shadows and other animations
@al-iom
@al-iom 5 жыл бұрын
Hello Shahin, VERY GOOD JOB, it's realy amazing. I have question about shaders. Can I use shader graph instead animationinstance shader ? How if it's possible ? Many thanks.
@okandemirkaya9066
@okandemirkaya9066 3 жыл бұрын
Thank you for asset. Everything okey in editor and pc but when I add 15 same model (zombie) in empty scene, fps decrease 15-20fps. How I do for solving this problem ? what should ı do for solving this problem ?
@krischmiel2231
@krischmiel2231 2 жыл бұрын
Hi It works but my animation looks bad. My model sways
@alifkamaljauhari1161
@alifkamaljauhari1161 11 ай бұрын
Hello! I am currently developing a VR application for Android focused on virtual concerts, using these assets to create the crowd. While in the editor, everything runs fine. But why is it that after building the application, all the crowd disappear? Do you have a solution?
@ShahinRostami
@ShahinRostami 11 ай бұрын
Hello! It's been years since I've touched this, but I remember it being an issue with the AssetBundle generation. All the best.
@alifkamaljauhari1161
@alifkamaljauhari1161 11 ай бұрын
@@ShahinRostami Thanks but what should i do next?
@puneethraj4040
@puneethraj4040 4 жыл бұрын
But these shader doesn't work with HDRP :(
@ShahinRostami
@ShahinRostami 4 жыл бұрын
Try creating an issue on the repo!
@puneethraj4040
@puneethraj4040 4 жыл бұрын
@@ShahinRostami OKAY
@brianknox3778
@brianknox3778 2 жыл бұрын
NO SHADOWS: You ended it by saying you'd address "shadows" next, but I can't find this video. :( Was it problematic, or did you just have more important things to do?
@ShahinRostami
@ShahinRostami 2 жыл бұрын
Hey Brian! I can't remember what got in the way of these videos - it was likely work!
@sudarshanshetty1791
@sudarshanshetty1791 5 жыл бұрын
can you pls tell me how to play with multiple animations for a single character with the same method?
@ShahinRostami
@ShahinRostami 5 жыл бұрын
I'm glad you found it useful. I may make a video on this in future, but in the meantime here is how you do it: 1. In your script, create a public variable of type AnimationInstancing (use the AnimationInsttancing namespace) 2. In the Unity editor, drag over the GameObject which has the AnimationInstancing script attached to it, over to the newly created AnimationInstancing property in your own script. 3. You can now use the PlayAnimation(int index) or PlayAnimation(string name) method on the AnimationInstancing class (see github.com/Unity-Technologies/Animation-Instancing/blob/master/Assets/AniInstancing/Scripts/AnimationInstancing.cs)
@zxz8917
@zxz8917 5 жыл бұрын
Hi, I wanna to ask you, I build project into exe format, but I don't display the role after running exe. What's the reason for this? Can you tell me, please. Thanks!!
@dev_emre
@dev_emre 3 жыл бұрын
Hello, were you able to solve the problem?
@okandemirkaya9066
@okandemirkaya9066 3 жыл бұрын
@@dev_emre Emre, kullandıgın versiyon ve assetbundledan dolayı olabilir problemin. Tam olarak ne sorunu alıyorsun
@dev_emre
@dev_emre 3 жыл бұрын
@@okandemirkaya9066 Problemim tam olarak şöyleydi, PC editörde her şey gayet sağlıklı çalışıyordu fakat IOS build aldıktan sonra telefonda karakterlerim render olmuyordu. "LoadAnimationAssetBundle" IEnumerator 'ını awake fonksiyonunda çağırarak problemi çözdüm şuan problemsiz çalışıyor.
@okandemirkaya9066
@okandemirkaya9066 3 жыл бұрын
@@dev_emre Evet ben de o şekilde çözdüm sorunu. Peki sen "Object reference not set to an instance of an object." hatası aldın mı mobilde. Editorde bir sorun yok calısıyor fakat andoridde bu hatayı alıyorum karakteri olusturuyor ama bunda da render etmiyor.
@dev_emre
@dev_emre 3 жыл бұрын
@@okandemirkaya9066 Hayır öyle bir hata almadım ama benzer bi hata alıyordum şuan tam hatırlayamadım aldığım hatayı ama bundle dosyalarını silip yeniden create edince düzelmişti. Bunu bir dene istersen.
@franciscojoseconesacatala6028
@franciscojoseconesacatala6028 5 жыл бұрын
Hi Shahin, can I use this method for more than 2k characters? It´s for a football game
@ShahinRostami
@ShahinRostami 5 жыл бұрын
Hi Francisco. It depends entirely on the mesh, scripts attached to your characters, materials, etc., and on the minimum requirements for your game... in this video, we went to around 1000 zombies without any issues. In another video (kzbin.info/www/bejne/jXbTgHqOot5lbsU) we go to around 4000 with a different mesh and script. Is this for a stadium audience? There may be more suitable techniques if that's the case. I hope you find the video useful!
@franciscojoseconesacatala6028
@franciscojoseconesacatala6028 5 жыл бұрын
@@ShahinRostami Hi!! After 1 month it works!! But I have a problem in the building, not showing any issue script on the debugin but doesnt show the geometry, in editor works fine. I tried to check gpu instancing and doesnt work too, help me pls T.T
@ljhoser5842
@ljhoser5842 3 жыл бұрын
I would recommend using a fake crowd in a football game, most do
@emrekorkmaz5115
@emrekorkmaz5115 4 жыл бұрын
I get the errors "Assertion failed" and "You should call LoadAnimationAssetBundle first." in android build. How can I fix this? Please help me :)
@okandemirkaya9066
@okandemirkaya9066 3 жыл бұрын
Emre merhaba, AssetBundleBrowserı indirip asseti build ettin mi ?
@mooooooon9296
@mooooooon9296 4 жыл бұрын
Can we use this for AI ? will the colliders still work ? can you explain with more detailed examples like AI.
@lifeartstudios6207
@lifeartstudios6207 4 жыл бұрын
I'd like to know as well
@MyChannelWNW71
@MyChannelWNW71 4 жыл бұрын
I do everything as shown. My characters are textureless even thou there is a texture .png set in material (shader set the same as tutorial shows). In play mode those characters are totally invisible
@trash2treasure786
@trash2treasure786 3 жыл бұрын
me too
@stuartrichards54
@stuartrichards54 3 жыл бұрын
@@trash2treasure786 me 3
@tenpen7
@tenpen7 4 жыл бұрын
When I press Generate in the Animation Instancing window, it creates a clone of my character, but then just sits there with no indication that it's doing anything, I dont get an Animation Textures folder, how long does the generation process usually take?
@tenpen7
@tenpen7 4 жыл бұрын
Its because my anim controller uses animation blending and I dont think instancing likes those kinds of transitions
@tenpen7
@tenpen7 4 жыл бұрын
Now it works but i went from 25 fps using only CPU instancing, to like 3 fps using animation batching, everything seems to be working correctly as the current number of batches has been dramatically reduced. Any reason this could be having an adverse affect on performance?
@luiginicastro1101
@luiginicastro1101 3 жыл бұрын
@@tenpen7 I'm having the same issue, how did you solve it?
@tenpen7
@tenpen7 3 жыл бұрын
@@luiginicastro1101 I forget exactly what I did as it was over a year ago at this point, now I use a gpu instancer that I got from the asset store that does everything I need
@luiginicastro1101
@luiginicastro1101 3 жыл бұрын
@@tenpen7 Thanks for getting back to me! I found another model that worked, so it must have been something wrong with that one model
@kameleonmedia
@kameleonmedia 5 жыл бұрын
i've try everything, it's always invisible. I'm in android and i've updated the code correctly to load assetBundle first... i got no error but the caracter is invisible (in editor). Didnt test yet on android. Any help ? using latest unity 2019
@ShahinRostami
@ShahinRostami 5 жыл бұрын
I haven't tested it yet in Unity 2019 myself, but an invisible model usually means you haven't selected one of the shaders that come with the animation instancing package. Hope it works out.
@stuartrichards54
@stuartrichards54 3 жыл бұрын
Did you ever find a solution?
@KimboKG14
@KimboKG14 5 жыл бұрын
took me some time to find this tutorial but it was absolutely worth it!!!! In wich realm of unity are we working once we hit play? is it classic gameObjects or Entities?
@ShahinRostami
@ShahinRostami 5 жыл бұрын
I would need to check the AnimationInstancing source code but as a guess, classic gameObjects! I’m glad the video was useful :)
@nv7287
@nv7287 2 жыл бұрын
excellent tutorial!
@shawarmagames1689
@shawarmagames1689 5 жыл бұрын
Exactly what I needed. Great tutorial. Thank you for copy pasting 1000s of zombies though. :/
@roxannafabiolastefaniuc3606
@roxannafabiolastefaniuc3606 3 жыл бұрын
Hey guys!! Maybe someone can see my post and reply ... I cant find animation instancing in add component, from there I am stuck... Do you know why? :s
@roxannafabiolastefaniuc3606
@roxannafabiolastefaniuc3606 3 жыл бұрын
nevermind, found the script ;)
@monhasermusic1138
@monhasermusic1138 Жыл бұрын
عالی
@paulbunyangonewild7596
@paulbunyangonewild7596 2 жыл бұрын
Ew, this model has Mario 64 limbs, with skinned mesh renderers, yuck 🤮. Precious draw calls wasted on a cool but unnecessary and easily better replicable effect. It's probably done that way to enable limb detachment, but by scaling the bones down to zero and spawning in a low poly regular mesh, maybe a few decals and overlays for added gore, and you got a more involved but likely more performant effect.
@luiginicastro1101
@luiginicastro1101 3 жыл бұрын
When I go to generate the Animation Instancing on my model I get this error: IndexOutOfRangeException: Index was outside the bounds of the array. AnimationInstancing.AnimationGenerator.BakeWithAnimator () (at Assets/AniInstancing/Editor/AnimationGenerator.cs:514) AnimationInstancing.AnimationGenerator.OnGUI () (at Assets/AniInstancing/Editor/AnimationGenerator.cs:330) Any thoughts?
Unity Performance Tips: Draw Calls
4:24
Lofi Dev
Рет қаралды 201 М.
GPU Instancing Tutorial (No, Seriously, This Is Easy)
11:55
Craig Perko
Рет қаралды 47 М.
Почему Катар богатый? #shorts
0:45
Послезавтра
Рет қаралды 2 МЛН
УНО Реверс в Амонг Ас : игра на выбывание
0:19
Фани Хани
Рет қаралды 1,3 МЛН
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
How to work with humanoid animations in Unity
12:50
Unity
Рет қаралды 45 М.
Unity Performance Optimization - DevLog #9 for My Game, MiLE HiGH TAXi
10:12
Improve Performance 10x Using GPU Instancing || Unity Tutorial
9:43
3 Hours vs. 3 Years of Blender
17:44
Isto Inc.
Рет қаралды 6 МЛН
How To Build Roads Procedurally In Unity with the Splines Package
17:51
Six Grass Rendering Techniques in Unity
24:10
Daniel Ilett
Рет қаралды 55 М.
Citizencon 2017: Teaching a character how to walk on any terrain
23:27