Search Unity

Planning Out a Scene

Discussion in 'Formats & External Tools' started by Marble, Sep 23, 2006.

  1. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    I've got some common household components that could probably be reused in a scene I'm making (beds, tables, etc.). I can either copy and distribute them in my 3D app, which would be really fast for me, and also let me combine the meshes, or I could arrange them in Unity as prefabs. The 3D app route would be more productive for me, but might prefabs be better for performance?
     
  2. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    yes, prefabs would be much better. This is something I've often wondered about... I'd be kinda nice if you could use instance objects in your 3d application and have those transfer over to unity as prefabs based on the original.
     
  3. Lallander

    Lallander

    Joined:
    Apr 23, 2006
    Posts:
    429
    You realize how handy that would be right?
     
  4. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    What about for something that needs really accurate placement like a door? They're obviously perfect for prefabs since they're all the same with the same animation, but I don't know if I can line each one up in the door socket perfectly using Unity's transform tools.
     
  5. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    If you can make sure each "socket" is fixed to a 1-unit (or other) grid, then it would be easier in Unity: drag the door to it's approximate location, then round the values off.

    As for placing prefabs in your 3D app, that sounds like something that might possibly be done with editor scripting combined with the scripting that your 3D app supports. (If any. LightWave is scriptable for instance.)
     
  6. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    Performance wise, it is actually better to combine as many objects as possible into a single object. Having a single prefab of the combined object is going to be more efficient than several prefabs of different objects.

    For something like a door, if you need it to open and close you would probably want that to be its own object with a hinge joint. Even in this case, it would be best to use the same material as the combined object.
     
  7. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    Ok, I think I get you. For the doors, is there any bonus for using one mesh as a prefab in many places vs using a bunch of discreet, but identical meshes?
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The main advantage of using a prefab in that case would be that if you decided the doors should be different somehow, just changing the prefab would change all the doors, instead of having to change each one individually. I don't think there's any particular speed bonus, but I could be wrong.

    --Eric
     
  9. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    Makes sense. Thanks.
     
  10. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    I have another related question: if I have a really big mesh that won't get seen all at once, is it better to divide it up into chunks (say, a separate mesh for each material, or a separate mesh for each room that will be visible at once), or will performance increase the less of the mesh is being seen at once?
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    How big is "really big"? It's been said that the ideal number of polygons is between 1500 and 4000, so one 4000 poly mesh would be better than two 2000 poly meshes. And by "not seen all at once", is that outside of the view frustum entirely, or just not visible behind walls and so on? Because if it's just behind walls and still in the view frustum, it's still being drawn, then covered up by closer polygons. Thus you wouldn't save anything by splitting it up.

    However, apparently Unity will have a portal system at some point, which could speed up indoor levels by dividing them up into sections. In the meantime, it's possible to fake a portal system by setting up triggers that turn rendering off and on for various meshes. I've done this, and it works (getting a reasonable speed increase), but you do have to set up everything manually, and then test the triggers thoroughly to make sure you don't accidentally have meshes appearing/disappearing when you can still see them from certain angles.

    --Eric
     
  12. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    Yeah, sounds like a lot of work. I'm expecting to have a camera orbiting the player in third person from above, so I may benefit from large meshes (like sizable buildings and terrains) from being outside the frustum.

    I was wondering whether it takes as much effort to transform the mesh inside the view frustum as outside. You've answered that, though, thanks!