Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

After playing minecraft...

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

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

    Deadwall

    Joined:
    Feb 13, 2012
    Posts:
    5
    The smoothing looks great. At least there arn't gaps in the triangles of joined chunks. Could the smoothing be done as like a 2nd or 3rd priority after the initial chunks are created? Also how does your grass look on each? I imagine the grass would hide the seams fairly well.
     
  2. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    Hey guys, I just stumbled across this project when looking for information on accurately voxelizing meshes. http://voxeljs.com/ It is a pretty cool project and has a lot of source examples on how to do several topics for those of you interested in making a voxel game in java.

    -Dane
     
  3. mescalin

    mescalin

    Joined:
    Dec 19, 2012
    Posts:
    67
    in "javascript" and it just killed my browser, voxels used to be used to quite good effect for 3d sprites back in the build engine, it took some time before poly detail caught up.

    i don't personally consider cube polys being rendered as "voxels", i'd say a normal map is closer to what voxels actually are
     
  4. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    I don't think anyone really argues that the cube polys themselves are voxels; they are instead a polygon based visual representation of voxel data. The underlying data structure is absolutely voxel based.
     
  5. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    Finally after all this time, I figured out how to do mipmaps without having ugly seams between blocks. The result is just stunning. See for yourself:



    Watch at 1080p full screen to really see the difference.
    Pay close attention to the leafs in the trees, the grass, and the trunk of the coconut trees.

    The video does not do justice to how much of an impact mipmap really have, youtube compression really messes it up. However at high resolution you can clearly see what I am talking about.
     
  6. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    Looks awesome Goldbug :D
     
  7. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    Because getting lost in an infinite world sucks, I give you teleporters, radar and bed:

     
  8. HeadHunter2009

    HeadHunter2009

    Joined:
    Jul 3, 2012
    Posts:
    50
    Another video showing upcoming features from 5.0 update;)
     
    Last edited: Jan 24, 2013
  9. HeadHunter2009

    HeadHunter2009

    Joined:
    Jul 3, 2012
    Posts:
    50
    BlockStory radar
     
  10. XavLar

    XavLar

    Joined:
    Feb 14, 2012
    Posts:
    143
    Hey HeadHunter and goldbug, do you guys think you will change the 3d models to suit the terrain? Think of this as constructive critisim; The 3D models look really out out place, try some blocky models then it will look awesome :)
     
  11. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I'm not really sure, what I'm doing...

     
  12. botumys

    botumys

    Joined:
    Apr 16, 2009
    Posts:
    707
    It's a kind of fluid circulation? Can be cool to think to add a vent in a cave before to create a fireplace. (with the risk to suffocate because smokes)
     
  13. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    Showing a bunch of Block Story features

     
  14. HeadHunter2009

    HeadHunter2009

    Joined:
    Jul 3, 2012
    Posts:
    50
    Plants and simple farming system

    TNT

    Acid
     
    Last edited: Feb 12, 2013
  15. alexzzzz

    alexzzzz

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

    HeadHunter2009

    Joined:
    Jul 3, 2012
    Posts:
    50
    alexzzzz, your tree wery nice))
     
  17. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Pretty neat, Alexzzzz :)
     
  18. BSECaleb

    BSECaleb

    Joined:
    Jan 29, 2009
    Posts:
    72
    alexzzzz,

    Nice! Can we get a description of what is going on with that tree animation?
     
    Last edited: Feb 14, 2013
  19. Windexglow2

    Windexglow2

    Joined:
    Sep 23, 2012
    Posts:
    90
    Alexx - What would those look like with a solid color? A la make them look like trees from a painting.
     
  20. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    The tree crown mesh is generated as an isosurface around some tree nodes. The distances from all the points of the surface to their closest tree nodes are equal. If there is only one node, the isosurface will be a sphere. If there is two nodes, the isosurface will look like two separate or intersecting spheres.





    There is still room for improvement.

    --
    Isosurface demo starts at 8:30

     
  21. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    That's really cool! Is there any resources you could share for those of us who would want to play around with isosurface trees? :) Also wondering what your plans for your project were? Are you planning on making a game or just like dabbling in voxels? :D

    -Dane
     
  22. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    View attachment $MarchingCubes.unitypackage (alternative link: http://skydrive.live.com/?cid=d42713a2c49773e7&id=D42713A2C49773E7!852)



    Usage:
    Code (csharp):
    1.  
    2. var geometry = new Geometry();
    3. geometry.AppendIsosurface(scalarField, bounds, samplingResolution);
    4. meshFilter.mesh = geometry.ConvertToMesh(meshFilter.mesh);
    AppendIsofurface method requires a delegate that represents a scalar field - a function than takes a Vector3 and returns a float value. The surface will lie on the points where the values are zero, all the negative values will be inside the surface, all the positive values outside.
     
    Last edited: Feb 18, 2013
  23. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    Wow, thanks so much for sharing! I took a look at the functions and it is definitely helpful in understanding on how to add two isosurfaces together, but this looks like it requires both isosurfaces that are being combined to have the same resolution. Which makes sense but with a little tweaking I am sure we could have isosurfaces of varying resolutions being appended to one another?

    -Dane
     
    Last edited: Feb 17, 2013
  24. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
  25. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Try Internet Explorer.
     
  26. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    Tried..also chrome, and anonymouse and cleared cache and tried without logged in :)
    and also by adding random values to the link, http://forum.unity3d.com/attachment...d=1361025454&superunity=1234523452345asdfasdf

    I've had similar problems with other attachments in the forum lately..
    (i've reported it, but at first look they didnt see any problems.. so if anyone else has it, let me know)

    *Hey now it works - in firefox atleast :)
     
  27. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I experienced the same problem yesterday in Opera, today it works fine.
     
  28. XavLar

    XavLar

    Joined:
    Feb 14, 2012
    Posts:
    143
    Nope, tried in FireFox and Chrome still a 1x1 GIF. Could you upload it with Dropbox or Mega?
     
  29. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
  30. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    Hmm, I got it with no problems on the first try... Also, the new link you provided has other files exposed... Don't know if you intended to share those or not so I just wanted to let you know.

    Thanks again alexzzzz!
     
    Last edited: Feb 18, 2013
  31. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    That's fine, it's my public folder.
     
  32. Foam

    Foam

    Joined:
    Jun 13, 2012
    Posts:
    322
    Goldbug,

    How did you implement AABB with physics?

    Did you use your own physics engine or integrate your AABB code with PhysX?

    I am having some trouble getting my code to play nice together. The physics looks reasonably ok, the bounding volume heirarchy is ok, collision detection is ok, but contact generation is giving me a headache. Any suggestions?

    Thanks,
    Foam
     
    Last edited: Feb 21, 2013
  33. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    Unfortunately, unity has no way to have custom colliders. So my solution was to change the CharacterMotor script to use my AABB replacement for CharacterController.
     
  34. Foam

    Foam

    Joined:
    Jun 13, 2012
    Posts:
    322
    Thanks. I did a similar thing.

    Did you use SAT for contact generation? And are you using AABB vs AABB contacts or AABB vs planes?

    I really need to sleep on this awhile I think... I can handle contacts in one axis just fine using box vs plane contacts (e.g., the Y axis) but when I try to add in X or Z I get all kinds of problems. It's driving me crazy.

    I know there's a simple solution and I'm just completely missing it. Grrr. ;)
     
    Last edited: Feb 22, 2013
  35. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Recently I was inspecting my block physics code and decided to make a public standalone build to check whether the physics is really natural and intuitive or I should revise its principles. So, here it is (133 Mb)

    Permanent link: https://1drv.ms/u/s!Audzl8SiEyfUoULsKMdEgY_elHkd
    Temporary link: https://dl.dropbox.com/u/102171874/X/x-bin 25-02-2013.zip

    One bug I'm aware of is when a vertical pile of blocks falls, some blocks may disappear.





    --------------------------
    Keys:
    R - reset player's position
    F5 - quick save (the game also always autosaves on exit)
    F9 - quick load

    WASD - movement
    Space - jump
    Shift - sprint
    Control - walk

    E - take
    B - toggle flashlight

    Z - drop what's in the active hand
    X - throw what's in the active hand

    LMB - make the left hand active, or use the item in the left hand if it's already active
    RMB - make the right hand active, or use the item in the right hand if it's already active
    MMB - free hands

    Tab - show inventory (use left or right mouse button to take an item in the corresponding hand)

    F1 - show debug inventory menu, use it to add any item to the inventory

    I - show debug info (hold Alt to temporary lock the camera)

    ~ (tilde) - debug menu
    --------------------------
    Tools and items:
    Pickaxe - against stone blocks
    Shovel - dirt and sand blocks
    Axe - wood blocks
    Saw - trees
    Hammer - pretty useless
    Raw wood - can be put in a campfire
     
    Last edited: Aug 16, 2017
  36. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    Sweep AABB vs AABB.
     
  37. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    alexzzzz: Just pure amazing : D The smoke is soooo cool not just going up but follows tunnels and chimney paths : D
    One bad thing thou was that it was pretty easy to fall through the world when placing blocks close to yourself, did not have a lot of time to test so will test the physics a bit more later : )

    Edit: Did some more testing, and the tree tutting mechanics was very, very impressive! To be able to gut of branches and whatever at an exact location is very cool, also the overall physics i think are very good, a bit buggy sometimes with blocks falling through, some blocks stuck in the air and once a roof smashed me through the world : p
    The smoke when stone is collapsing is a very nice touch that adds a lot to the feeling, keep up the great work, this really have potential : )
     
    Last edited: Feb 25, 2013
  38. Vanamerax

    Vanamerax

    Joined:
    Jan 12, 2012
    Posts:
    938
    wow alex! you keep impressing me! :D

    Nice you give us the chance to play around with your voxel engine, are you going to release it sometime (paid or free?) :)

    really like the speed and complexity of everything! Especially the tree cutting is nice, although it might get a bit buggy when you cut very thin slices. Maybe a minimum distance from a previous cut?

    Is the terrain generation also this fast when using simplex noise or does it slow the generation down a bit?

    EDIT: just played around with the debug menu and OMG I found out you can climb in trees! How awesome is that? :D
     
    Last edited: Feb 26, 2013
  39. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    @Alexzzz - Awesome work! One of the most impressive things to me is how you handle trees. From the generation of them to cutting them down. Our small indie studio is working on a game with dynamic environments - I wish we had access to something like this. The flowing grass is great, and I love how you handle the snow! The texture was missing or not working, but the idea is there and it works (and I love running around listening to my footsteps crunch in the snow). Let me know if/when you decide to license it.
     
  40. botumys

    botumys

    Joined:
    Apr 16, 2009
    Posts:
    707
  41. _Max_

    _Max_

    Joined:
    Feb 21, 2013
    Posts:
    160
  42. Vanamerax

    Vanamerax

    Joined:
    Jan 12, 2012
    Posts:
    938
    Just thinking about ways to gain some performance, Don't know if any of you thought about this or (tried to) implemented it yet

    According to the MSDN documentation, the "unsafe" keyword is most usefull in the following cases:

    - Dealing with existing structures on disk
    - Advanced COM or Platform Invoke scenarios that involve structures with pointers in them
    - Performance-critical code

    Now the last option is something of interest here. It states that using the unsafe keyword gets rid of array bounds checks.

    Now I'm wondering, does this also speed up calculations, like /, *, + and - ? What is the speed gain of this micro-optimisation and how "unsafe" is it to use?
     
  43. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,203
    Using unsafe code would not speed up math. It allows you to use pointers to address memory. With this, you can allocate a block of memory, and write into it using the pointer, and walk through the memory by incrementing the pointer. This is faster than using an array. However, it's more dangerous, and you have the overhead of getting the memory block (by pinning the memory). This will also cause issues in garbage collection, because the pinned memory cannot move.

    I would not recommend this as a way to improve your performance, as performance gains would likely be minimal (except in some cases, like working on a DIB) I would recommend to look at the algorithms you use, and make sure you are doing things optimally (ie, when you process an array, do you process all items? If not, perhaps you should keep a separate list of items to process, etc).
     
  44. Vanamerax

    Vanamerax

    Joined:
    Jan 12, 2012
    Posts:
    938
    Thanks for the clarification, I was reading it on the MSDN and saw the word "performance" so I thought that might work out :D
    I'll have a quick look over the code tomorrow

    Just out of curiosity, How do you guys manage your chunks, processing and memory? (especially curious about Alexzz, hint hint) :p
     
  45. Foam

    Foam

    Joined:
    Jun 13, 2012
    Posts:
    322
    This is an ongoing issue for me, but, basically:

    1. Terrain generation (perlin noise type stuff) and mesh calculation is done in threads via a thread pool. The only Unity items you need to reference in this area are things like Vector3, Vector2, etc., so you are thread safe provided the rest of your code is. Bounding Volumes and such can be calculated in the threads as well if you go that route.

    2. A "chunk manager" takes the data generated in the threads and uses it to actually create the Mesh game objects and display them, to to keep track of them, to remove them from the game, etc. This is a MonoBehaviour object(s). It is responsible for telling the thread manager when it needs chunk data and receiving updates from the thread manager.

    3. A separate area handles terrain/player interactions, collision detection, physics, etc. This is also a MonoBehaviour object(s).

    4. Memory isn't something I've gotten to yet but I can tell managing Garbage Collection is going to require some effort. I'll probably have another object(s) that manages this that is sort of a Cache.


    This thread contains some performance debates if that's what you're looking for. Things like how to make lighting quick, how to use a circular array to store to speed up voxel access, how to optimize meshes, etc.
     
  46. Foam

    Foam

    Joined:
    Jun 13, 2012
    Posts:
    322
    Making progress. I was using discrete AABB vs AABB which was giving me some problems with multiple contacts, nevermind missing some collisions. I think I've got it mostly figured out now. I hope :) I like the massive speed increase over MeshColliders but I've certainly spent more time on the collision and physics than I would have liked.
     
  47. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I managed to reproduce the blocks flying in the air. Fixed it.

    I can't say right now. If I completely lose the interest (no signs of it after 1.5 years), I'll release it as is (don't know under what terms). If I don't, then maybe I'll release it too, maybe I'll use it for myself. The only thing I can say for sure - no releases in the near future.

    Nice idea.

    Since I still don't have a terrain generator which I would be proud of, I don't know how fast or slow it is. All the previous generators were experimental and now I use a simple flat terrain, it helps me to focus on what's important.

    Cool!!! I didn't know that :D
    Thank you for the hint!

    With all I have learnt so far I want to rewrite my tree code from scratch. I'd like a tree object to be a black box with a simple interface, right now it's a dense ball of dependencies. When I put everything in order I may release it at the store. It's not a priority though.

    The snow is supposed to look like this:


    I don't pay much attention to the art, it's still too early I think. The last time I updated some textures it was just because it was hard to create good height maps for the old textures to test parallax mapping effect.
     
    Last edited: Mar 2, 2013
  48. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I spent the Friday evening trying to calculate the sum of elements in an array using pointers faster than using indexers. I can't say I failed, but it's not a big success either:

    Safe: 82ms, sum = -134217728
    Unsafe: 81ms, sum = -134217728


    Tested on i5-2500K @4GHz, .Net 3.5, x64

    http://pastebin.com/MpajHbPG

    The main three tricks about memory are:

    1. One big array to represent all the chunks around the player. No boundaries between chunks. It boosts lighting calculations and generating chunk meshes, and the code looks neat without all those tons of ifs and elses.

    2. The array is flat, i.e. one-dimensional. Such arrays are faster than multi-dimensional.

    Code (csharp):
    1.  
    2. public readonly Block[] blocks = new Block[WORLD_ARRAY_SIZE];
    3.  
    4. public Block GetBlock(int wx, int wy, int wz)
    5. {
    6.     int pointer = CalculatePointer(wx, wy, wz);
    7.     return blocks[pointer];
    8. }
    9.  
    10. public void SetBlock(int wx, int wy, int wz, Block value)
    11. {
    12.     int pointer = CalculatePointer(wx, wy, wz);
    13.     blocks[pointer] = value;
    14. }
    15.  
    16. public static int CalculatePointer(int wx, int wy, int wz)
    17. {
    18.     wx = WORLD_WIDTH_MASK;
    19.     wz = WORLD_WIDTH_MASK;
    20.  
    21.     return (((wx << WORLD_WIDTH_SHIFT) + wz) << WORLD_HEIGHT_SHIFT) + wy;
    22. }
    23.  
    24. public const int WORLD_WIDTH_SHIFT = 10;
    25. public const int WORLD_WIDTH = 1 << WORLD_WIDTH_SHIFT;
    26. public const int WORLD_WIDTH_MASK = WORLD_WIDTH - 1;
    27.  
    28. public const int WORLD_HEIGHT_SHIFT = 7; // 128
    29. public const int WORLD_HEIGHT = 1 << WORLD_HEIGHT_SHIFT;
    30. public const int WORLD_HEIGHT_MASK = WORLD_HEIGHT - 1;
    31.  
    32. public const int WORLD_ARRAY_SIZE = WORLD_WIDTH * WORLD_WIDTH * WORLD_HEIGHT;
    33.  
    3. The array is circular. You don't need to scroll it when the player moves through the world.

    Processing is done mostly in background threads: terrain generation, disk IO, lighting, generating lists of vertices, triangles, etc for meshes. Then in the main thread I create gameobjects, meshes for them, collision meshes and assign materials to the meshrenderers.

    The order in which the chunks are processed is inferred automatically as described in this post: http://forum.unity3d.com/threads/63149-After-playing-minecraft/page32?p=719409&viewfull=1#post719409
     
    Last edited: Mar 1, 2013
  49. Foam

    Foam

    Joined:
    Jun 13, 2012
    Posts:
    322
    re: unsafe code.

    arrays already use pointers internally to address items. that's why they're fast---it's one block of memory with a start and an end pointer with indexing just using pointer arithmetic based off the start or end.

    pointers are good more for things like recursive data structures.

    for example, a struct with an array of child structs

    struct Node:
    child_nodes as (Node)

    is painfully slow in .NET because structs are value types and adding in a (Node) means you have to box the struct because now it's not a value type, it's a reference type. which in turn ends up being slower than just doing

    class Node:
    child_nodes as (Node)


    Because classes are already reference types and don't need to be boxed.

    However, with unsafe, that is, with pointers, you can use a traditional recursive struct with no boxing involved, and it ends up being very fast.

    Generally though pointers are rarely worth the effort.
     
  50. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I didn't get the idea of what's going on. Could you write it in C# syntax?
     
Thread Status:
Not open for further replies.