Outerra forum

Anteworld - Outerra Game => Tech demo, support, updates => Topic started by: Levi on March 11, 2015, 10:40:30 am

Title: Multi/Sub-Object Materials and Draw Calls
Post by: Levi on March 11, 2015, 10:40:30 am
I've just noticed that the draw calls are being affected by the material IDs in a strange way.
I did some quick tests using a single mesh with a Multi/Sub-Object Material assigned to it, which only uses one standard material.

First test:
- Material ID set to 1 and all polygons using ID 1.
(http://i.minus.com/ibjvNlXUgQtM1k.png)

Result:
Draw calls: 1
Package memory footprint in MB: 0.
(http://i.minus.com/iQ6pY1thfUYyp.jpg)


Second test:
- Material ID set to 1000 and all polygons using ID 1000.
(http://i.minus.com/iLhvwicNb0xpe.png)

Result:
Draw calls: 1000
Package memory footprint in MB: 2.
(http://i.minus.com/i9ILWQJU17fgy.jpg)

I've also tested with more than one sub-material, but always the draw calls equals to the highest Material ID number. There can be five sub-materials, but if one of them have the ID set to 37 for example, then there will be 37 draw calls.

   Maybe the above isn't very practical, so here is a real situation:
I create a Multi/Sub-Object Material which has 17 standard materials.
I assign it to the main mesh which uses all 17 materials. This mesh will use 17 draw calls, so it's OK.
The problem comes now. I assign this Multi/Sub-Object Material to another mesh, but this mesh only uses the material IDs 5, 8, 9 and 11.
Once in Outerra, it uses 11 draw calls instead of only 4.

Is this behavior intentional, is it just a bug, or I am missing something?
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: angrypig on March 11, 2015, 11:01:20 am
Hi Levi can you send me the FBX of the model for test?
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: Levi on March 11, 2015, 11:05:46 am
Alright, I'll send you via e-mail both FBX files, the one with ID set to 1 and the another one with ID set to 1000.
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: angrypig on March 11, 2015, 11:06:06 am
Thanks
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: Levi on March 11, 2015, 11:10:38 am
No problem, thank you for looking at this issue.
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: PytonPago on March 11, 2015, 11:58:40 am
Levi, youre building a heli ?
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: Levi on March 11, 2015, 12:52:03 pm
Levi, youre building a heli ?
Good eye!
Yep, it's a heli, but I'm not exactly building it, just optimizing the meshes, adjusting smoothing groups, and stuff like that for the next conversion. :)
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: PytonPago on March 11, 2015, 03:03:57 pm
Levi, youre building a heli ?
Good eye!
Yep, it's a heli, but I'm not exactly building it, just optimizing the meshes, adjusting smoothing groups, and stuff like that for the next conversion. :)

I see ... you really do not sleep at all !!  =D  =D
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: KW71 on March 11, 2015, 03:52:57 pm
Hi, Levi!

How can you know the number of draw calls  in OT?
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: Levi on March 11, 2015, 05:06:35 pm
I see ... you really do not sleep at all !!  =D  =D
=D :))
Nah, I do actually sleep lately. Now I have less free time to work on the PC, than I used to have before...  :'(

Hi, Levi!

How can you know the number of draw calls  in OT?
If you have debug keys enabled in eng.cfg, just hit Alt+7 and the black window will show up, then look on the second row to see the draw calls.
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: KW71 on March 11, 2015, 07:28:03 pm
Thanks!!
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: Levi on June 25, 2015, 09:21:35 am
Hi Ladislav,

This issue seems to be fixed now, well at least partly. I'm not sure if this is a bug or it's intentionally done this way.

Here's the issue: I have a Multi/Sub-Object material which contains multiple sub-materials. This Multi/Sub-Object material is being applied across different meshes.
Some meshes are using the sub-materials with ID:1 and ID:2. Until now it's all good and works as it should when imported into Outerra.
Now I apply the Multi/Sub-Object material to another mesh which is using let's say the sub-materials with ID:1 and ID:10. When imported into Outerra, the mesh is showing the sub-materials with ID:1 and ID:2 instead of ID:1 and ID:10.

Note: Intentionally and just for testing purposes, the ID:10 corresponds to a wrong sub-material, and it's supposed to show like that in Outerra.
(http://i.minus.com/iP9bEHC0O9PN8.png)(http://i.minus.com/ibiwfwcHv2E6PU.jpg)

Any thoughts on this?
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: KW71 on June 25, 2015, 03:57:08 pm
I have the same problem... Temporarily I had to separate the meshes by material and make a parent relation.
I have also noticed this do not happen with all the multi material objects...
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: Levi on June 26, 2015, 06:10:48 am
I have the same problem... Temporarily I had to separate the meshes by material and make a parent relation.
Yeah, that's a solution, but in my case I cannot separate the meshes (or I don't want to) because of various reasons.

I have also noticed this do not happen with all the multi material objects...
It works as it should if the mesh is using the IDs in the right order, for example the IDs 1, 2, 3, 4, 5. But if you want to use let's say the IDs 1, 3 and 5, then in Outerra will show IDs 1, 2 and 3.

The solution would be creating a Multi/Sub-Object material for each mesh, reusing the sub-materials of course. But this will create a mess within the material editor...
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: KW71 on June 26, 2015, 10:00:35 am
"Yeah, that's a solution, but in my case I cannot separate the meshes (or I don't want to) because of various reasons."

I agree with you; I'm doing it just provisionally.


It works as it should if the mesh is using the IDs in the right order, for example the IDs 1, 2, 3, 4, 5. But if you want to use let's say the IDs 1, 3 and 5, then in Outerra will show IDs 1, 2 and 3."

In Blender there are not IDs as in Max... You have to select the faces you as material X, then selet the material and apply to those faces... Or join (AKA Attach in Max) meshes with different materias... I'll check if the selection order befor joining affects the result.

Hopefully there is a solution.
Title: Re: Multi/Sub-Object Materials and Draw Calls
Post by: Levi on June 27, 2015, 05:50:04 am
In Blender there are not IDs as in Max...
I think there actually are some kind of IDs in Blender too, but not shown to the user as in Max...

Here are the four materials assigned to a single mesh in blender:
(http://i.minus.com/izukpCJDtivuO.png)

After exported to Max via FBX, we have now four material IDs. A Multi/Sub-Object material was automatically created as well, with the corresponding sub-materials.
(http://i.minus.com/i0i2adWJuVhQP.png)

You have to select the faces you as material X, then selet the material and apply to those faces... Or join (AKA Attach in Max) meshes with different materias...
You can do the exact same thing in Max as well, and it will automatically create a Multi/Sub-Object material for that mesh.

I think I will end up creating Multi/Sub-Object material for each mesh if there won't be a solution, but hopefully there will. :)