Search Unity

Grout Tile Engine (Hex,Square,whatever)

Discussion in 'Works In Progress - Archive' started by FervInt, Aug 4, 2014.

  1. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    NO LONGER AVAILABLE

    I am currently working on a tile system for terrains and other uses and was wanting to gauge the interest. So if you would be interested in something like this being on the asset store please let me know here or on my blog link below.

    Here is a couple screenshots and a few details.








    • A Hex implementation of the tile engine
    • Square implementation of the tile engine
    • Tile engine that can use any shape tile (provided you implement a few interfaces that describe your tiles, requires coding)
    • Adjustable tile sizes
    • Support for sparse data sets
    • Tiles with or without sides (2d or 3d tiles)
    • Terrain Chunking for performance and “zone” uses
    • Dynamic, on-demand terrain chunk loading (when your player gets close to the edge of a chunk for instance)
    • View frustum chunk disabling (this is not simply a render cull it fully disables the object)
    • Support for a HUGE area, I will need to do some work to see exactly how many chunks can be loaded
    • Pathfinding with support for individual tile traversal costs as well as blocked tiles
    • Configurable perlin noise data generator
    • Bitmap based terrain editor takes in a bitmap and converts it to tiles, simply use paint to draw your map and the editor will convert it to tile types (might change this to an in unity editor)
    • An Inversion of Control system for Unity that provides the engine with its flexibility but can and should be used elsewhere
    • A much more advanced messaging system for Unity using Weak Actions and Weak Object References to avoid memory leaks
    • Written entirely in c#
    More information at www.ferventinteractive.com/blog

    Web Player Here
    WSAD to move
    Mouse wheel to zoom
    if you run off the edge of the map...more map will be generated.

    Thanks,
    Justin
     
    Last edited: Dec 16, 2014
    balaam likes this.
  2. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    Looks nice
     
  3. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Thanks, though looks aren't in any way my strong suit :) I am having some art put together for it now that will show off a bit more of the capability. It should look a lot better soon. I am 100% focused on making the engine as extensible, fast and clean as possible.
     
  4. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    Well i thought more in the way that it has really nice potential
     
  5. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Ah yes, that makes much more sense! thank you. More of that will show once I get a couple more tile shape implementations up and a video or two.
     
  6. inko

    inko

    Joined:
    Nov 29, 2013
    Posts:
    143
    Did something similar to this myself ages ago and ran into a whole world of problems. Would be interesting to hear how you solved some of them ;)
    In what kind of coordinate system are you storing your hexagons? How does your 2d img to hex grid converter work? And how fast can you search for specific tiles?

    Hexagons are pretty awesome but can be quite tricky to code with so I'm gonna keep an eye on this :)

    Good luck and keep it up!
    also: whooo c#!
     
  7. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Thanks for the interest inko.

    I use a simple 2D coordinate system for ease of use. My tiles are stored in a sparsely populated data structure similar to a BSP tree so I only have to allocate what is required to store the tiles.

    If you have the x,y coords of the tile you are looking for it is very fast as it is a simple tree look-up using quadrant bounds to narrow down the location of the tile.

    Currently the image converter takes a bitmap (1 for each layer) in, splits it into chunks and processes the color values of each chunk into tile type data files. As the chunks are needed the engine will convert them from data to tiles and load them into the tree. Chunk loading is spread over n frames to avoid any frame-rate loss. I am debating making this into an inside unity editor instead of the bitmap but I'm not sure. I like the image because i can hand it off to an artist and they can make that image all nice and pretty and then use something like MapTiler to make it browse-able via the web.

    Yeah I wanted to make sure to get a complicated implementation in there first to make sure the engine could handle it and maintain a decent fps. I will of course be continuing to optimize it but right now we are looking pretty speedy. The square implementation will be a cakewalk compared to the hexes. The different implementations of the tile shapes are injected into the engine via IOC so all that is required to change tile types is to register a different tile implementation (about 3 lines of code provided you have your tile implementation written).

    and yes....wohoo c#... i love it
     
  8. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    I spent about 20 minutes tonight implementing the required interfaces for my tile engine to render square tiles. I have separated the main tile management objects from the tile rendering objects so it is quite easy to switch the engine out from one tile renderer to the next.

    Screenshot on the original post.
     
  9. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    When do you think this could be able to use in a game as i am working on this 3d city builder game but i really have no good engine for creating random terrains


    maybe we could develop together as i use it in my game i can report and give feedback on what could be better
     
  10. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    If you don't mind the WIP nature of it, I wouldn't mind having someone else try to use it. Give me a couple of days to clean it up some and ill get back with you. If you are not familiar with IOC Containers I would suggest you take a look at that pattern as I use it heavily.
     
  11. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    Ok i will do a little research

    Do you got some good places? that i can learn about IOC
     
  12. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    ioc
    That is a pretty good overview.
     
  13. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
  14. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    another image...
     
    Last edited: Aug 27, 2014
    mathias234 likes this.
  15. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    Not bad :)

    I am just wondering is it possible to use perlin noise to generate the worlds?
     
  16. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Yes, I can think of a few ways to get that done. It all depends on how large you want your world and if you want to do it every time your start up or on a new game or what. The easiest way to see what it will look like would be to use perlin noise to generate an image that is sent through my bitmap converter. So yes it is possible but not right out of the box yet.
     
  17. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    I was thinking that everytime when the player creates a new city he will get a randomly generated map it wont be too big but not too small either
     
  18. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Yeah that wouldn't be too hard
     
    mathias234 likes this.
  19. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
  20. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    I went ahead and implemented the perlin noise data provider for my tile engine. It will generate a random map each time it is run...or you can give it a specific offset and zoom level to work from.



    and naturally with a small tweak....you can render in another tile shape.

     
    Last edited: Aug 13, 2014
  21. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
  22. Kivak

    Kivak

    Joined:
    Jul 13, 2013
    Posts:
    140
    Looks great!!
     
  23. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Thanks guys

    ..should have a alpha version up before too long for you mathias.
     
    Last edited: Aug 13, 2014
  24. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
  25. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    Any Updates?
     
  26. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    I've got just about everything packaged up...I need to write a bit of documentation.

    If you choose to use the perlin noise data provider you can now send a configuration message to it and supply the scale and offset into the noise. It also allows you to provide a callback method for it to convert a noise value into a tile type.

    I'll explain all of this in the docs.

    I want you to have to code as little as possible to get it up and running so I am making sure that it is easily configurable.
    I'll provide examples of it all as well.
     
  27. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
  28. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    check your conversations mathias I have an alpha build up for you.
     
  29. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Thought I would post up a web player build so people could have a look.
    WSAD to move
    Mouse wheel to zoom
    if you run off the edge of the map...more map will be generated.

    Grout Web Player

    let me know what you think.
     
  30. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    I am just about finished with the pathfinding service for my tile engine.

    I have decided to make the pathfinding pretty simple in that it will do just what it says....Find a path from A to B and return the path to you. You can do whatever you wish to do with that path as I don't want to force any sort of movement mechanics onto your objects.

    Does this sound good to you folks or do you think people using the system would want something more.
     
    mathias234 likes this.
  31. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Started working on performance. Over 65 thousand tiles at 326fps. I've got a few more things to work on which should bring that number up some more.

     
  32. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    That is amazing
     
  33. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    thanks! :)
     
  34. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Couple more screens.

    The first one is showing 100 robots wandering around using the built in pathing provider...


    The next one is showing support for sparse data sets...it doesn't have to be all filled in...


    Thanks!
     
    Joror, mathias234 and calmcarrots like this.
  35. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Wow this looks REALLY cool. Great work!

     
  36. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Thanks, getting close to finishing it up :) If there are any features anyone thinks would be nice in a system like this please let me know.

    It comes with its own messaging system that is generic
    It also comes with an Inversion of control system that can be used

    Both of these things will allow for great flexibility in ones code.
     
  37. Morgen

    Morgen

    Joined:
    Jan 2, 2013
    Posts:
    11
    Will there be any kind of pathfinding system available? I mean tile-based, for a game like Civilization?
     
  38. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    yes. It comes with a basic pathing system.
    you can set tiles inaccessible as well as provide a traversal cost.
    The pathing system will try to find the easiest path taking into account the cost of each tile.
    I didn't want to force any movement code onto your objects so I simply provide the path as a list of tiles and you can then do with that whatever you need to do to get your objects to follow it.
     
  39. Morgen

    Morgen

    Joined:
    Jan 2, 2013
    Posts:
    11
    That's great. Can't wait to see if this system will fit into my game. :)

    Did you tested it on mobiles?
     
  40. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    I have not tested it on any mobile devices as of yet but I am not doing anything that would give me any reason to doubt that it will run just fine. I will put it on a phone to test it out soon. :)
     
  41. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Quick screens showing the tile height options

     
    Last edited: Sep 5, 2014
    mathias234 likes this.
  42. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Here is one configuration I put together tonight using the perlin noise values as a standard height map for the tiles.

     
    JohnParask likes this.
  43. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    Here is another example of the flexibility of the system. This is a work in progress but it is almost ready.

     
    moure likes this.
  44. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    The bitmap reader I have created allows me to do things like

    this.


    turns into this

     
    MJNuchia, JohnParask and mathias234 like this.
  45. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    I got world aligned pixel shaders to work last night...here is the initial result...ill add a detail texture in for the asset...

     
    mathias234, Sammual and Joror like this.
  46. MJNuchia

    MJNuchia

    Joined:
    Aug 18, 2014
    Posts:
    109
    Very nice sir. Impressed by your progress.
     
  47. Sammual

    Sammual

    Joined:
    Oct 28, 2008
    Posts:
    176
    That looks great.
     
  48. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    thanks :)
     
  49. FervInt

    FervInt

    Joined:
    Nov 29, 2013
    Posts:
    47
    just uploaded a new web player...

    It has some options to switch between the different tile layouts...

    web Player
     
    Last edited: Sep 29, 2014
    mathias234 likes this.
  50. inko

    inko

    Joined:
    Nov 29, 2013
    Posts:
    143
    Dammit, I totally forgot about this thread after getting such a detailed answer. I feel bad now :(

    Your progress looks pretty darn impressive, especially your cylinder projection is crazy cool!

    Storing a 2d height map in a data tree is an interesting approach. So it's really optimised for huge maps, eh?
    That, plus chunking your geometry mesh should allow for insanely big maps. Awesome!
    What really blew me out of the water though where the triangles in your webplayer preview though. Does that mean that it even support more complex patterns like pentagons or even irregular ngons or am I talking out of my ass here?

    Anyway, really really cool stuff going on here. Do you have any plans taking this awesome tec and putting it into a game or even just a game prototype?

    Best of luck and keep it up!

    Oh, also thanks for the link on IOC, I haven't heard that term either before. Interesting read.