PDA

View Full Version : Cryengine and drawcalls


Ark
01-19-2012, 12:37 PM
I've been studying a lot of how the buildings where made for Crysis 2 and noticed theres quite a bit of modularity going on.

One thing i noticed was that a lot of the buildings have multiple sub-materials, some up to 20 sub-materials for a single exterior building.
I know certain areas are broken up so surface types can be assigned, but having this many sub-materials for a single mesh i would have thought would send the draw calls through the roof?

Does the engine combine all the sub-materials in one atlas at runtime or is it just that the engine is optimised to handle many smaller textures than larger atlas textures?

I know this is quite specific to Cryengine but i was hoping one of the Crytek guys could jump in.

Jonathan
01-20-2012, 05:31 AM
They are most likely using a command buffer or direct memory address to speed up drawcall performance, it's very common these days.

http://msdn.microsoft.com/en-us/library/windows/hardware/ff569747%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb172234%28v=vs.85%29.aspx
http://c0de517e.blogspot.com/2008/04/gpu-part-1.html
http://traxnet.wordpress.com/2011/07/18/understanding-modern-gpus-2/

Ark
01-20-2012, 05:49 AM
Thx for the links, been reading up on it, but not that clear as I'm not that technical minded.

For what i understand it keep the history of meshes/materials stored in a buffer instead of keep recalling them separately?

Jonathan
01-20-2012, 06:05 AM
Yes, it stores the associated information/data for those drawcalls, so there's no need for the CPU to be hammered by them. It's a very good solution to the problem, and it's why, in some situations, people are often overly concerned by drawcalls, and often hurt performance by using more complex shaders to blend "materials," or that is, to have multiple surfaces in one shader, when it'd be better to break them apart into separate materials.

Ark
01-20-2012, 07:03 AM
Thats great, thx for the explanation.

[HP]
01-20-2012, 08:16 AM
http://www.polycount.com/forum/showpost.php?p=1414052&postcount=102

Ark
01-20-2012, 09:01 AM
Cheers HP, with regards to that building you posted, your basically using more sub-materials so that this allows you to tile the textures better?

Also if you could elaborate on the surface types? Does the surface type get generated from the surface type of the proxy or the actual visible materials surface type?

I.e. i need a separate proxy for every different material in the model or just one proxy and and the surface types set under the actual material.

[HP]
01-20-2012, 09:19 AM
Cheers HP, with regards to that building you posted, your basically using more sub-materials so that this allows you to tile the textures better?


Yeah, pretty much, gives you more control over different materials as well, allowing you to create materials with diferent specularities, bullet collision decals and all that jazz.


Also if you could elaborate on the surface types? Does the surface type get generated from the surface type of the proxy or the actual visible materials surface type?


If you watch this video tutorial (http://eat3d.com/free/cryengine_3dsmax) I explain that you need to have a proxy for each kind of material if you want to have different collision bullet decals and footstep sounds, but as far as I know this isn't the case anymore.
So It's enough to have only one proxy for your entire mesh, just make sure to specify a surface type for each sub-material you have, one that makes sense. All this does is changes the bullet decal, and particle spawned.

Although, just something small I wanna point out, it's nothing very important but nevertheless just so you know, if you want the footstep sounds to work with different sub-materials, then you need to have a different proxy, for example say you have a carpet with a wooden strip on it, if you want this wooden area to emit wood-like footstep sounds when walked on it, then you need to have a separate proxy, just a nitpick really, because the rest works fine.


I.e. i need a separate proxy for every different material in the model or just one proxy and and the surface types set under the actual material


Short answer is yes, just one proxy sub-mat for the entire thing, just don't forget to set the surface types on the other sub-mats! :)

Ark
01-20-2012, 09:22 AM
Thx HP very informative. :)

polypilot
01-21-2012, 05:21 AM
One of the reasons why more sub mats were needed is because we were limited to 512 textures due to texture streaming on consoles. I was aming for a texel ratio ~200px per meter for the buildings which means you need more tiles and you can't just put everything on one map.

Ark
01-21-2012, 06:31 AM
Cheers polypilot, makes real sense to me now. :)