Search Unity

Character Customization Assets

Discussion in 'Editor & General Support' started by diablo, Feb 15, 2011.

  1. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Hello everyone,

    From what I've read on the forums, the best way to create wearable assets for a character that can be dynamically swapped is to include all the assets in the model. For example, Diablo's Barbarian model would be a base model that's in his underwear but will also include all helms, chestplates, bracers, belts, boots, etc... Now there are a couple of ways that the assets can be made : 1) split the model into regions that can be completely replaced by the asset. For example, one helm asset would be a bare head (no helm) while the others would be the helm and whatever parts of the head that remains visible. 2) keep the model intact as one big piece and model the assets to cover the appropriate certain regions. For example, each helmet would be modeled on top of the head, each chest-armor piece would be modeled on top of the chest, etc... Approach #1 seems to take more time but reduces poly count while Approach #2 seems to take less time but increases poly count. All of these items would be bound to the rig and are therefore a part of all animations. Assets such as weapons and shields need not be included since they can be mounted on to a mount-point dynamically. Wearable assets can be swapped by simply toggling the active state for the current asset to false and toggling the active state for the new asset to true. When exporting the model, the main mesh and rig should be exported to one FBX file while each animation should be exported to their own individual FPX files without the main mesh. They should conform to Unity's '@' sign convention so that Unity will automatically link each animation to the main mesh.

    These are all my assumptions so far based on what I've gathered on the forums and experimentation, so please correct me if I'm wrong; it's important that I know where I'm going off the deep end :p

    Okay, so here are my questions :

    1) Which approach should I take to modelling the assets : #1, #2, or some other approach?
    2) If there's 100 of each asset (ie. 100 helms, 100 chestplates, etc...) then I assume that instantiating the Barbarian would take a VERY long time and hog up a TON of resources since each individual asset would need to be in memory. (I assume that they are in memory even though they are inactive). Therefore, I must be missing something since this is obviously the wrong approach, and putting all of the assets into the model is definitely not the way to go. However, everyone seems to claim this is the way to go, and the Unity Character Customization example uses this approach (but then again they only have 2 of each asset).

    Help me, all-mighty Unity Community; you're my only hope!

    El Diablo
     
  2. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
  3. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Hello Anomalous,

    Thanks for responding. I'm not sure if that link you posted helps me though; they're trying to use one set of animations for all of their characters while I'm trying to figure out what the overall processes are in creating a customizable character. If I'm missing something please let me know.

    El Diablo
     
  4. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Now I have a few people asking me if I found a resolution. This seems to be a hot-topic so if I find answers I'll post a how-to guide.
     
  5. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    Blizzard's World of Warcraft follows method #3: Model all the pieces of armor and such and bring the individual mesh's together to "look" like its all one piece. They go one step further and use the model's base texture with overlays to make skin tight outfits. This to me is a million times more acceptable than one model with a thousand pieces. I figured this out a while back when I was tinkering with the Wow Model Viewer and the file format of the big files they use to store objects.
     
  6. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    This is exactly what I do with my game.
    Details in pages 4 5 of the WIP thread in my sig.

    I separated a body in 4 pieces : head, torso, legs and arms.
    Then each part has a unique computed texture, generated from 4 different layers : naked skin+cloth base color+cloth color 1+cloth color2.
    You can find a tutorial for this texture computing here : http://forum.unity3d.com/threads/66...e-from-multiple-textures?highlight=super+fast

    It loads in no time, and opens to a ton of different configurations and cloth/color mixups.

    The hard part is to make all the meshes fit together, and all the different texture layers being able to overlay with each other seamlessly.
     
  7. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    Ok, it depends on the situation. Doing your approach #1 (complete replacement of body part) would be a hassle for replacing a character's head when he equips different helmets. You'd have to create all combinations of his face on all helmets as meshes. Better to attach the part on top of the head instead (think of the character's hair as a "helmet" that gets unequipped when your character equips an actual helmet).

    For something like long robes for example, if the legs aren't seen, it makes sense to remove the legs completely while the robes are equipped. Just make sure that the robes conform to the character's skeleton properly during animations, as if the legs are still there.

    Once the robes are removed, put the legs back.

    Depends on you if you just want the legs to be hidden when not needed, or really removed. Perhaps for NPC's who rarely change their clothing you'd want them to really remove the not visible parts. For player characters who can change their clothing anytime, perhaps just hide them from view when not needed so showing them again will be fast.
     
  8. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Hey guys,

    Thank you so much for replying!

    @Nomad : I'm going to look into your links when I get to the office; I briefly glanced at your WIP thread : nice!!!

    @Anamalous : Approach #2 (what you were just talking about) is what we have in place right now for a test model, but we want to make sure our approach is right before using it for all of our models, which mean we're stuck! :/ However, the problem we have is that if there's 100 different helms, 100 different armor, 100 different boots, etc... then I assume that whenever I instantiate that model not only will the base nude character be instantiated but also each and every one of those assets (ie. helms, armor, boots, etc...). Therefore, this must not be the right approach, or perhaps I'm missing a step or two in between? If someone can shed a light on this I would greatly appreciate it.

    The thought just occurred to me... considering that what I want to do should be handled via streaming Asset Bundles, should I write a design-time (editor?) script that takes each model, removes each asset (helms, armor, boots, etc...) so that the model is naked, save the nude version of the model on its own and save all the assets as Asset Bundles? Is it even possible to do this? I'm a programmer so writing scripts is not a problem, but given my unfamiliarity with Unity I was wondering if it's possible to programatically strip a model of its assets and save the model and assets for streaming via Asset Bundles.

    If I'm completely going over the deep end, please let me know, I'm very much open to constructive criticism. Perhaps there's a myriad of other approaches I'm not considering that are much better.

    Thanks in advance!

    El Diablo
     
  9. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Hey guys,

    @BigMisterB, N0mad :
    Would someone please go into just a little more detail regarding the workflow for the model and individual pieces/meshes?

    For example, we use ZBrush to create a high-res model of, let's say, a nude human. Now let's say we need to create 5 of each wearable asset such as helms, armor, braces, boots, etc... We start with helm1, modeling it straight on to the head. Then we make it invisible and go on to the next helm. We keep doing this with every asset until we're done. At this point we have a high-res base model + high-res assets. We then low-poly everything (targetting the PC) and pass it on to our animator who rigs the base model, binds everything (model + assets), and creates animations for it. Another alternative is to separate the base model into several regions (head, torso, arm, legs, feet, etc...) and create 6 different heads (one with regular hair, the others with different helms), 6 different torso, etc... and then do the low poly, rigging, binding, animations.

    What you guys seem to be suggesting (and please correct me if I'm wrong) is to model each asset *individually", which I think means creating a new ZBrush project for every single asset and modeling them separately. If I do this for, let's say, a helm, how will I be able to model the helm to the exact contours of the human base model unless I have the model in the same project as reference? That would be like trying to create a bolt to fit a nut that you can only look at from a distance : it will never be a precise fit. Therefore, I don't think this is what you're suggesting and I'm simply confused, lol. Or perhaps you mean to export each individual asset as an individual mesh. But then, how will they get back onto the model at exactly the right places? How will they bind to the rig?

    Would you be kind enough to offer a quick and dirty walkthrough from modelling to animation? It doesn't have to be that long, just a paragraph like the example of how I currently do it.

    Thank you guys very much for your assistance and patience; I really appreciate it.

    El Diablo
     
  10. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Thanks for your compliment El Diablo :)

    Ok, now for the explanation :

    Everybody his own method, but I chosed this one you mentionned :

    Management : I got a file, in which I got different folders, based on those different body parts (heads, haircuts, torsos, arms, and legs). Each time I want to edit a head for example, I turn on invisible all the others.

    UVs : Each mesh is UVmapped to a universal UV map (based on naked skin, for obvious reasons) for each member group. Then I adapt each texture to this map. If it happens that some models got more or less vertices than the naked mesh, then I do my best to fit the new vertices in a way that keeps being proportional to naked map.
    For example if I decide to put a bracer on the naked arm for a new arm mesh, I will organize the new UV points in a way that will visually exactly fit the old naked UV arm map. This way I can keep a good eye on homogenity between my textures, without having to spend countless hours of drawing, then checking under 3D tool, then drawing, then coming back to 3D tool, etc.
    This can even let me put a texture from one mesh to another completely different one, seamless (just in case of).

    Rigging : traditional rigging of every vertex, for each different mesh.

    Export : I put everything in one big FBX (cleaned from folders and useless conception stuff), take away all the textures, and export it.

    Import : I create as much prefabs as there members, and drag-n-drop each FBX members into them respectively. This way I can update each prefab seamlessly by re-importing the original FBX.

    Ingame :
    1) At start, I instantiate a boneset with proper animations,
    2) then create the mesh with different instantiated prefab parts,
    3) Combine meshes into one with Unity CombineInstance class,
    4) then reassign the bones to it
    5) create the proper texture with the method I linked earlier
    6) et voilà.
     
  11. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    You have to write down some resource "loader" of your own. Unity was never meant for building huge games and asset bundles are not sollution for multigigabyte projects with thousands of items, shared materials, textures, LODs...I would reccomend you to design model ideal for your game and then make appropriate loading engine.
     
  12. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    Like I said, if you have 100 different helms, its too much to create 100 different heads (each head having that helmet), and that's 100 for each character that can use such helms.

    So I would rather just have one head that doesn't go away, and you just put the helmet on top of him. However you remove the hair when you add that helmet, so that you can be sure that the hair won't show up on the helmet.

    You have the base nude mesh, but the different possible clothing that the character can equip are not loaded yet. You just then load the ones that are needed.

    However like I said, parts of the base nude mesh will be removed when you start equipping. When you equip boots, you remove the feet from the base nude mesh, since its being replaced with boots (there's no reason to have the bare feet still loaded since the boots are equipped, plus it ensures the bare feet mesh won't poke out from the boots meshes). This means your base nude mesh is segmented and some parts of it can be removed.
     
  13. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Hello again,

    @anomalous : I'm currently looking into n0mad's workflow, but I wanted to reply to you real quick. When you say that I have the base nude mesh, you forget that it's not the only thing I have. Remember, I have the base nude mesh + all wearable assets that are rigged, bound, and animated, all of them in one file. This all gets exported from Maya to FBX and imported into Unity. It now appears in Unity as, let's say, Humanoid. Inside Humanoid there's the nude mesh and all the helm meshes, armor meshes, boot meshes, etc... If I drag Humanoid into the world editor, I'm creating an instance of this Humanoid which contains a nude mesh *plus* all his gear and I will see the Humanoid covered head to toe in a blob of every single asset I created. You see my problem now? Obviously this is bad, and I'm missing some step in between, obviously some pre-processing. This is what lead to me thinking the following, which I posted earlier but will re-post here for convenience :

    I never received a reply as to whether this is feasible or not, but it may answer my question.

    El Diablo
     
  14. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    You don't really have to design an editor script, just do that :

    For example, you have this huge FBX file in your asset library, and you just want to make head prefabs : Create as many prefabs as there are different heads in your FBX, and then drag n drop your FBX head meshes into each prefab.
    Then at runtime, you select the head type you want to load by instantiating the right prefab :)

    On a sidenote, the naked + progressive dressing up is quite similar, except that in this case you waste some precious resource by loading a mesh that you won't necessarly use (naked mesh).
     
  15. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    @n0mad :
    Really?? I didn't know you could do that! I'll try that when I get back to the office and post what I find!

    El Diablo
     
  16. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Wouldn't that break the animation data on each of the meshes?

    I have a very large FBX that I paid an artist to make for me, that in addition to the skeleton rig under the fbx there is 6 heads, 6 bodies, 6 hands, 6 legs and 6 feet.

    I can't even move the transform on any of them, let alone move them out of the fbx, which I don't really understand, but I assume it has something to do with the animation data.

    That said, I have no issues instantiating the model and enabling/disabling the different body parts of the fbx at runtime.
     
  17. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Yeah that's simple :)

    Also, do not drag n drop FBX parts into the scene, and then drag it into prefabs, as it would create a new instance of the FBX and lose its connection to the bones.
    Just drag n drop directly the FBX parts into library's prefabs.

    Yes it would break the animation stuff on it. But basically it's not a good idea to merge animations and meshes into one single file when you deal with character customization assets, as it means you would have to reimport all your meshes whenever you change the animation, or vice versa. It's better to separate them, loading your animated skeleton at runtime, then your meshes, and then link the whole together.

    On the other hand, as explained earlier, instantiating the whole meshes library and then activating / deactivating parts is a huge memory waste. You basically asks your game to load as much useless data as you have deactivated meshes, which means unecessary loading times.
    Imagine the case when you have 10 types of heads, arms, torsos, legs, that would mean you'd load (10 x 4 - 4) = 36 unused meshes ! :)
     
  18. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    I think thats very similar to what I'm doing, actually. When my model is instantiated it has 30 pieces, then I deactivate 25 based on his equipment, hehe :)

    Oh well, I'm not an artist so I'm not in the position to change the way it was designed, the artist that made it for me is long gone and I REALLY love the model. But I don't notice a performance hit with the way I'm currently doing it, and I tested it with ~30 AI bots using the model, configured with different outfits and pathfinding, and I still get about ~500 fps.
     
  19. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Ah, you're targetting Desktop machines, ok I understand then ;-)
    Yes in this case it's not really important.

    (if there are not that much customization assets)
     
    Last edited: Feb 18, 2011
  20. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Okay, I had my hopes up this morning as I came in to the office but alas!, nothing is ever that easy :(

    Maya
    ====
    What I did was have my animator create a very simple model for testing purposes. What he did was create something that looks like a lamppost, basically a cylinder with two different bases at the bottom. One base is a cube, the other base is a sphere, and these are meant to be interchangeable; completely swap one out for the other. At the top of the cylinder are two sign meshes (sign = NYC street-sign with the name or number of street on it). One of the sign meshes has a rectangular sign as well as a cylinder base that fits on top of the lamppost which serves as the "glue" between the sign and the lamppost. The other sign mesh lacks the sign and only has the cylinder base. These signs are interchangeable as well, swap one out for the other, but unlike the cube/sphere base, they don't completely replace a particular region of the lamppost, they simply fit on top of it like jewelry. We did this to test both scenarios. We then created two animations for the lamppost, one which bends in the middle and the other which tips over like a bowling pin. We then exported the mesh + rig to its own file called "thing" and exported the two animations (just the animations, no mesh) to "thing@bend" and "thing@tip". I have included the FBX files as an attachment if anyone's interested in playing around with it.

    View attachment $thing.zip

    Unity
    ====
    I drag all three files into Unity and since they conform to Unity's '@' convention it's able to link in the external animations to the main mesh automatically. Now I have three things in my project folder : the main mesh called "thing" which contains the lamppost + assets (cube/sphere/signs) + rig. The other two files "thing@bend" and "thing@tip" are just animations and have already been linked to the main mesh thanks to Unity.

    Okay, at this point I'm able to create an instance of thing, animate it, and have it swap between the different assets. Perfect, love it, except that having all these assets in memory at the same time and toggling their active state based on which one I want visible is a very bad idea, which I think everyone agrees with. This is where I need some help.

    N0mad's tip :
    Okay, so I'm excited about this! I expand "thing" in my project folder to reveal its children and find all the submeshes. I drag Cube to its own prefab, Sphere to its own prefab, and the signs to their own prefabs. But now I have a problem... what do I do with "thing"? "thing" contains the base mesh (lamppost) and rig, it has all the animations linked to it, and it still has all the assets in it (cube/sphere/signs), but I need to create a prefab for it so that I can instantiate it. However, I can't create a prefab for it if it still contains all of the assets, and there's no way I can delete the assets within "thing". If I copy the base lamppost mesh (basically all the children of "thing" that are not assets) into its own prefab then I lose the animations that were linked in to "thing".

    I'm obviously doing something wrong... help!!

    El Diablo
     
  21. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    Don't do it like that. Separate each wearable asset as its own file, import them into Unity, then join them together via scripting using the method explained in the first link I gave you. This ensures that you load only the assets that you need, while still letting the attached assets conform to your character's skeleton and be animated properly.
     
  22. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I like this approach too, but there is one problem. Shared materials and textures. Perfomance is not only about number of polygons, but about textures and materials too. Smart texutre/material design is difference between 20 and 100fps. Once you have thousands of meshes, some of them with shared materials and textures, optimal loading is quite challenge. Unity does not provide anything close to solve this, you have to write your own resource loading system.

    If you are making small game, forget it, but for big game this is crucial.
     
  23. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    It's the workflow I'm confused about, not sure at which point in the workflow I've described to do what you're saying. I'll take a stab at it... I take it you mean that once all the assets are finished (base character + all wearable assets), low-polyd, rigged, and bound (all done in one file of course), I should then select each individual asset and export them to their individual FBX files, then apply the method in the first link?

    Thank you for your patience anomalous, I appreciate it.

    El Diablo
     
  24. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Hello Demostenes,

    I'm looking into every possible solution so I'm curious as to whether or not you have a link to what's involved in writing a custom resource loading system. I have no problem writing code, I just don't understand the nuts and bolts of the system yet and any pointers/guides/examples would be much appreciated.

    El Diablo
     
  25. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Check unilod and antares for inspiration. Nice systems, but far from ready for using in big game. So you have to modify it, or write something new from the beginning.
    Resource loading is basic of each big game and until you have solved this, it does not make much sense to work on art. I would reccommend you to design some art/animation/lod/etc pipeline according to your needs, then design structure of your data and resources (what will be prefab, what assetbundle, how to approach to shared textures and materials...) and then make resource loader (what load/unload and when). Asset bundles are not sollution for bigger game. This is not simple task, it require lots of research and you will redesign your sollution few times, until you have something usefull.
     
  26. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    I don't quite understand the problem, can you elaborate with an example situation?
     
  27. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    As I answered to Legend411, animations would be in a separate FBX, containing only the skeleton.

    Here is what I basically perform in my game for a character creation at runtime :

    1) load Instantiate a FBX containing the skeleton of a character, with all his animations
    2) Instantiate all the custom assets (head, torso, arms, legs, haircut), at the right place, aligned with skeleton. Aligning it should already be done in the FBX (should be automatically aligned if your skeleton FBX file was just an extract from the original lamppost file)
    3) Combine meshes with CombineInstance.combine()
    4) link the new mesh to skeleton
    5) and that's it.
     
  28. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    It is very ineffective to load whole asset bundle just for one texture needed for object from other bundle, and it is very ineffective to duplicate textures just to have them always together with models. For small game does not matter, but if you have 15GB of client side data, you must load really carefully, to fit in to the memory and do as minimum HDD operations as possible, especially if you want seamless world.

    Imagine, that I have bundle with kitchen equipment, lets say 50MB. But it does not make much sense to load whole bundle just to display one spoon. On the other side it does not make much sense to give each model unique material and texture and do lots of small bundles, because most of time you will have more kitchen equipment in one place and then is much faster to share one texture and material for theese objects. Duplicating textures into to each small bundle can make your client data 3x bigger. There is no difference between 100MB and 300MB, but between 10GB and 30GB is really big.

    Same problem is with the characters, sharing of textures and materials is really important for performance, but once you have hundreds of parts, you cant make giant bundles.
     
    Last edited: Feb 19, 2011
  29. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    I am not familiar with AssetBundles, but from what I know, its useful in a web build of a game so that you download the game data part by part so that the game can start even while parts of it are still being downloaded, as opposed to staying at the loading screen while the whole game downloads.

    However that's only for downloading game data, not loading it into memory. You can make an asset be loaded into memory only when you want to by putting it into the Assets/Resources/ folder, then using Resources.Load().

    I had a problem before, where I was displaying a randomly chosen loading screen image whenever loading is needed. The script back then used to hold a list of Texture2Ds. That meant the script loaded all those Texture2Ds into memory, and it crashed the iPhone because the memory needed was too much.

    The problem was that it was loading all of them into memory when only one of them is needed. So I fixed it so that among the list of images, only that one randomly chosen Texture2D is loaded into memory, by using Resources.Load().

    So just go ahead and download the whole asset bundle, but, inside that asset bundle, load only what you need into memory by using Resources.Load().

    Again, I have never tried using asset bundles as I have no Unity Pro, so I am not sure if Resources.Load() will work with asset bundles.

    For the character customization, I would make it so that each wearable asset is on its own asset bundle, along with its textures and texture variations it uses.
     
  30. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    You can do it that way, though I am not sure, but try putting a maya file into you unity project and it should load fine without needing to bother with exporting settings; it converts it into FBX for you (that's what happens to me when using Blender). If that's true, then I would rather put each wearable asset to its own file.
     
  31. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    But this mean, you cant share textures and materials between assets. For example if you have armor, it is much faster to have one texture and material for all parts, instead of separate textures and materials for each part. Material change is worst case in rendering process. If you plan few charactes on the screen no problem, but if you have 20+ it can mean unplayable game.
     
    Last edited: Feb 20, 2011
  32. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    I don't know where you get your ideas on what's slow or not, but I'm not going to contest them.

    Its up to you. If you think the situation calls for the need of texture atlases, then go ahead.

    For me, I never had an unplayable game where the assets' textures are separate. If you have a leather boots, then it uses its own texture, but would only be about 128x128 or even just 64x64 since its a small object. For a leather chest armor on the other hand, the texture would take perhaps, say, 256x256, or maybe 512x512, since its a bit bigger than the boots. It won't need to be big like 1024x1024 since its only a part of the body and not all of it.

    Everything has its pros and cons. If you put textures of say, 8 armors in one texture file, and you had a situation wherein only 2 or 3 of them are used, you waste loading the texture data of all the others that were not used.

    I believe texture atlases are best used on objects that are sure to be displayed next to each other, like various objects that show up only in a particular level/map, or enemies that come in preset groups. But for ones that call for customizability, I wouldn't use it.
     
  33. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Where? It is how each graphic card works. EVERYBODY should read theese basics beforce starting to model/design anything.
    If you have 6 body parts with separate textures and meshes, then you have 6x more draw calls. Imagine using some parallax shader, having 50 characters on the screen...Other golden rule is, that one big texture for 10 objects is bettern, than 10 small separate textures. If you are doing small game, you dont have to care about these performance tricks, if you are doing something more serious, you should.
     
    Last edited: Feb 20, 2011
  34. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    This is interesting. I understand the general idea of keeping draw calls down and sharing textures/materials as much as possible. However, I didn't realize that Asset Bundles won't allow you to share textures/materials. I guess I'll have to read up more on Asset Bundles.
     
  35. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Well, they allow. Problem is, that sooner or later you are in situation (no matter how you design your data structure), where object is in one bundle and texture in second. Or some similar case (you need one just one object from whole bundle and so on). And it is very inefficient to load whole bundle just because of one texture. You want to minimize your loading operations. This is the reason why i started to talk about custom resource manager. Assets bundles are not sollution for big game.
     
  36. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    I've been reading about unilod as you suggested and it seems to take care of grouping meshes/textures as well as streaming in resources. What do you feel it's lacking that you wouldn't recommend it for big games?
     
  37. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Unilod is really nice, but it is not finished. It crashes when it shouldnt, some cases are not solved (you cant have whole game in one scene)...so it need some tuning. Unfortunately in such cases is faster to write down your own (and much lighter) system exactly for you needs.
     
  38. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    Ok.
     
  39. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    I just think that you should always look first where the bottleneck in your game is before you optimize.
     
  40. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    If you are preparing big game, it is completely insane to start optimizing after you have problem. Imagine, that you have 1000 models and after one year of creating them you find out, that everything is wrong. And you have to remake everything. We have now cca 1300 models and it is barely 1/3.
     
  41. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    I think both of you are right but are simply talking at different levels about different things. Anomalous seems to be referring to the evils of premature optimization where you optimize every microscopic detail without doing any benchmarking that exposes where the real problems are. Demostenes seems to be referring to choosing the correct overall strategy/framework before embarking on a project. Both approaches are absolutely correct and fundamental and go hand-in-hand in any successful project. Designing the proper framework and overall strategy before one starts development (eg. choosing the optimal tools, workflow, data formats, etc...) is if nothing else a prudent approach and once development is going full steam some benchmarks will be necessary to help work out any bottlenecks that may arise. I think you guys should shake hands and hug each other because your approaches work extremely well together.

    I'm going to look at N0mad's approach as well as what you guys suggested and see which one makes sense for my particular project. I'll post what I find.
     
    Last edited: Feb 22, 2011
  42. ranko

    ranko

    Joined:
    Apr 24, 2011
    Posts:
    4
    One solution that may be possible to do in order to have only 1 draw call for each character, is to code something like this :

    ->Load the skeleton of the character with all animations.
    ->Load all the meshes for each body parts and armors etc...
    ->Load all the textures of each body parts.
    ->Choose which body parts need to be used for the character.
    ->Position each body parts at the correct place near the correct bone on the skeleton.
    ->For each mesh (body part) store the name or handle of the mesh, store each index and each X,Y,Z coordinates of each vertices of this mesh, store the texture name associated to this mesh, store the UV coordinates of each vertices.
    ->Merge all meshes of body parts into one mesh and one surface.
    ->Read in the stored values of the vertices to associate each vertices corresponding to a body parts to the correct bone. (so that the bone animate the correct body part)
    ->Create a texture large enough to have all the textures of the body parts on it.
    ->Read in the stored values of the vertices to draw each texture of each body parts on the new texture. (with the correct offset so that it is possible to calculate the new UV coordinates of the vertex.)
    ->Associate the new texture to each vertices of the mesh.

    That should work (in theory) to be able to customize the character with many meshes and many textures and keep the polyscount low and to have only 1 surface and 1 material for the character, but i don't know if it is possible to code this in Unity3d, maybe with the pro version ?
     
    Last edited: Jun 7, 2011
  43. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
  44. reset

    reset

    Joined:
    May 22, 2009
    Posts:
    393
    Last edited: Oct 30, 2012
  45. MedivhWen

    MedivhWen

    Joined:
    Aug 9, 2017
    Posts:
    1
    These are some useful discussion. :)