Results 1 to 10 of 13

Thread: Smoothening tile edges

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I'm making a circle shaped world. I'm not far enough to show the idea with game yet, but this should give you the idea:
    http://upload.wikimedia.org/wikipedi...Order7.svg.png
    Center of gravity is in the middle of the planet, and player feet are always towards it. Imagine walking on that "spiky" surface, there are these "holes" on all 6 sides of it. And i believe this is solved by adding triangles outside the hexagons to fill the gaps.

    And not just the planet surface, but some caves inside. If not natural caves, then digged ones. Idea similar to
    http://i146.photobucket.com/albums/r...fullscreen.jpg

    Hmm.. know what, i would get much easier by doing this with square tiles. I could add triangles between edges with it aswell. And it might even look much better, not to mention easier math around it.

    1 tile from 4 triangles and i could also leave 2 triangles hidden depending on corner, instead of adding new ones between tiles. This would also increase the rendering performance. I have to consider the options...
    http://i.stack.imgur.com/ssaaS.png
    Last edited by User137; 28-04-2013 at 02:49 AM.

  2. #2
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    well I suppose that could work but your still going to end up with some ugly spots as you can't make a perfect circle with any shape you chose. you could apply a granular aproach to it and acheve a much rounder cut off.
    measure the distance of each point from the center of the world to calulate the cutoff point. you could then apply some sort of linear interpolation to give it a more controlled fade.
    RoundWorld.jpg

  3. #3
    I made a simple planet and tunnel generator, so here is few screenshots.
    http://i41.tinypic.com/35knxp3.png
    http://i41.tinypic.com/2ez7cll.png
    Tile-radius of this planet is 240. Overall 600x600 tiles are reserved for space building room. Went down to 12 fps rendering all at once

  4. #4
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    If the framerate is proportional (linear) to the number of tiles you render then that suggests that you are not using any spatial partitioning schemes to cull rendering to the visible hexagons?

    If you are you may want make sure it's functioning correctly.

    Can I ask what version of GL you code for, your CPU and GPU?

    12fps for a a screen of 2D triangles at the perceived density from your screenshots is well below what I'd expect from even mobile phone class hardware.

    If you're not using spatial partitioning, a quad tree should be perfectly good enough.

    The basic principal is to represent the bounds of the world as a quad, then divide that into four smaller quads, and add to each of these a list of hexegons in that quad. then keep on splitting and adding in this fashion until you reach some pre-defined minimum size (Say the size of one hex etc).

    Then when you render a frame, you test your screen quad against the top 'node' in the tree and determine which quadrant it's in, then you can immediatly bypass 3/4 of the hexes from render. Then test against the 4 child nodes of that quad etc etc

    Because of the squared nature of dividing the space by 4 each time, you reach the smallest nodes (leaf nodes) in just a small handful of checks. (obviously you test if the screen is inside a node OR overlapping the node, you may be itterating into more than one child node at a time, but it will beat brute force quite early on in a graph)

    (just for those reading if you already know this)

    EDIT : Apologies! I just saw you screenshot, you're zoomed right out so obviously spatial partitioning won't help there

    you could however render the map at a certain resoution to a texture and then switch to rendering that texture at a certain level of zoom. if you required the display to still show realtime changes on the map, you could stagger the updating of this renderbuffer texture over a number of frames (so as not to impact framerate). So you'd have good framerates when zoomed out in terms of the interface and any other things you wish to render at the cost of a lower percieved framerate for the rendered map.
    Last edited by phibermon; 28-04-2013 at 03:24 PM.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  5. #5
    If you are designing your game to use hexagon tiles, then it might not be bad to check how Widelands (Settlers 2 clone) map is gnerated. While Widelands use triangles (vertex approach) for map representation you can always create hexagon tiles by combining 6 triangles.

    On link below you can see a bit more information about how it is done, including the way for calculating regions. I hoe it would come in handy to you:
    http://widelands.svn.sourceforge.net...ry/index.xhtml

  6. #6
    I could let you test this version (at least while i keep it online): https://docs.google.com/file/d/0B7FI...it?usp=sharing
    Actually i'd hope it to be tested just to verify there's no major bugs in nxPascal. The controls don't allow zooming, just drag-moving with mouse. F7 toggles for windowed fullscreen mode.

    Full earth screenshot was special case with no limiter. Smaller game view is rendering 41x41 area, which is propably much bigger than needed at the moment anyway. I should be fine without splitting optimizations. I get max 60+ fps with it, at 0-1% cpu use. I need to look closer to zooming levels when i get to playable stuff. Also 1 reason the FPS went slower on full planet view, was especially after i finalized the texture blending. It is calculating texture opacity for each vertex per frame, by adding and normalizing texture opacities of self+3 neighbouring tiles.

    And yes, i scrapped the hexagon idea and used squares and triangles with this. Because with triangles there are actually 8 different "sides" in use, which is smoother than hexagons 6. It calculates the corner cutting in planet generation phase at least, not realtime, and puts the angle in 1 shortint variable. Also there is no static vertex-array, but the triangles are queued same way as my renderer class does. There's hard cap of 1000 vertices and 1000 vertex indices for glDrawElements(). That is another thing new, so i don't have to do the heavy texture-opacity calculation so many times on CPU. So pretty much everything is reconstructed per frame.

    If someone was interested in joining the game project, you can send me a PM I'm working on it with 1 other person at the moment, with growing documentation and stuff in google docs. I don't want to reveal the game more in public yet, and i don't have any opinion yet on wether it will be free/opensource or anything else.

  7. #7
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    I'd love to work with people on projects but in terms of games there's only one game I have my heart set on and I code my engine with it in mind. It requires the rendering of at least one planet (and possibly a moon) from space, all the way down to walking on the surface. It involves time travel, a deep mystery, a planet wide search, a lovable AI companion and a shocking twist. I have my story and I know how it'll play just depends on how much of my ideas I can get into it on my own
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •