Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

After playing minecraft...

Discussion in 'General Discussion' started by jc_lvngstn, Oct 8, 2010.

Thread Status:
Not open for further replies.
  1. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    1000 Posts :p
     
  2. HeadHunter

    HeadHunter

    Joined:
    Dec 17, 2011
    Posts:
    53
    lol you post 1001 post :D
     
  3. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    @alexzzzz It looks amazing! Any chance of a standalone or webplayer? I'd like to see its performance in action :)
     
    Last edited: Apr 29, 2012
  4. Uforzyx

    Uforzyx

    Joined:
    Apr 30, 2012
    Posts:
    1
    Very remarkable progress on everyone's engines.

    Looking at jc_lvngstn's code and Beezir's code. jc_lvngstn's interpretation is good, but isn't infinite, while Beezir's interpretation is infinite in all axes (which is a big plus), but lacks a 'block' system. It's confusing on learning how chunk generation work. Maybe the fact it's little to not commented, or that I'm not looking/thinking at the right angle, or I'm rushing and not slowly ingesting the information (reminds me when I started learning Lua and I haven't learned how tables work).

    I seem to not be able to grasp the concept of how the chunks generate, meshes are created, unloading and loading of chunks when the 'player' is an X amount of units away, etc. etc.

    Main question is: where would one start with something like a chunk / terrain generator in all directions?

    Side note: Hopefully this post isn't too messy, run-on, and vague. 12:48 AM with little energy left isn't helping much on my ability to elaborate and be clear.
     
  5. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    If there are things you don't understand about the terrain generation, like specific things, you should tackle learning those separately. For instance, mesh generation. You should play around with it outside of any terrain generation theme, in a completely different project. Also when it comes to doing infinite terrain, learn how to make one chunk and the rest should come pretty easy to you. You could try doing a simple 2D infinite terrain with GUI tiles. That would give you a good idea of how the "infinite" part works.

    That's just how I would do things. If you learn differently than I'm not sure what to say, I'm not a professional teacher. I can learn how this stuff works but teaching others about it doesn't come as easily for me. Go slow and don't try to learn it all at once.
     
    Last edited: Apr 30, 2012
  6. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Standalone: x-bin 30-04-2012.zip
    https://skydrive.live.com/redir.asp...2713A2C49773E7!305&parid=D42713A2C49773E7!304

    Keys:
    E ― take
    Z ― drop
    X ― throw
    Tab ― inventory
    Shift ― run faster
    Control ― walk slower
    ~ ― debug menu

    For other keys see debug menu.

    Items in the inventory:
    1) glass block - for placing glass
    2) bricks block - for placing bricks
    3) shovel - for dirt and sand
    4) pick - for stone and bricks
    5) axe - for nothing
    6) firefly - for fun :) It's an unlimited source of fireflies. When you drop or throw them, they fly away.

    --


    --
    About performance
    1. Today I tested this build on a notebook with an old and lousy Intel graphics, and I got 10-15 fps.
    2. Billboard grass turned on => 420 fps, turned off => 650 fps. I think I should move it to separate game objects and reduce its culling distance.
     
    Last edited: Apr 30, 2012
  7. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    Thanks for the executable!
    It runs at approx 300 fps on my computer. It's very smooth, only lags a bit when moving to the edges of the map.
    Digging feels very natural with the distorted meshes. It makes the earth seem soft like mud :D

    It's looking great. Keep it up! :)
     
  8. BusterBlader

    BusterBlader

    Joined:
    Apr 23, 2012
    Posts:
    79
    Very cool Thread guys :) I want to generate a simple Terrain (only hills)...how should i do this? Sorry, but i can't look through the entire Thread :S
     
  9. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    alexzzz,

    Performance in my computer:
    intel i5 @2.50 GHz,
    built in Intel HD Graphics 3000,

    When I start the game I get about 14 fps, but it drops down to 7 fps sometimes. After a couple of minutes, it starts going up and stay between 45 -60 fps. Not sure if it was because it finished processing something, or because I was finally able to go down to ground level.

    Some things I noticed:
    * I start in the middle of the air, the only way to go down seems to be to hit ground at my heght, and after that, it starts going down slowly.
    * caves are pitch black. Some ambient light or light coming from the player would be good to explore caves.
    * Textures are beautiful
    * distorted terrain vertices look great.
     
  10. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I don't know why is that. 5..10 seconds should be enough to calculate everything.

    Press 'Y' ― it turns on and off gravity.
     
  11. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
  12. HeadHunter

    HeadHunter

    Joined:
    Dec 17, 2011
    Posts:
    53
    alexzzzz, i have RadeonX800 video card on my old PC, and grass looks like black plane. Please take a look at your transparent shader, i think you need to make fallback for older cards.
     
    Last edited: May 3, 2012
  13. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    We just added biomes to our terrain generator

    [video=facebook;3828780675692]http://www.facebook.com/video/video.php?v=3828780675692
     
  14. HeadHunter

    HeadHunter

    Joined:
    Dec 17, 2011
    Posts:
    53


    Could you ever imagine that may be, more epic ...
    What, stone by stone, build your house.
    Protect your home with a weapon in your hand.
    And one day ... Resist evil, unseen until now.
    Fight and win!
    Hunt for unknown monsters! On land and under water
    Choose the path of creation ... Or destroy everything in its path!
    Explore a truly infinite world.
    Take off into the sky!
    Choose the type of weapon that fits you and develop the skill of possession to perfection.
    But always be ready to meet with something that will kill you ...
     
  15. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
  16. botumys

    botumys

    Joined:
    Apr 16, 2009
    Posts:
    707
    Hi alexzzzz,

    I'm a big fan of you work. I like the way you create your engine, very organic and detailed elements.
    I wait impatiently next progress video!

    btw if you need special fx (or something else) just ask ;) (my channel with some fx made for asset store : http://www.youtube.com/user/botumys )
     
  17. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    botumys, your magical effects look pretty "real"!

    --


    Mesh distortion:



     
    Last edited: May 25, 2012
  18. XavLar

    XavLar

    Joined:
    Feb 14, 2012
    Posts:
    143


    sexy! Great work! :d
     
  19. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
    jc_lvngstn's and Beezir's Packages the only Examples so far?

    I love Beezirs Package but its hard to understand to add more Landscape Blocks or change the Noise of the Map
     
  20. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
  21. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    @paulp Cool! It was interesting to see the development from the early stages. Congrats! :D
     
  22. gen

    gen

    Joined:
    May 29, 2012
    Posts:
    1
    Description has mistake. In russian language "что ни будь" wrong written, right "что-нибудь".
     
  23. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
  24. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    Thought you might find it interesting. Also created in Unity.

     
  25. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
  26. codan

    codan

    Joined:
    Apr 26, 2012
    Posts:
    8
    Is it done with Voxelform from the AssetStore?
     
    Last edited: Jun 8, 2012
  27. codan

    codan

    Joined:
    Apr 26, 2012
    Posts:
    8
    Last edited: Jun 8, 2012
  28. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
    I have added some Water to jc_lvngstn last release.
    from ground up to 30. looks pretty nice :)


    beziers viewdistance styled chunk removing is the next step to save some RAM i think.
     
  29. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I suspect it is.
     
  30. codan

    codan

    Joined:
    Apr 26, 2012
    Posts:
    8
    I have question @all who work on a Minecraft engine: how do you do collisions? Do you use the Unity build-in mesh colliders? If so, how long does it take to insert a new chunk? In my engine, adding the mesh-collider is the biggest part. I measured ~5ms for generating the chunk and ~120ms for adding the mesh colliders (assume ~7500tris).

    So I started to remove the mesh colliders and do collision detection by using the fact that we have a block world.

    Or is there a better way?
     
  31. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    That is the best way.

    Another quick way to do it is by placing box colliders as you move around the map, but the skin width property of the character controller is problematic. If you set it too high, you get stuck on ceilings, if too low, you walk through blocks.
     
  32. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
  33. codan

    codan

    Joined:
    Apr 26, 2012
    Posts:
    8
    Yes, this is my observation, too! So I'll remove the CharacterController and do the collision checks by myself...
     
  34. codan

    codan

    Joined:
    Apr 26, 2012
    Posts:
    8
    @alexzzzz: a single mesh would be pretty fast. But you would have to place a mesh not only at the player's position, but also at every MOB's position. Or did I get it wrong? Moreover when shooting f.e. a rocket you do not know the collision position, not even the chunk.

    Do you use it successfully in your engine? (...that looks great I have to say)

    I am currently doing the voxel traversel approach (http://www.cse.yorku.ca/~amana/research/grid.pdf, http://www.xnawiki.com/index.php?title=Voxel_traversal)
     
  35. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Every chunk in my world that has its own collider:





    "[main] apply collider" counter measures the time it takes to create an optimized mesh object from the lists of its vertices and faces and to assign it to a MeshCollider component.

    UPD: I have updated the second screenshot, there is a new "max" column now.
     
    Last edited: Jun 9, 2012
  36. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    We are adding crafting real soon now!!!. Here is a screenshot:

     
  37. codan

    codan

    Joined:
    Apr 26, 2012
    Posts:
    8
    So to understand you correctly: you use the colliders from Unity? And creating them from the mesh takes in avarage 1.4ms? That's really a very good time! Why do I have so bad performance? Do you also use this code to create the colliders:

    Code (csharp):
    1.         m_MeshCollider[idx].sharedMesh =   null;
    2.         m_MeshCollider[idx].sharedMesh = m_MeshFilter[idx].mesh;
    I also measured the time to create the colliders for an average chunk like this:


    I got about 50ms for the two lines about for the one chunk (triangles=8445)...

    UPDATED: now I got your approach! Sorry for being so slow...
    You create an extra optimized mesh with much fewer triangles. This is great!
    But if the level gets very complex, like in caves or with trees, can you also reduce the triangels that much?
     
    Last edited: Jun 10, 2012
  38. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Have you measured how much "= m_MeshFilter[idx].mesh" takes? Try to use sharedMesh instead.

    Here is the method I call to create or update colliders (Geometry is a class to store lists of vertices, triangles, normals, etc; nothing special about it.)
    Code (csharp):
    1. public void ApplyCollider(Geometry geometry)
    2. {
    3.     if (geometry == null || geometry.IsEmpty())
    4.     {
    5.         if (colliderObject != null)
    6.         {
    7.             Destroy(colliderObject);
    8.         }
    9.  
    10.         return;
    11.     }
    12.  
    13.     var timer = new Stopwatch();
    14.     timer.Start();
    15.     {
    16.         if (colliderObject == null)
    17.         {
    18.             colliderObject = CreateGameObject("collider", Layer.Invisible, needsRenderer: false, needsCollider: true);
    19.         }
    20.  
    21.         var meshCollider = colliderObject.GetComponent<MeshCollider>();
    22.         var mesh = meshCollider.sharedMesh;
    23.         if (mesh != null)
    24.         {
    25.             Destroy(mesh);
    26.         }
    27.  
    28.         meshCollider.sharedMesh = null;
    29.         meshCollider.sharedMesh = geometry.ConvertToMesh(verticesAndTrianglesOnly: true);
    30.     }
    31.     timer.Stop();
    32.     PerformanceMonitor.IncrementCounter("[main] apply collider", timer.ElapsedMilliseconds);
    33. }
    Here is the difference between normal and optimized collider meshes. The graph shows frames duration while all the chunks update their lighting, terrain geometry, and colliders.





    --
    BTW, all the screenshots are from stanalone builds, which run faster.
     
    Last edited: Jun 10, 2012
  39. codan

    codan

    Joined:
    Apr 26, 2012
    Posts:
    8
    I tried .sharedMesh but it leads to the same (bad) performance as .mesh. The time needed seems to grow with the number of triangles (as one can expect :(). So your approach might be the best when using the Unity colliders.

    Yes that's true. But the collider approach is (for me) dimensions too slow. In a chunk with trees (=transparent leaves) and canyons, there can be easily 12k tris or more. So I decided to remove the colliders and do the collision by myself.

    Anyway, your screenshots look really amazing! Looking forward for the game it will become...
     
  40. HeadHunter

    HeadHunter

    Joined:
    Dec 17, 2011
    Posts:
    53
  41. codan

    codan

    Joined:
    Apr 26, 2012
    Posts:
    8
    Thank you for these deep information! With this I can implement the whole Unity PhysX collision...

    [Btw: as far as I understand the Minecraft code, it uses only AABB (axis aligned bounding boxes) for collision]
     
  42. Foam

    Foam

    Joined:
    Jun 13, 2012
    Posts:
    322
    I am working on a similar project and have a question regarding the noise function.

    So I have the Perlin 3D noise function working and it is generating 3D noise off of (x, z, y, seed) as the inputs. This gives me fine 3D noise, but, it's truly 3D----the tops and bottoms of my chunks end up getting sheared off essentially as my top/bottom is independent of the noise function.

    I need to scale it in some way so that the lower in a chunk, the more likely it is to be a solid, and the higher, the more likely to be air. Similar to the article here: http://www.gamedev.net/blog/33/entry-2227887-more-on-minecraft-type-world-gen/

    I'm having trouble wrapping my head around this. Does anyone have any suggestions?

    I'm not sure how to incorporate the Perlin noise with both x,z,y positoin as well as some height gradiant.

    In particular I'm looking at this part of the article:


     
    Last edited: Jun 13, 2012
  43. Foam

    Foam

    Joined:
    Jun 13, 2012
    Posts:
    322
    I'm getting mildly close...

    It looks like he's doing something like:

    p = Perlin(x, z, y, seed) // return float from [0, 1] based on coordinate
    g = Gradient(y) // return float from [0,1], smoothly where g=0 if y=0 and g=1 if y = max height
    density = Pow(p * g, 0.3)

    where density < 0.5 is "solid" and >= 0.5 is "air"

    This is giving me something reasonable so far. My terrain is a little wonky, but, I'm pretty sure that's a result of a bug in Perlin() (I rolled my own noise functions). So far it looks to be setting a good lower bounds on air/ground.
     
    Last edited: Jun 13, 2012
  44. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    You could also create a heightmap from 2D Perlin noise then substract the 3D Perlin noise to create caves.
     
  45. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
  46. HeadHunter

    HeadHunter

    Joined:
    Dec 17, 2011
    Posts:
    53
  47. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Nice screenies both of you! Makes me jealous and also makes me want to hurry up and get my terrain generator back up and working. I've started fresh. I'll be using a single block array, the chunks will be structs instead of classes, and once I've got some of the chunk-moving logic sorted out it should work better than my previous generator.
     
  48. HeadHunter

    HeadHunter

    Joined:
    Dec 17, 2011
    Posts:
    53
    Awasome) Wish you good luck with development.
     
  49. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    GIB3D,
    Good luck! Some parts of my engine has been rewritten two or three times already, and there's no such a part that hasn't been rewritten at least once, except those that were thrown away. :)

    --
    I'm currently trying to make a snowfall. I want it to cover large areas, say at least 64x64 blocks wide, but at the same time not to happen inside caves. For now, I see two ways:
    a) to use the particle collision feature of the legacy particle system, but I suspect it's an overkill;
    b) to control each particle manually and destroy those that are inside solid blocks, but I don't want to do much calculations in the main thread.

    Any other ideas?



    PS
    Another idea is not to mess with particle systems, but create a bunch of long vertical billboards around the player from the sky to the ground surface and to scroll down a snowflakes texture using its uv offset. However, I'm not sure it would look that nice.
     
    Last edited: Jun 19, 2012
  50. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    The screenshots look great!

    Here's an untested idea :) You could have a single vertical plane on each of the highest blocks around you and scroll the texture with uvs. In the case of rain, you could also add some particle effects for raindrop splashes since you would know the position of the highest block. In a square area around the player of say 20x20 blocks, it would be 400 planes. It could easily be just one mesh. The planes don't need physics so you could regenerate the mesh pretty fast as the player moves. Again, untested, and I don't know what it would look like :D

    I think that's what the latest Minecraft releases do for rain and snow.
     
Thread Status:
Not open for further replies.