Robots in Unity question

Hey guys, I’m in a bit of a situation. And it’s one I really don’t like.

Alright, think of a robot like the Terminator (just an example), not using that haha.
But alright, Robots like the Terminator have all sorts of moving parts. which okay is fine.

But how do you go about texturing one and keeping performance. My robot, despite how simple it was
went from roughly 200 draw calls in the scene to nearly 1800 when importing my model, and it was maybe 15 pieces.

Which is my problem. How can one truly keep performance with a robot, I thought about making it one solid mesh, unwrapping it, texturing it and then breaking the mesh back into smaller pieces, but then that would I would assume go right back to the same issue it did before. I would rig the robot as a single mesh, but wouldn’t that kind of ruin the motion of how a robot moves. (Hydraulics that rotate motors to move the legs, etc).

Just looking on some potential ideas that could help me with this one.
I’m sure there’s someone out there that has an idea that could work.

Thanks guys!

15 pieces is not the problem. Need more info on what your mesh looks like, how many materials it uses, polys, etc…

1 Like

Well what I meant by 15 pieces is, 15 materials. That’s the least I could break it down to.
Keep in mind this was a concept robot so it’s not the greatest looking.
Most of the polys are coming from the rotating motors (for the legs and arms and feet).

But what I did was, I built half the of the robot (left side) for example, textured all the stuff on the left, and copied it to the right.

So each arm as a total of 2 rotator motors, and each leg has 3, (upper thighs, knees and feet).
each rotor motor is a single material, but the problem I’m having is, I can’t batch these materials, so it’s upping the draw calls with Shadows.

As mentioned I tried to break it down as simple as possible, but the batching is what is killing me.
Granted I am still getting 60 FPS. I’d just like to know how it went from roughly 200 to around 1800.

As you can see in the photo below, it’s reall ynot an overly sophisticated robot.

It’s around 2400 polys I believe. Not inside Unity right this moment.
2735472--194738--Clunker_Robot.jpg

#EDIT: because you see, the issue, isn’t so much textures, it’s batching.
Each arm piece has to be seperate, each rotator motor has to be seperate.

Why don’t you make it one mesh and use bones? Anyway, lights, shadows and hidden materials that you accidentally exported from your 3D software could all be to blame.

Are you using deferred and do you have a great number of dynamic lights? 1800 draw calls for that robot seems unreasonable to me. Ok, if you still have 60fps on your target plattform I don’t know if it’s worth the time to optimize (make sure to optimize the biggest performance hits first). But it should really be possible to get the whole thing into 1 skinned mesh renderer with 1 material. Use a proper texturing tool like Substance Painter 2 and rig the model in your 3D application. In Unity the bones should get imported as transforms afaik. You should be able to get 100% the same robotic animation look with a skinned mesh renderer as with 15 individual pieces. You just need to rig it appropriately (everything 100% influence, every vertex only affected by 1 bone).

If you set up a proper skeleton or rig, you can rotate the motors, etc, all on one skinned mesh renderer. However, even with multiple parts, you should still use one material (or one for each kind of material such as transparent or not). If you have some cash, buy Mesh Baker. There is even a free version, though I have no idea what the differences are. It can easily cut your drawcalls down to a manageable level, even on multiple pieces. I use it with DAZ figures that have similar drawcall counts as your robot and can get them down to 3 or 4.

Thanks for the tips guys. I forgot completely about setting the weights of the bones.
It just wasn’t hitting me because all I could think about was motors rotating parts haha.

In 3D multiple pieces can be skinned together - they will be separate meshes in Unity but have one skinned mesh renderer. Multiple pieces can also be UVd together - resulting in one texture. Since the metalness of the texture is derived from the textures (depending upon setup metallic or specular) the shader can be setup to look like different materials (shiny metal, flat painted, rubber pieces) and still only be one texture sheet.

I think where they are getting at is, (espically my new robot that’s not on here) has literally hundreds of moving parts.
And that to keep the Draw calls down because with like 15 pieces draw calls went up to nearly 1600 from 200.
So to put it into one mesh and to use rigging to move the robotic parts. Seems more complicated, but it beats having thousands upon thousands of draw calls lol…

