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. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447


    I have been playing with 3d-noise for a long time already, but still have no idea how to make good caves, long and narrow.
     
  2. Manmax75

    Manmax75

    Joined:
    Jun 13, 2011
    Posts:
    88
  3. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    Sure what you have done isn't what your looking for, but that terrain is amazingly cool :p
     
  4. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    Also I was wondering if anyone making the MC clones would put their source codes up to look at? Or the Unity project or something. Would be much appreciated to learn from :) thanks!
     
  5. Manmax75

    Manmax75

    Joined:
    Jun 13, 2011
    Posts:
    88
    Alex, what if you clamp the noise values for air generated underground(i.e caves) Thus making them smaller in height/width.
     
  6. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    324
    Nice job alexzzz, it looks really good so far :) I'm still playing around with the noise code, having a hard time to create good looking mountains (that doesn't look like a bunch of meta balls), but it's getting better.

    Like mentioned on the blokworld forum, my biggest problem at the moment is calculating light, it is was too slow.

    I do it like many others probably do it, apply sunlight blocks to air blocks, starting at the top till you hit a solid block.
    After that's done you spread the light, and this is exactly the problem, it takes up to 3 seconds for one chunk to spread light.

    My (current) code for spreading it is this (i've modified many times so i might have added unnecessary parts):
    Code (csharp):
    1.  
    2. // Calculate light for block. x = chunkPos.x + blockPos.x, ...
    3.     void SetLightBlock(int x, int y, int z, Light light)
    4.     {
    5.       // Check if the light is bright enough to continue
    6.       if(light.strength * 0.8f > 2)
    7.       {
    8.          // Check if this block is AIR or not
    9.          if (GetDensity(x, y, z) == 0)
    10.          {
    11.               int absX = Math.Abs(x);
    12.               int absZ = Math.Abs(z);
    13.      
    14.               int modX = x < 0 ? (chunkSize.x - absX % chunkSize.x) % chunkSize.x : x % chunkSize.x;
    15.               int modZ = z < 0 ? (chunkSize.z - absZ % chunkSize.z) % chunkSize.z : z % chunkSize.z;
    16.      
    17.               int ciX = x - modX;
    18.               int ciZ = z - modZ;
    19.      
    20.             // Calculate next light value with a lower strength
    21.               Light nextLight = new Light(light.color, (byte)(light.strength * 0.8f));
    22.            
    23.             // Apply light to our light dictionary
    24.             m_tcache.lightData[new IntCoords(ciX, 0, ciZ)][modX, y, modZ] = nextLight;
    25.    
    26.             // Spread lower light to neighbours
    27.                       SetLightBlock(x + 1, y, z, nextLight);
    28.                       SetLightBlock(x - 1, y, z, nextLight);
    29.    
    30.                       SetLightBlock(x, y, z + 1, nextLight);
    31.                       SetLightBlock(x, y, z - 1, nextLight);
    32.    
    33.                 // Only spread horizontal for now
    34.                     //SetLightBlock(x, y + 1, z, nextLight);
    35.                     //SetLightBlock(x, y - 1, z, nextLight);
    36.          }
    37.       }
    38.     }
    39.  
    Maybe you guys have some ideas why its so slow? I assume it's the way i calculate my next chunk/block, but it's hard to test it without rewriting the whole system, which i'm actually doing at the moment to try it with a one dimensional block array.

    Thanks!
     
  7. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I have an idea how to make caves.

    1. As long as caves should spread preferably in horizontal direction, let's start with 2d noise. "Sinus-noise" with amplitude high enough produces long and thin curves:
    $caves0.JPG

    Here are our future caves with height = 1
    $caves1.JPG

    2. Let's use another noise function to calculate the heights of our caves:

    $caves01.JPG

    $caves2.JPG

    3. Now we have 3d-caves but they lie on the same plane. Let's use one more noise function to make the caves go up and down:

    $caves3.JPG

    The result is still not perfect, but it is far better than it was before:

     
  8. benac1

    benac1

    Joined:
    Aug 10, 2011
    Posts:
    9
    This is fantastic. Anyway I can help?
     
  9. botumys

    botumys

    Joined:
    Apr 16, 2009
    Posts:
    707
    what appends if you add little noise displacement to "isolated" vertices of stone blocks? Even with same cubic collider system, it'll add more diversity in caves !
     
  10. SpiderPork

    SpiderPork

    Joined:
    Jan 29, 2011
    Posts:
    27
    I like your lighting, alexzzz! Mind sharing a piece of code because I honestly don't completely understand the process Slaihne described?
     
  11. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I don't quite understand what you are talking about. :(

    I'm not sure I can explain it better than Slaihne, because he has an advantage of good English, but I'll try.

    Each cube has 6 faces that lie in different planes. Let's process the face E. It has four vertices: f, g, j, and k. If we want smooth lighting, we have to calculate the brightness of each vertex as an average of the brightness of all four faces that the vertex belongs to. We should take those faces that lie in the same plane where the face E does.

    $pic.jpg

    When I say "brightness of face" I mean the brightness of the block adjacent to this face from the side where the face's normal looks to. For example, if face E is the upper face of a block (x,y,z), then its brightness is the brightness of the block (x,y+1,z).

    Code (csharp):
    1.     // North
    2.     Block neighbour;
    3.     if (z + 1 < Settings.CHUNK_SIZE)
    4.     {
    5.         neighbour = blocks[x, wy, z + 1];
    6.     }
    7.     else
    8.     {
    9.         var neighbourN = parentMapChunk.NeighbourN;
    10.         if (neighbourN == null)
    11.         {
    12.             goto exit1;
    13.         }
    14.         neighbour = neighbourN.blocks[x, wy, 0];
    15.     }
    16.  
    17.     if (IsFaceVisible(block, neighbour))
    18.     {
    19.         var uw = Map.GetLightAll(wx - 1, wy + 1, wz + 1);
    20.         var u = Map.GetLightAll(wx, wy + 1, wz + 1);
    21.         var ue = Map.GetLightAll(wx + 1, wy + 1, wz + 1);
    22.         var w = Map.GetLightAll(wx - 1, wy, wz + 1);
    23.         var dw = Map.GetLightAll(wx - 1, wy - 1, wz + 1);
    24.         var d = Map.GetLightAll(wx, wy - 1, wz + 1);
    25.         var de = Map.GetLightAll(wx + 1, wy - 1, wz + 1);
    26.         var e = Map.GetLightAll(wx + 1, wy, wz + 1);
    27.         var c = Map.GetLightAll(wx, wy, wz + 1);
    28.  
    29.         var c1 = Light.Average(dw, d, w, c);
    30.         var c2 = Light.Average(de, d, e, c);
    31.         var c3 = Light.Average(ue, u, e, c);
    32.         var c4 = Light.Average(uw, u, w, c);
    33.  
    34.         faces.Add(MeshGenerator.GetFace(FaceDirection.North, 1, 1, c1, c2, c3, c4));
    35.     }
    36. exit1:
    37.  
    38.     //////////////////////////////////////////////////////////////////////////////////////////////////
    39.     // South
    40.     if (z > 0)
    41.     {
    42.         neighbour = blocks[x, wy, z - 1];
    43.     }
    44.     else
    45.     {
    46.         var neighbourS = parentMapChunk.NeighbourS;
    47.         if (neighbourS == null)
    48.         {
    49.             goto exit2;
    50.         }
    51.         neighbour = neighbourS.blocks[x, wy, Settings.CHUNK_SIZE - 1];
    52.     }
    53.  
    54.     if (IsFaceVisible(block, neighbour))
    55.     {
    56.         var uw = Map.GetLightAll(wx - 1, wy + 1, wz - 1);
    57.         var u = Map.GetLightAll(wx, wy + 1, wz - 1);
    58.         var ue = Map.GetLightAll(wx + 1, wy + 1, wz - 1);
    59.         var w = Map.GetLightAll(wx - 1, wy, wz - 1);
    60.         var dw = Map.GetLightAll(wx - 1, wy - 1, wz - 1);
    61.         var d = Map.GetLightAll(wx, wy - 1, wz - 1);
    62.         var de = Map.GetLightAll(wx + 1, wy - 1, wz - 1);
    63.         var e = Map.GetLightAll(wx + 1, wy, wz - 1);
    64.         var c = Map.GetLightAll(wx, wy, wz - 1);
    65.  
    66.         var c1 = Light.Average(dw, d, w, c);
    67.         var c2 = Light.Average(de, d, e, c);
    68.         var c3 = Light.Average(ue, u, e, c);
    69.         var c4 = Light.Average(uw, u, w, c);
    70.  
    71.         faces.Add(MeshGenerator.GetFace(FaceDirection.South, 1, 1, c1, c2, c3, c4));
    72.     }
    73.  
    74. exit2:
    75.  
    u, d, n, e, c, ... are the short-cuts for up, down, north, east, centre, etc.
     
    Last edited: Aug 16, 2011
  12. SpiderPork

    SpiderPork

    Joined:
    Jan 29, 2011
    Posts:
    27
    Edit: Sorry, misread your post.
    So, what does the GetLightAll function do in your code and how do you get the average value (Light.Average)?
     
    Last edited: Aug 16, 2011
  13. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Map.GetLightAll just returns the light value at given position in the world.

    Code (csharp):
    1. public static Light GetLightAll(int wx, int wy, int wz)
    2. {
    3.     // Calculate local in-chunk position
    4.     int x = wx  Settings.CHUNK_MASK;
    5.     int z = wz  Settings.CHUNK_MASK;
    6.  
    7.     // Calculate chunk coordinates
    8.     int cx = wx >> Settings.CHUNK_SHIFT;
    9.     int cz = wz >> Settings.CHUNK_SHIFT;
    10.  
    11.     MapChunk mapChunk = QuadTree[cx, cz];
    12.     if (mapChunk == null)
    13.     {
    14.         return Light.Zero;
    15.     }
    16.  
    17.     byte red = mapChunk.lightsRed[x, wy, z];
    18.     byte green = mapChunk.lightsGreen[x, wy, z];
    19.     byte blue = mapChunk.lightsBlue[x, wy, z];
    20.     byte sun = mapChunk.lightsSun[x, wy, z];
    21.  
    22.     return new Light(red, green, blue, sun);
    23. }
    Code (csharp):
    1. public static Light.Average(Light a, Light b, Light c, Light d)
    2. {
    3.     var red = (a.Red + b.Red + c.Red + d.Red) / 4;
    4.     var green = (a.Green + b.Green + c.Green + d.Green) / 4;
    5.     var blue = (a.Blue + b.Blue + c.Blue + d.Blue) / 4;
    6.     var sun = (a.Sun + b.Sun + c.Sun + d.Sun) / 4;
    7.  
    8.     return new Light(red, green, blue, sun);
    9. }
    10.  
     
  14. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    There are many unnecessary calculations in your code, Slaihne pointed to it already. But I'd still recommend to use real profiling tools not to guess, but to know what exactly is wrong with the code.

    There are many performance profilers for dotNet. They'll show you how many times each function or line of code is executed and how much time it takes. Here is an example of what ANTS Performance Profiler shows:
    $profiling.png $profiling2.png

    The biggest problem however is to separate the performance-critical code into a separate dotNet library in such a way that the library do not reference UnityEngine classes. If it does, you will not be able to compile it with dotNet-compiler and profile with dotNet-profilers. But if you manage to do so, the possibility to analyze the code with dotNet tools will be very handy.

    PS
    Just one more thing about performance: I spent two evenings earlier writing a QuadTree implementation. I thought it would be a nice place to store the chunks because it's fast and doesn't consume much memory. Recently I tested it against a simple Dictionary<IntVector2, MapChunk> and the winner is the dictionary. It more than ten times faster than quadtree while adding items, and several times faster while getting items.
     
    Last edited: Aug 16, 2011
  15. SpiderPork

    SpiderPork

    Joined:
    Jan 29, 2011
    Posts:
    27
    Still about the shading (sorry :s): Which shader do you use to blend between colours so perfectly and how (sorry to bother you that much)?
     
  16. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I just assign vertex colors and the shader that supports vertex colors does the rest.
     
  17. SpiderPork

    SpiderPork

    Joined:
    Jan 29, 2011
    Posts:
    27
    Any code examples (sorry, I'm an example-needed kinda guy :p)?
     
  18. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    No code:

    $vertex.PNG $pixel.PNG
    (Strumpy Shader Editor)

    A use alpha-part of color for sunlight intensity, and rgb-part for light, generated by independent light sources.
     
    Last edited: Aug 17, 2011
  19. Kethis

    Kethis

    Joined:
    Sep 10, 2009
    Posts:
    28
    Has anyone given thought on how to expand on the concept so that you could also dig down / build up infinitely?

    Lighting is the only major thing I can think of that I don't know how to (even theoretically) handle gracefully in such a scenario.

    The cop-out solution to that is to make the game world ALL underground, with no surface. While I could definitely see that being the basis for a very interesting game (anyone ever read the Myst series of books?), its not what I am going for stylistically.

    alexzzzz, is there a copy of your project available?

    EDIT: What if there was a maximum height, but no deepest depth. Lighting makes the assumption that no blocks below a certain depth are ever directly sunlit. Chunks are still 16x128x16 (or something like it).

    Would that approach not allow you to create an infinitely deep world with only the smallest trade off?
     
    Last edited: Aug 17, 2011
  20. Manmax75

    Manmax75

    Joined:
    Jun 13, 2011
    Posts:
    88
    Ok, What you have to take into consideration is memory. What chunks will be loaded on the y axis. For this to be feasiable, after reaching a certain point on the y axis, you would have to serialize the chunks to disk and remove them from memory. Chunks handeled in 16x16x16 is a lot better for his then the minecraft 16x16x128. Ok, so imagine diggin down say, 16 chunks. So thats (16x16x16) x 16. If one block had one byte of memory(which it wouldn't it would have more) That would be 65536 bytes of data for that one section that you dug down. Now say you have 4 bytes dedicated to each R,G,B channel (each channel being a 32-bit integer) and perhaps even another for Alpha, thats 16 more bytes PER BLOCK. And you might want to add say a 16-bit short for, idk, damage or special properties. Or whatever. Thats 2 extra bytes. So Say each block has 1 byte for block type. 16 bytes for colour and say 2 bytes for whatever. Thats 19 bytes per block. So that would be ( ( 16 x 16 x 16) x 16) x 19 = 1,245,184 bytes of data. Thats 1216kb or 1.216 mb. Now this isn't a big problem if you seperate chunks into 16x16x16 but making bigger y axis sized chunks, would be bad. You also have to consider rendering distance, and how you would do it. Its not nessicarly a bad problem here for us, but for minecraft to do this. It would be a pain for notch.
     
  21. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    No need really, one byte per channel is ok, even exessive. 4 bits should be enough.
     
    Last edited: Aug 18, 2011
  22. botumys

    botumys

    Joined:
    Apr 16, 2009
    Posts:
    707
    A little drawing is better than my stupid explanation :)



    I mean add a subtle displacement to these vertices. If the player place a block besides a "non-cubic" bloc, displacement disappears.
     
  23. Kethis

    Kethis

    Joined:
    Sep 10, 2009
    Posts:
    28
    @Manmax
    16x16x16 chunks are of 2^12 size and 16x128x16 are 2^15. While cube chunks are appealing from an elegance standpoint, if nothing else, there is a constant time consideration when loading/unloading a chunk. Rapid movement exacerbates this. The most common type of rapid movement is downward, therefor 16x128x16 chunks allow you to fall greater distances without lag. (not sure if this is an issue in practice, though)

    Also to consider is the appearance of tall tower-like structures at a distance. With cube chunks you would see the base far before seeing the top. With 16x128x16 chunks you would generally see the entire structure come into existence at once. An alternative to this is to load chunks in a cylinder around your character, instead of a sphere.

    Im getting the feeling Im missing something, but can't you store each block type in one byte (making space on disk per chunk be blocksInChunk * 1 byte, or 32kb for 16x128x16) and then for each face look up which material is appropriate to apply there? Storing 256 materials is ultimately trivial, how bad can it be to tell each face which to use?

    @botumys
    That could work in theory, but I think it would be more trouble than its worth. Earlier, alexzzz showed that he was optimizing the mesh and removing redundant triangles. Adding displacement to exterior vertexes partially counteracts those efforts. While cave interiors do get repetitive, Im not sure that displacement like that is the right way.

    If anything, I would like to see this:



    As it is still only using 2 triangles per face. However, that uses 4 bits to store only the top face. In our game we would like to be able to do something similar to the other faces as well (to solve the problem of boring cave structures). At that point you have to wonder, is the effect any greater than just making the voxels smaller (relative to the player)?

    (also, your Youtube video is one of the first things I saw when I first learning about Unity, and one of the major factors in me deciding to pursue learning Unity)
     
  24. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Just an experiment. I tried to add a little noise to each vertex position. Looks funny:

    $Captura.JPG
     
    Last edited: Aug 18, 2011
  25. Manmax75

    Manmax75

    Joined:
    Jun 13, 2011
    Posts:
    88
    Ok, The problem I was trying to state is. Lets say you have a world with a 1024 block height(that's 8 minecraft 128 block chunks down, or 64 16 block chunks down. Now your going to have a 'rendering distance' for y axis chunks as well. When you set your fog to far on minecraft, its a fairly big area of land that's has chunks loaded into memory, etc. Now I am not saying you have to load and fill all of the 8 chunks with noise and render them. You may only want to do 4 at a time, then wait till the player moves further down. But now you run into the problem that, for every new chunk you make by walking, you create a column of 4 chunks. Or, maybe even all the 8 chunks, depending on how far you want it to load. So what I am trying to say is that you will be using 4x as much memory, or 8x as much, etc.
     
  26. Kethis

    Kethis

    Joined:
    Sep 10, 2009
    Posts:
    28
    Because only the mesh differs, not the actual voxels, the noise can be discarded after it is applied to the vertex. The same number of triangles are used and only processor time is lost.

    @alexzzz:

    That looks... nauseating. Since Im still trying to figure out how to (find time to) programatically work with meshes, could you show us what it looks like if the noise is only applied to exterior vertexes?
     
  27. Manmax75

    Manmax75

    Joined:
    Jun 13, 2011
    Posts:
    88
    You still have memory being used for block type, light, color, textures, damage, etc. As well a processing light and other things.
     
  28. CharlieSamways

    CharlieSamways

    Joined:
    Feb 1, 2011
    Posts:
    3,424
    Just looked at this thread and I am far to late to try jump in and find out about it:/ Looks mental, anyone care to brief me on the situation maybe?
     
  29. Manmax75

    Manmax75

    Joined:
    Jun 13, 2011
    Posts:
    88
    Have you played minecraft?
     
  30. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Not yet, it's tricky a bit.
     
  31. CharlieSamways

    CharlieSamways

    Joined:
    Feb 1, 2011
    Posts:
    3,424
    Yeah I play it all the time
     
  32. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I kinda like the added noise to the vertices, looks sort of more ogranic, albeit a bit weird like being in a different dimension or something.
     
  33. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    $s1.JPG
    $s2.JPG
    $s3.JPG
     
  34. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    It looks better if I move outer vertices slightly to/inside the nearest blocks.

    $t1.JPG
    $t2.JPG

     
    Last edited: Aug 22, 2011
  35. botumys

    botumys

    Joined:
    Apr 16, 2009
    Posts:
    707
    I like what I see ! For me, much better than a simples cubes. Thanks alexzzzz, it's impressive !
     
  36. botumys

    botumys

    Joined:
    Apr 16, 2009
    Posts:
    707
    About gameplay I have an idea: let's scale the player by 3. In this case:

    With a pickax : by digging one stone cube, he receives materials equivalent to a 3*3*3 volume. If this volume is full of stone, he receives a "big" stone (composed of 3*3*3 little stone cubes). Is the volume is not complete, he receives the amount of "little" stone cubes present in the volume.

    In its inventory : 2 kinds of cubes : Bigs (3*3*3) and littles (1). Now, player can places one big cube or littles cube to create stairs, arcs, more rounded pillars ext...

    With stone chisel : he can extracts stones one by one or sculpt more precisely parts or buildings or statues like a sculptor.

    About collision:

    The player climbs automatically on little cubes but must jump 2 or more.
     
  37. Kethis

    Kethis

    Joined:
    Sep 10, 2009
    Posts:
    28
    Manmax, Im not really seeing the concern. We know that even large voxels take a huge amount of memory, but we also know that it is entirely feasible and nothing that is being discussed increases the amount of memory from manageable to unmanageable.

    However, botumys's idea of scaling the world might do that - as that is 27 times more memory needed to represent the same volume (unless you get clever and only show the higher resolution up close... but that would have practical problems of its own).
     
  38. benac1

    benac1

    Joined:
    Aug 10, 2011
    Posts:
    9
    What's new with all of these projects?
     
  39. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Is there a community or shared voxel engine i could use for Magix Elementus, ideally with good performance, texutres, lighting?
     
  40. Clave

    Clave

    Joined:
    Apr 6, 2010
    Posts:
    24
    Hello Alexxzz, have you solve the artifacts on the transparency for glass blocks. Im having the same one :(
     
  41. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I guess we have to use alpha test for glass instead of real transparency, like Minecraft and other engines do. I don't know any other simple way to deal with this problem.

    Currently I'm trying to simulate water flow as shown in this and this articles, however haven't succeeded yet.
     
  42. Windamere

    Windamere

    Joined:
    Aug 21, 2011
    Posts:
    15
    I would like to see something like this from these projects. Incorporate both the voxel and heightmap together. I'm not a programmer or would try to figure this out myself. (and make more money than Notch ) I've been following this project and love the advances people are making.

    Here is the example I've come up with and it sort of incorporates the kind of map used in Wurm Online (written in Java)



    The map would still be created using the cubes just not rendered to player as a cube unless Digging.

    Just remember if you do make this type of map and make more money than Notch be sure to remember where you got the idea from :p
     
  43. Windamere

    Windamere

    Joined:
    Aug 21, 2011
    Posts:
    15
    I wrote to Notch(see if he responds with his new found fame AND fortune :p) in hopes that he has some idea on how to create this type of terrain since he worked on the Wurm Online project with Rolf. I really would like this type of terrain to build a possible MMO on. Minecraft terrain was ok for killing time on but not what I want to work with.
     
  44. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Looking for examples of glass implemented using alpha-test technique, I found an extremely interesting blog of the guy that writes an engine just like ours. He uses c++ and directx/opengl directly but anyway he gives many interesting ideas (about glass too).

    $glass.JPG
    Not so nice glass, but I'm experimenting.

    PS
    $glass2.JPG
     
    Last edited: Sep 10, 2011
  45. Clave

    Clave

    Joined:
    Apr 6, 2010
    Posts:
    24
    I've check the blog, and i think it was in Part 4: Transparency ? Its too complicated for me right now :p

    I did the advice in this thread.
    A separate mesh for the transparency, so every chunk that has transparency has a child gameobject with a different material for a transparent shader, and I draw the Side 2 times, for the front and back. Its not a big deal at the moment, i dont know in the future :(

     
  46. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Try to render this shape:

    $glass3_small.jpg
    $glass4_small.jpg

    or this:
    $glass5_small.jpg
     
  47. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Here is screen-door transparency. Doesn't look like glass actually, but I still like it.

    $glass6.JPG
    $glass7.JPG
    $glass8.JPG

    I attached the shader, its Strumpy Shader Editor source and a sample texture.
     

    Attached Files:

  48. Clave

    Clave

    Joined:
    Apr 6, 2010
    Posts:
    24
    Here's the shape, there's some small problems



    And your shader and texture, works perfect! :)

     
  49. Skaruts

    Skaruts

    Joined:
    Jan 21, 2010
    Posts:
    2
    I can't call myself a programmer, since the most I've ever done was a failed prototype for an arkanoid clone and a prototype for a text adventure game with a nice GUI in Actionscript 2.0, and a few other easier programs in C, but my desire to learn game design and programming is still high in my dreams list. And I must admit that Voxel engines and Cube engines are two of the most interesting things I've ever found, but they are way too complicated for my knowledge.

    Still, I've been lurking around this thread today, and I must say I found very interesting stuff. At some point I skipped to the last page and Alexzzz's stuff reminded me of Dungeon Keeper and how the game had distortion applied to its walls and such, and I was going to post about it, but then I started going backwards on the pages and saw his video and realized he was actually doing something similar. Moving vertices resembles some kind of distortion on the blocks and looks very nice and helps giving the landscape a more natural feeling of irregularity. Nice work you got there. And from what I've seen all other people here seem to be doing great work as well. I wish I was that skilled...

    But I still got two other things in my mind that I'd like to be elucidated about.

    First, during my hours of minecraft I realized that sometimes the blocks are too big for certain constructions. Well, dimensions suffer a bit, since wall widths of 1 meter is a bit exagerated, but that's not exactly my problem. The problem is when trying to give a little bit more detail like rims and other wall/floor/ceiling details, I found myself wishing I could have cubes that were 1/8th of the original cubes, or in other words, 50cm of cubic volume only.

    This lead me to wander, what if minecraft was made of 50cm cubes instead, and had a height limit of 256? I believe the doubled height limit might bring quite a few performance issues, so, I thought, would it be at least possible to have all the cubes divided into smaller cubes? Which, I realized, resolves to the exact same as my first question, so I thought I was entering a endless cyclic train of thought. But since Minecraft has Slabs and Stairs and a few other shorter blocks, I still wander how feasible this is.

    Second, how about triangles? There's a mod for Minecraft (which name I don't recall) that adds slopes, which was one of the things that my subconscious quickly felt the need for as soon as I started playing minecraft, since it gets quite annoying to be constantly jumping around. But I don't know if it actually relies on triangles, and Mojang seem to avoid doing it. I don't know their reasons, but I'd assume at first that they want to keep it blocky, which is quite the trademark in Minecraft. But when I look at other minecraft clones I realize no one else is doing it either. So I wander, are their reasons the retaining of blockyness too, or this would be a harder and performance-killer feature to implement?
     
    Last edited: Sep 11, 2011
  50. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    1. Smaller cubes. Half of the original size.

    PROS
    ― Better look.
    ― No need to jump so often.

    CONS
    ― Requires 8 times more memory.

    ― 4-8 times more meshes/chunks on screen. Right now my average not so complex scene (224x224x128 blocks) consists of ~400 objects. If the cubes were smaller, it would be ~2000..3000 objects, I guess. Several thousands of objects, the most of which don't batch together, because they are too big. I can't make the chunks themselves larger, for example 32x32x32 instead of 16x16x16, because of two reasons:
    a) I will possibly meet vertex count limit per mesh (or triangle, don't remember) that Unity has. I tried it earlier and actually did meet the limit several times.
    b) The bigger the chunk, the more time it takes to rebuild it, and there can be lag when you add or remove a block. And if you add or remove a block that is in a chunk's corner, there are up to 8 meshes that have to be rebuilt, and it causes a big capital LAG.

    ― Light calculation also takes much more time.

    2. Slopes.

    PROS
    ― Better look.
    ― No need to jump so often.

    CONS
    ― Harder to calculate light propagation. Slops bring us a special kind of blocks that can pass light in one directions and block it in other direction.

    ― Harder to build meshes. Right now I have solid blocks of different types, water blocks, empty blocks, and that's it. But the class that just generates meshes (one visible and one for physics) is already ~1200 lines long. If I had slopes, I couldn't really say the block is solid, or contains just water, or is absolutely empty. Besides the orientation of slopes really matters, so the calculations would become even more complex. I decided to not even think about slopes at least until I fully implement water, because otherwise I'm afraid I will have to dump all my slopes generating code out and rewrite it from scratch.
     
    Last edited: Sep 13, 2011
Thread Status:
Not open for further replies.