Search Unity

After playing minecraft...

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

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

    Arddra

    Joined:
    Jan 15, 2012
    Posts:
    5
    Martin, this is really, really impressive. I think you've done some great work and I really like some of the design choices you've made. The block within a block idea is fantastic and solves one of my pet peeves in minecraft: snow on tall grass. Keep up the good work and please, share more!
     
  2. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Is anybody reading my Block engine demystified series? So far I have covered some pretty basic stuff that I am sure all engines here have. Is there interest in here for me to continue?
     
    Last edited: Feb 29, 2012
  3. recon

    recon

    Joined:
    Nov 28, 2009
    Posts:
    119
    Just out of curiosity, which noise library do you guys use? Iv'e seen a couple of different ones floating around the forum and I just wondered which one is the most popular one? Or do you rely on your own functions?
    The C# libnoise port sounds like a good alternative to me..
    Any thoughts?
     
  4. montgomery

    montgomery

    Joined:
    May 10, 2009
    Posts:
    12
    yes, and please continue :)
     
  5. Arddra

    Arddra

    Joined:
    Jan 15, 2012
    Posts:
    5
    Paul, Yes I have been reading it. Yes, I'm interested... so please continue!
     
  6. Zhosay

    Zhosay

    Joined:
    Dec 12, 2011
    Posts:
    98
    Yes of course continue.
     
  7. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Didn't know it existed! I'll have a read .

    Done Reading
    That was great! I didn't even think about using inheritance instead of the enum route for BlockType, which can be a bit annoying. With the IsSolid function, would it be worse to just make it a "getter"?

    Code (csharp):
    1.  
    2. class BlockType {
    3.     public virtual bool IsSolid{ get { return false; } }
    4. }
    5.  
    6. class GrassType : BlockType{
    7.     public override bool IsSolid{ get{ return true; } }
    8. }
    9.  
    Edit:
    Using an interface also seems like a good idea too
    Code (csharp):
    1.  
    2. interface BlockType {
    3.     public bool IsSolid{ get; }
    4. }
    5.  
    6. class GrassType : BlockType{
    7.     public bool IsSolid{ get{ return true; } }
    8. }
    9.  
     
    Last edited: Feb 29, 2012
  8. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Yes. interface is a great idea.

    Whether you use a getter or a method is just convention. They are equivalent. From the microsoft design guidelines you get this:

    So based on guideline, it should be a getter like you say. But I did not want to complicate things for the javascript devs.
     
    Last edited: Mar 1, 2012
  9. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    If you guys are liking the articles, then for crying out loud, click on the like button :) let me know there is an audience.

    Also, english is my second language, so if you see bad grammar or spelling errors, please PM me.
     
    Last edited: Feb 29, 2012
  10. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Instead of articles, would some sort of wiki page be better? That way different approaches on the different systems could be added, documented, etc by various people.
     
  11. Zhosay

    Zhosay

    Joined:
    Dec 12, 2011
    Posts:
    98
    My chunks and blocks are working. Can somebody explain me how to use different textures on different blocks in the same chunk? I dont get that point, as its 1 mesh how I create different textures for the blocks?
     
  12. yumyum

    yumyum

    Joined:
    Feb 29, 2012
    Posts:
    5
    You can create a single texture will all your textures in it.
    This "container texture" will be a serie of squares, each square being a face texture for one block type.

    And then with the UV mapping you can map these squares to the block faces you want.

    For example when you add a block face, your add 4 vertices to the mesh.
    After that to map a texture on this face, for each vertices you add the coordinate of a square corner in your container texture (the square being your block type texture).
     
    Last edited: Mar 1, 2012
  13. Zhosay

    Zhosay

    Joined:
    Dec 12, 2011
    Posts:
    98
    Yes thx, thats the part I allready know :) I have a problem mapping the texture. You got an example for that?

    If the texture is 256*256 I thought it would be just like 0,0 0,16 16,0 16,16 these 4 cordinates but somehow I dont get it working or it shows a wrong texture streched or false.
     
  14. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    UV coordinates are between (0,0) (bottom-left) to (1,1) (upper-right). If you have a texture atlas of 16 textures (4x4) the UV coordinates for the upper left texture would be:

    Vertice A: (0, 1)
    Vertice B: (0.25, 1)
    Vertice C: (0, 0.75)
    Vertice D: (0.25, 0.75)

    Change the order of the vertices to suit your code. Hope this helps :)
     
  15. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Does anyone know how to do custom collision detection for this? I want to avoid relying on box colliders, and CharacterController. I think It should be possible to make a replacement CharacterController that takes advantage of the rectilinear geometry. But unity does not come with the source for CharacterController.

    Currently, I am creating box colliders around the player, but it is a bit dirty, It would be more efficient and simple if I do a custom CharacterCollider. Plus it will make it easier to incorporate into enemy AI.
     
    Last edited: Mar 2, 2012
  16. Zhosay

    Zhosay

    Joined:
    Dec 12, 2011
    Posts:
    98
    Thx martin that was what I needed gonna try it when home.
     
  17. yumyum

    yumyum

    Joined:
    Feb 29, 2012
    Posts:
    5
    I think the PackTextures method returns the UV coordinates no ?
     
  18. Zhosay

    Zhosay

    Joined:
    Dec 12, 2011
    Posts:
    98
    Thanks that together with that picture solved my problem. The streched effect was the wrong order for mine code.



    Edit: for the packing I used http://www.texturepacker.com/ has anybody a better solution? As its more optimized into small textures I think.
     
    Last edited: Mar 2, 2012
  19. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    We (HeadHunter really) use photoshop. We made a web site for people to submit their texture packs, vote, and comment on. These will be available in our game.
     
    Last edited: Mar 2, 2012
  20. Zhosay

    Zhosay

    Joined:
    Dec 12, 2011
    Posts:
    98
    Thats dangerous as you have no prove they own the textures they submit you. I would be carefull.

    Edit: thats btw why minecraft lets the texture thing to the user if they use textures its there thing not minecrafts.
     
    Deon-Cadme likes this.
  21. yumyum

    yumyum

    Joined:
    Feb 29, 2012
    Posts:
    5
  22. Zhosay

    Zhosay

    Joined:
    Dec 12, 2011
    Posts:
    98
    Sounds good too but requires more tweaking I think. Now I have block dirt is number 1 and the texture in my pack nr 1 is dirt. If you do the api call you have reassign them I guess. More brain smoke^^.

    Oh another question as I got the textures working is there a way to make a single block transparent? Does a transparent texture work or is there a easier/better way? For example a building preview block?
     
  23. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    We experimented with it, but gave up on it because:

    • It did not work at all in some phones.
    • It wastes a lot of memory because textures are essentially duplicated, once in their original form and another in the atlas form. If you use a straight up atlas, textures get uploaded to the video card and get removed from RAM. with PackTextures, the original textures will remain in RAM for ever.
    • It is apparently easier for someone with Photoshop skills to edit a texture atlas than edit a million small files (so I have been told.).
     
    Last edited: Mar 2, 2012
  24. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    This is someone testing Block Story in an LG Optimus 3D:



    I would skip over to 4:40 to see it with FULL detail and maximum view distance.
     
  25. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    More recent video



    This thing is getting closer and closer to an actual release
     
  26. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,409
  27. andererandre

    andererandre

    Joined:
    Dec 17, 2010
    Posts:
    683
    Has anyone of you gotten mipmapping to work? Minecraft itself doesn't have any mipmapping, but everything in the distance looks grainy and unnatural that way. I'm encountering a number of issues with mipmapping though.

    FilterMode.Point:
    • textures scale pixel-perfect
    • ugly transition between mipmap levels (apparently Unity isn't capable of fading the mipmap levels into each other with FilterMode.Point)

    FilterMode.Bilinear / FilterMode.Trilinear using PackTextures():
    • mipmapping artifacts (white borders around textures), not solvable by increasing the padding parameter

    FilterMode.Bilinear / FilterMode.Trilinear using my own texture atlas with mipmaps generated by Unity:
    • with this fix it's possible to reduce the mipmapping artifacts
    • textures seem to loose pixels in the corners when they are near the player and there are a lot of textures in the atlas (like 16x16)
    • UV coordinates should be correct but suffer from floating point errors and might just loose those pixels that way
    • PackTextures() will probably run into the same issue when it's atlas size grows if it doesn't optimize the UV coordinates somehow

    For the original Minecraft there has been a mod to add mipmapping: http://www.minecraftforum.net/topic/121092-v181-mip-mapping-patch/

    It looks to me like this guy uses pixel-perfect textures but still fades the mipmap levels into each other.

    EDIT: okay, I got it working with FilterMode.Trilinear and a custom atlas with a few pixels of padding around each block and a separate alpha channel. You loose the pixel-perfect-scaling that way, but I didn't want it so it's really more of a feature. For pixel-perfect scaling the only way would be to get Unity to fade mipmap levels into each other with FilterMode.Point - that's apparently not possible at the moment.
     
    Last edited: Mar 16, 2012
  28. StormSurge

    StormSurge

    Joined:
    Mar 17, 2012
    Posts:
    1
    in minecraft there's a few 100 blocks so the image of them is there:http://www.minecraftwiki.net/images/3/32/Template1.png.if you're making muiltplayer you should consider a griefing script so people cannot grief.also people can modify in normal minecraft so people will try here,i think you'll need to make a mod sopport.weather scripts and mobs will need coding.
     
  29. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    I didn't have the time to read all 49 pages of this and don't really know if this is supposed to be a strictly minecraft fans ONLY thread but if it isn't permit me to contribute the following dissenting opinion

    Not a huge fan of minecraft here. I did check it out to find out what all the hoopla was all about. BY'it' I don't mean the actual minecraft game but a minecraft type game that, if I remember correctly the m2h people here put out some time back.

    After playing it for a while I wasn't particularly impressed. I just couldn't understand the need for the rigid adherence to cubes. I often wondered why someone with the resources couldn't come up with an alternative where-

    - The inner layers always had to be cubes but
    - The outer layer could be composed of other simple shapes such as pyramid, wedge etc
     
  30. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
  31. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
  32. XavLar

    XavLar

    Joined:
    Feb 14, 2012
    Posts:
    143
    Hey guys, I'm using the Mineclone project (Beezir's), and I was wandering how do I add Water and/or beaches? I'm really baffled!
     
    Last edited: Mar 23, 2012
  33. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    flying around to show terrain:
    http://www.facebook.com/v/3530395536250
     
  34. Mike-D093

    Mike-D093

    Joined:
    Mar 29, 2012
    Posts:
    8
    Hey all... all i can say is WOW... nice work on all the screenshots..... this is a HUGE forum and probably exactly what I need. First let me say i'm not here to make a minecraft clone. My aims are to create a game that is blocky in appearance... maybe 2 layers of depth so that the player can stand on it and have the top one shatter when hit with x amount of force or something nifty like that. I tried doing a simple instantiation of cube prefabs... i got 10*10*10 to load nice, got 100*100*1 to load ok.... but ctrl-alt-del when i tried the 1000*1000*1.... yeah i know i should do some code for only displaying visible faces....

    thats where i would like some help. I've been programming for a while but very new to 3D graphic programming (got excited making an XNA/C# triangle, lol)... I have seen MINEPACKAGE on the forums here and in another post in this thread have seenthat someone used Beezir's MineClone.... are these the same? any good suggestions on where i should start? i want to learn how to do this and not take credit for someone else's hard work.... i mean it would be easier but then again i won't be able to contribute back if i can't understand what i'm doing.

    Thanks!!!
     
  35. Mike-D093

    Mike-D093

    Joined:
    Mar 29, 2012
    Posts:
    8
    So, since i've been lurking on here trying to grasp this stuff.... I'm also working on regular poly games.... one of which is a remake of the original DRAGON WARRIOR for the NES... bringing it into 3D..... the one thing that was most daunting was trying to accurately recreate the layout of the terrain.... after searching for an image splitter to break apart the .gif i downloaded of the map, i was so frustrated i fired up VB and started working on my own.... if there's interest in something like this i could clean it up and make it more dynamic to release to you guys... not sure how helpful it would be but what i have so far is selecting the image via in-app file browser, allowing specific pixel grouping, and exporting to bmp.... any interest? any suggestions? it's not from within unity but i figure if i want to do something that benefits from this, maybe some of you all would as well? let me know....
    height map for DW along with the original map it was created from..... removed color.. pixel by pixel, ran a threshold and a few filters... got a decent heightmap to match the game terrain.. wewt...

    http://imageshack.us/photo/my-images/406/alefgardmap.png
    http://imageshack.us/photo/my-images/441/heightmapq.png/
     
    Last edited: Apr 1, 2012
  36. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    @hugoboosh

    Besides this forum, the best resource I know for understanding this stuff is my own blog.
     
  37. Mike-D093

    Mike-D093

    Joined:
    Mar 29, 2012
    Posts:
    8
    Roger... going there now lol.... im getting frustrated with trying to figure this out.... most of what i pick up on easily is from youtube videos... i;ve been so frustrated the last few days i started working on my Dragon Warrior 3D project again (as above) and played minecraft last night ... lol
     
  38. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Just published another article, where I go over the big picture and how the process of generating terrain is put together.
     
  39. Mike-D093

    Mike-D093

    Joined:
    Mar 29, 2012
    Posts:
    8
    great article.... see i get the whole overview of how stuff works... i downloaded MinePackage as well.... and while it's great for those who want to make a minecraft style game with deep terrains and such it's overkill for what i want... do you have any recommendations for accomplishing the following:

    1. Yes basic cube shaped terrain.... i assume a mesh is needed as unity's terrain engine comes close to cube shaped but there are always slants as you cannot have 2 vertices above/below eachother....
    2. Terrain will at max be 2 cubes deep.... some places will have this depth to allow destructable "grass" or other terrain kind of object
    3. Terrain will be colored not textured... i'll write something based on height to change the material (lowest terrain height = black/dark brown, highest will be white like snow)

    In essence i think i would like to simulate not recreate the look of minecraft with it's blockiness but there will be no digging or "real" destructable terrain.... im thinking to model terrain meshes in blender and import but that would be very tedious as i'm the only one working on my project..... i looked into procedural mesh creation.... but i'm not quite sure how i could save it and i eventually would like to make my game multi-player so loading and unloading dynamically may cause issues there.... so... yeah... would you say to go with the pre-modeled meshes and then just instantiate some destuctable items (or even a cube kind of particle system)? The characters will be literally 3D Pixelated Mario looking guys but medieval theme....
     
  40. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    @huboboosh

    If you want terrain to be generated dynamically, you have to do procedural mesh creation, which is what all of us are doing.

    In your case, you want only 2 cubes deep? so you don't want mountains, sea, tree, overhangs, caves? If that is the case, I would suggest, you create a heightmap based on perlin noise, and then use that to determine the height of your terrain. See my second article where I explain how to do the mesh.

    To save, you would not save the mesh, rather, you would save the array of blocks you used to create the mesh.
     
  41. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,409
  42. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    You might want to check out Blockscape.
    It has smaller blocks (1/4th the size of Minecraft's), an infinite cave system and beautiful static shadows.

     
  43. Mike-D093

    Mike-D093

    Joined:
    Mar 29, 2012
    Posts:
    8
    @paulp

    Yeah i am following you on the whole thing about procedural mesh generation and saving the cubes there.... i actually dont want to generate the terrain on the fly..... i dont need caves, dont need over hangs... what i am aiming for on this project would be to have a static terrain.... with a small amount of "grass cubes" in areas that would be destroyable... the terrain would have hills but instead of gently sloping like unity's terrain engine does, it would have a cube shape... going up in increments of one whole unit instead of a float.... thats the only reason i've looked into procedural mesh generation.... and i would like to have it all created prior to runtime because it will be the same terrain all the time and i'd like some control over how it's made.... what would be awesome is if the terrain engine allowed multiple Y values for each x,z (i think i got the right variable order to make my point)...pretty much if you modeled concrete steps... thats how my terrain would look... with a tiny itty bitty extra layer on top of that which could be destroyed just for awesomeness effects....

    but this is kinda taking a back seat for now.... im working with some guys who published their first book and making a small game based off of that.... dark elf assassin here i come... haha
     
  44. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
    Epic oO
     
  45. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    I've been trying to get my terrain generator sorted out so it runs better. Right now it's fast and doesn't lag me out. The problem is that I can't place blocks on a chunk that is having it's mesh regenerated or else I get a nice mesh-related error. So now I have a question, how many 'worker" threads do you use to sift through the chunks and determine whether a chunk have its blocks and mesh generated? Here's how I'm doing mine, which probably isn't the best way to be doing it but it works.

    1. In Update it loops through each chunk and puts it into either a temporary blocksToGenerate or a meshToGenerate list, but never in both at the same time

    2. If either of the lists are greater than 0, it starts up a coroutine.
    Code (csharp):
    1.  
    2. //debugUpdateChunksCoroutineStarted and debugUpdateMeshCoroutineStarted
    3. //let me know if the coroutine is already in progress so it try to run it more than once at the same time
    4.  
    5. if(listBlocksToGenerate.Count > 0  !debugUpdateChunksCoroutineStarted) {
    6.     StartCoroutine(UpdateChunks(new Queue<Chunk>(listBlocksToGenerate)));
    7. }
    8. if(listMeshToGenerate.Count > 0  !debugUpdateMeshCoroutineStarted) {
    9.     StartCoroutine(UpdateMesh(new Queue<Chunk>(listMeshToGenerate)));
    10. }
    11.  
    3. Inside UpdateChunks each chunk in the list gets dequeued and it starts up its very own thread using ThreadPool for populating its block array. It transfers its own chunk information to a ChunkData struct to get information from in the thread so that the chunk can be freely modified without screwing up the thread

    4. After the ChunkData is done inside the thread where it populates its blocks, it puts itself into a blockApply queue so that the information can be applied to the chunk

    5. ChunkData in the blockApply queue are dequeued and applied to the respective chunk. The chunk is then told to generate it's mesh. It then has to wait for #1-#2 to decide what it should do

    6. In UpdateMesh, basically the same thing happens with UpdateChunks except that it generates for mesh instead of blocks and then puts itself into a meshApply queue. The chunk creates another thread in the ThreadPool for generating mesh

    7. ChunkData in the meshApply queue are dequeued and delt with. The Chunk is now free to have its mesh generated at another time
    ---------------------------------

    In short, I use
    6 Coroutines that turn themselves off when there is no more data to deal with
    2 different types of threads for the Chunks to generate their stuff from

    Coroutines (6) -
    UpdateChunks - Updates blocks
    UpdateMesh
    AddRemoveBlocks
    ApplyChunks
    ApplyMesh
    ApplyLight

    Chunk Threads (2) -
    GenerateTerrain
    GenerateMesh
     
  46. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Some kind of my progress report:

    1. I liked the effect of mesh distortion, but it seemed to be incompatible with water. If you distort water blocks too, it looks unnatural because water surface should be flat. If you don't, then there's a problem: if a water block is full of water then sometimes it is higher than its distorted neighbor blocks made of solid materials, that is even more unnatural. If you want to keep water surface flat and solid blocks distorted at the same time, you have to find a way to properly align water to coast blocks. Even if it were possible, it would be very tricky.

    I found a compromise: just do not distort vertically the blocks adjacent to water. It's much more easier to align water to coast blocks that are one unit high, even if they are distorted horizontally.

    $1.jpg

    2. I don't know about you, guys, but personally I always thought that blocks and materials have one-to-one relations, until I realized that there is no reason to keep it this way. Each block side could be represented by different material. I do not use texture atlases, so the code changes are minimal.

    This is a grass block. It looks like grass from above, like dirt from below, and has a special grass+dirt material on the rest of the sides:

    $4.jpg

    3. My procedural trees now more or less resemble the real trees, every tree is unique, and you can cut them into pieces if you want. It would be nice if the trees could naturally grow, but they can't, it was too late when I thought about it for the first time.

    $2.jpg

    $3.jpg

    Here are some old videos: http://vimeo.com/album/1857240
     
    Last edited: Apr 28, 2012
  47. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    wow alexzzzz, your engine is just incredible. And you seem to be getting really good fps from that screenshot.

    May I ask: if you are not using texture atlases, how do you make the different blocks have different textures?
     
  48. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
  49. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Multiple submeshes. Performance is the same (Radeon 4850, Q6600 2.4GHz), but I can use high-resolution textures. FPS on screenshots is shown on Radeon 6950, i2500K @4GHz. I did test it on low-end hardware.

    Correction: I did NOT test it on low-end hardware.
     
    Last edited: Apr 29, 2012
  50. Ragnaren

    Ragnaren

    Joined:
    Apr 28, 2012
    Posts:
    1
    It must be optimized
     
Thread Status:
Not open for further replies.