Unless you know of some other way to keep the draw calls down. I’m all ears.

As others said, you can make it a single skinned mesh with one material. Just link different parts to different bones.

However, I wouldn’t bother with fixing this unless you actually have a performance problem somewhere. Also see “premature optimization”

1 Like

I know, but in order to do that don’t it need to be literally a single mesh? Because that is what I am doing now.
The way I was doing it in the photo above, I had literally every single part as its own model to get the robot motions.
They the arms and legs shared the same material, but that didn’t help.

So now going to try making it a singular mesh and rig it.

Well I wouldn’t optimize if it wasn’t for the fact that I’d like to have nearly 20 of them on the screen at least for different situations. Think of the Terminator games where you’ll have a group of Robots appear out of nowhere. Well 1400 * 20 is quite a bit of draw calls. Especially with real-time reflection probes. So this is something I’m definitely going to have to optimize, just know from experience that that’s something I need to do…

I just wasn’t sure if there was some other more proper way to do Robots. As they aren’t exactly functioning like Humans do. At least in terms of Industrial Terminator like robots they don’t.

Yes, it would need to be literally a single mesh, and modifying this model later will be royal pain in the ***, once you merge all the parts into one. I would try to write some sort of script to automate this nonsense, and I would delay merging parts as long as possible. It is possible to do this kind of merge on unity side.

Do you HAVE a performance problem RIGHT NOW? If you don’t, it could be a good idea to delay optimization.

See, you would need to first make a prototype, then mvp, then polish. Optimizing draw calls is definitely belongs to “polish” and only when it is confirmed to cause problems. For example, if you spend time fine-tuning robot models right now and then decide to scrap them later, you will have wasted your time.

I also highly recommend to look into profiler/frame debugger to see what actually happens.

Merging all the parts into one right now is pretty much only worth it if you want to learn how it is done.

1 Like

Yes. [quote=“drewradley, post:6, topic: 635202, username:drewradley”]
buy Mesh Baker.
[/quote] Sure, it’s not free, but does wonders for your situation.

Or write a replacement. It shouldn’t take long.

1 Like

@neginfinity : makes total sense, an dyeah I bet it would be a pain in the butt haha… One thing I love about 3ds max though is the Element tool. Even if they are merged together, the element tool can still select the model that was merged so I can easily break the stuff off.

But I do agree that it could potentially be a big waste of time doing it now. Just the only problem is, I have quite a powerful PC. I don’t have a mid-range computer. So not sure if my stuff is too much for the average gamers computer (not the rich gamers).

Like my PC, 60 FPS (without the robot).
But on my friends new PC (store bought), he gets 7 FPS at 400 MS.
And that’s with 100% baked lighting no shadow casters, etc. And maybe 1800 polygons. using the normal Standard Shader.

So I’m also trying to target some what the average consumer the best I can. Not just top of the line computers haha.

I will get something figured out though.
@drewradley : I would get it if I had the money, broke lol… Stuff like that I don’t mind buying. But can’t afford it at this moment.

Do you have any post processing effects? That can slow things up a lot.
Did your test on two different computers use the same quality and size? If not it’s not a fair comparison. Especially if you have effects that only kick on at higher quality.
Another thing you can try is to simply replace all the materials on the robot with a new blank material and see what happens. You’ve never said (or I missed) how many materials it has.

Well worth the investment when you have the cash to do so. It’s literally the most useful tool I ever bought for Unity.

@drewradley : Yeah have quite a few of them. I took that into consideration, so the next test I send him I’m going to give him options to turn off all PPE and Volumetric Lighting Systems…

I believe it had (don’t remember now) around 8-9 materials on it.

8 to 9 total? or 8 to 9 per object? You should have a folder called “materials” near your mesh. Just count them. Makes a big difference, especially with effects. Many effects multiply the draw calls like realtime shadows do.

Basically the answer is to condense it into one skinned mesh and one material. There isn’t any reason that model can’t do that. When done, the draw calls will drop to normal levels.

2 Likes

It was for the whole robot. And hmm I never thought about the effects multiplying the draw calls.