Search Unity

How World of Warcraft terrain works?

Discussion in 'Scripting' started by blaze, Aug 23, 2012.

  1. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Anyone know how World of Warcraft's terrains works?
    I want to know how to do terrain get loading when necessary, and only render what the character is seeing.
    Know how to do giant worlds like in WoW be possible?
     
  2. Karmarama

    Karmarama

    Joined:
    Jul 11, 2011
    Posts:
    261
    I'm assuming you'd have to divide Unity Terrain as a grid, into cells, and then occlusion cull anything not in view such as that of M2H culling (google it) unless you're using Unity Pro then you can use the built in occlusion culling.
     
  3. hannes-dev

    hannes-dev

    Joined:
    Apr 27, 2012
    Posts:
    132
    unity doesn't render things outside the screen unless you tell unity to do so
    so don't worry about that
     
  4. BPPHarv

    BPPHarv

    Joined:
    Jun 9, 2012
    Posts:
    318
    Dhaiku is correct Unity provides Camera Frustum Culling so there isn't a need for M2H Occlusion to disable rendering on non-visible objects. For a really large world, the entire world + tree + grass + detail in one terrain (if it even fits in memory) can cause performance issues so you do need to break it up as Karmarama suggests. The trick to doing this well in Unity (or any engine) is making it seem like it's in memory when it's not. Loading terrain blocks based on distance and then carefully managing the instantiation and reuse of GameObjects to reduce any hiccups in frame rate as you swap in or out new stuff. That last bit isn't an easy task.

    Gamedev has a similar thread http://www.gamedev.net/topic/558603-how-does-wows-terrain-generation-work/ which google would be happy to provide any enthusiastic individual with a penchant for terraining their hair out.
     
  5. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    Frustum Culling can't really be compared with Occlusion Culling... I think (not sure here) that the default Terrain does cull non visible parts, but if you make your own terrain in a 3d modeling software and import it as one single mesh then it won't be (partly) culled and even the stuff rendered that's behind the camera since it's one still one single big mesh.

    Also Frustum Culling doesn't cull objects in front of the camera which are hidden by i.e. mountains, cause it's still in the camera frustum, just overdrawn by a mountain. For this case you need Occlusion culling
     
  6. Karmarama

    Karmarama

    Joined:
    Jul 11, 2011
    Posts:
    261
    Frustum culling only disables the renderer of the object outside camera view (as Tseng mentioned, if still in camera view and behind an object is still rendered) - however even when it's renderer is disabled you're still processing it's tri count or draw calls, something along the lines. Occlusion culling allows everything out of view to be entirely disabled, even things behind a wall or a mountain to be disabled and not processed whatsoever on screen and reduce draw calls.
     
  7. BPPHarv

    BPPHarv

    Joined:
    Jun 9, 2012
    Posts:
    318
    I stand corrected. Carry on.
     
  8. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    Why? That doesn't make sense. Do you have proof of this?
     
  9. Karmarama

    Karmarama

    Joined:
    Jul 11, 2011
    Posts:
    261
    http://docs.unity3d.com/Documentation/Manual/OcclusionCulling.html

    http://www.andrejeworutzki.de/game-developement/xna-4-tutorial-frustum-and-occlusion-culling/

    Perhaps tri count is reduced with frustum, but draw calls are still there anyway? I've only played with the two different systems for a short while, and m2h is easy to set up + includes a manual/.pdf explaining how it works as well. Occ-cull is just the best way to go, frustum is a secondary method if you can't occ-cull for whatever reason it may be.
     
  10. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    You should usually not have any draw-calls on objects that are outside of the camera frustum. Unless your object has a script attached with OnGUI method and draws some UI elements on your UI.

    In this case, the draw calls added by the OnGUI Script will remain, because OnGUI is still executed despite the object being outside of the frustum culling. But you can disable certain components, when they are outside of the camera frustum with MonoBehaviour.OnBecameVisible and MonoBehaviour.OnBecameInvisible.
     
  11. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    That's not entirely true. Even if you use Occulusion Culling, you're still always using Frustum Culling. Rendering only occurs on GameObjects with an enabled renderer that are in the camera's frustum and are not occluded by another object (assuming you're using occlusion culling). When an object is requested to be rendered the engine looks at each triangle and only draws that triangle if it is facing the camera. This is another process known as Backface Culling (which is why it's important to wind your triangle vertices in the correct order when creating meshes procedurally).

    Of course shaders can alter the behavior of an object to not follow the rules above if the user so desires.
     
  12. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Right, but if I have a NPC walking in the map?
    It will only walk when the camera see it?
    Or the script will be running and only the "3D Model" will not be rendered?

    My idea is start to create some terrains, but for this, I need to know how it works.
    The streaming of next terrains I need to code, or just put it all together, and the Unity will do the dirt work?

    How much big would be a good size for the terrain "slices"?

    The idea, is to create a MMO, like WoW. Not so big, just for hobby. But needs to be a "PRO" work.
    I want to get exp with this.
     
    Last edited: Aug 27, 2012
  13. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    This.

    Depends on the game and the hardware you are aiming for. The lower the hardware, the lower the slices would probably have to be.

    "Have fun". You have no idea how much work that is and even simple Singleplayer games take months of work. A MMO will take you decades and you will scrap it like 5 times, before it get playable when you, especially when you have never done a game before
     
  14. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    I know that the work is terrible, but it is one of the things that I want to learn to do.
    I'm not creating a "game of the year", I'm creating a game that I would like to play.
    I wrote that it will be a MMO, because it need to be prepared for terrain stream. Nothing more.
    But I can use this technic for any game using a terrain.
    I have another projects, and this "MMO" is one of them. I'm catching knowledge to the day I work on this, I'll know good techs.
     
  15. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    About NPCs and action things (like a mailbox).
    How I can add NPCs and mailboxes, and switches in the walls, without load everything in the memory?

    Example, when I create a doorbell in a door, I will put a script to make the action.
    If I create 100 doorbells like this around the "world", every doorbellwill load the script in the memory?
    Or only what is near the player?
    I know that it is not automactic, but how can I do this?

    A respawn is another good example. How I create 600 respawn and dont overload the "client"? It need to be all in the server? Or I will need to create "small worlds"?
     
  16. Divinexkill

    Divinexkill

    Joined:
    Jan 1, 2017
    Posts:
    1
    old post but for anyone else looking at this problem check out Map magic in store!