Devblog 6th June 2017

    Discussion in 'Game News' started by schema, Jun 6, 2017.

    1. schema

      schema Cat God

      Joined:
      Feb 17, 2012
      Messages:
      1,470
      Hello citizens, ~


      The dev blog for this week features something more on the technical side. It covers a nice feature that will be very important in going forward.

      Optimized Meshes

      With the preview of last week, which is being able to draw any subset of blocks on any structure, we want to share another reason why we implemented this now. Not only is it already extremely useful for making existing GUI elements better and as said, adding new systems like active scanning, it also will be our basis for a new Level-of-Detail system. This system will increase drawing performance by drastically reducing the amounts of polygons at a distance.

      For that, the meshes we had last week needed to be improved and optimized. Since these are one colored representations of a set of blocks, polygon reduction is extremely viable.

      First of all, however, it needs to be explained why this method is not viable for all the mesh drawing, especially close. Reducing polygons means giving up information that is stored in those vertices. In our case that is texture information, the baked lighting, material, and a lot of other graphical meta information. Some of that can be compensated with techniques like deferred lighting, which would work yet does not scale well most of the time, and will force a lot of other optimizations to be removed. Also, the more detailed the mesh is with additional shapes, the less advantage the polygon reduction will provide.​

      [​IMG]

      That’s why combining both techniques will give us the best result. At a distance we can draw a minimal mesh that will speed up things dramatically. We can even make that multicolored with mixing multiple meshes on a fixed map of colors. Best of all, for close up, this still gives us the option of using deferred lighting eventually, but mixing it with existing lighting to have a smooth transition at a distance for maximal performance combined with the cool graphical experience of dynamic lighting.


      Here is how it works:
      [​IMG]

      As an example, we just take one side of the mesh. In production, this algorithm applies to all sides and all ‘depths’ (layers). Individually, however, we are looking at a 2D mesh.

      This is the raw drawing, which each block representing a full square. As you can see, the amounts of vertices and polygons are pretty high, especially if only one texture would be used.


      The algorithm itself at this stage records all vertices and its connections to other vertices, as well as diagonal vertices individually. Diagonals are handy to know that there was a filled out block at that position, and not just a one block gap.

      [​IMG]

      The first step for the algorithm is to remove inner vertices. These can be easily identified by checking the amounts of diagonal vertices a vertex has. If the number is exactly 4. We can remove it. At the same time, we can remove unnecessary connections. This is a bit more complicated to explain. Essentially for each non-inner vertex, we check for each existing direction the two orthogonal neighbors in the same direction. If both exist, the connection is unnecessary.

      [​IMG]

      A similar approach is used to remove the vertices that are not corners.

      Now the mesh is as simple as it can be. However, to draw it, we need to define triangles. There are several methods to triangulate a mesh, and it is highly complex, especially doing it with concave polygons that can have multiple holes in it.

      [​IMG]

      For our case, we can make the process a lot faster by using the fact that we are on a grid. A fact that is often overlooked in a lot of projects, but since starmade is primarily a voxel game, can be used as the source of countless optimizations.


      Explaining the exact process of retriangulation would take way too long for this dev blog, but you can probably understand the overall process of inserting horizontal lines at key points to subdivide the mesh into rectangles.

      [​IMG]

      From there, it is rather straight forward to get actually triangles that can be drawn.


      Now we do this for all sides, and their layers, and we get a mesh that is highly optimized, and doesn’t have any strangely shaped triangles (extreme angles). This has the great advantage of being able to use well formed texture coordinates if needed.

      [​IMG]

      As a final step (for the highlighting), the mesh is drawn into a frame buffer and rendered with an outline shader.​


      As announced, we have a dev build in the making which we will release when it’s ready for public testing.


      Thank you for playing StarMade,

      ~ The Schine Team
       
      • Like Like x 26
      • Agree Agree x 1
      • Informative Informative x 1
      • Creative Creative x 1
    2. alterintel

      alterintel moderator

      Joined:
      May 24, 2015
      Messages:
      779
      Yay, I'm first :^D

      Wow, who knew that adding a new Chamber and Reactor system could get into LOD stuff. It amazes me how far down the rabbit hole you have to go to get any new features implemented.

      Good Job, and thanks for all the dedication and hard work.
       
      #2 alterintel, Jun 6, 2017
      Last edited: Jun 6, 2017
      • Like Like x 3
      • Agree Agree x 2
    3. LunaIsBestPony

      Joined:
      Jun 25, 2013
      Messages:
      126
      Today is June 6.

      [​IMG]

      post was originally titled june 4
       
      #3 LunaIsBestPony, Jun 6, 2017
      Last edited: Jun 7, 2017
      • Agree Agree x 5
      • Informative Informative x 1
    4. GalactusX

      Joined:
      Jul 30, 2013
      Messages:
      327
      Nnnnnnnnnnnnnnnnice
      [​IMG]
       
      • Funny Funny x 1
    5. MrFURB

      MrFURB Madman of the Girders

      Joined:
      Jan 31, 2013
      Messages:
      1,116
      How much of an effect will the reduced draw time have on framerates in large battles where the only ship close enough to view the full mesh of is your own?
       
      • Agree Agree x 1
    6. Lancake

      Lancake Head of Testing

      Joined:
      Aug 20, 2013
      Messages:
      706
      I haven't read it yet but I'll upvote you because I can.
       
      • Like Like x 4
      • Funny Funny x 1
    7. nightrune

      nightrune Wizard/Developer/Project Manager

      Joined:
      May 11, 2015
      Messages:
      1,297
      These meshes are very very small compared to any ship currently in game, especially after the optimization process. The edge shader itself, from what I understand, is quite quick as well. I don't have numbers for you, but we don't see it impacting framerate much. Testing will show bottlenecks though.
       
      • Informative Informative x 2
    8. Blobfscrazy

      Joined:
      Jul 27, 2014
      Messages:
      70
      So this is just explaining what you did last devblog....
       
      • Funny Funny x 1
    9. Seijuro

      Joined:
      Mar 9, 2014
      Messages:
      9
      Are you disappointed? What did you think Devblogs were for if not explaining what the Devs are doing?
       
      • Agree Agree x 4
    10. therimmer96

      therimmer96 Cake Build Server Staff Elwyn Returnity Staff

      Joined:
      Jun 21, 2013
      Messages:
      3,500
      I think he thinks you plan to use these meshes for ships, which is what I took away from it as well :/
       
      • Agree Agree x 1
    11. nightrune

      nightrune Wizard/Developer/Project Manager

      Joined:
      May 11, 2015
      Messages:
      1,297
      Keep in mind that LoD simplified meshes would be used for objects much farther away then full block rendering. That's the idea of level of detail systems in any game. You can't see the details up close so it doesn't matter as much how it looks.

      What I said is true for highlighting systems on a ship and still for using lod on ships as well. What effect will it have? In testing, I would be aiming to have similar framerates but see more entities. The actual balance will be determined at a much later date.
       
      • Like Like x 1
      • Informative Informative x 1
    12. kiddan

      Joined:
      May 12, 2014
      Messages:
      952
      Remember; If LOD doesn't look too good, just turn on Star Trek lens flare mode!
       
      • Funny Funny x 5
    13. GnomeKing

      Joined:
      Feb 21, 2015
      Messages:
      25
      Thanks Guys - really appreciate the explanations of game mechanics given with the blogs !
       
    14. Toshiro

      Joined:
      Aug 29, 2015
      Messages:
      4
      Will we soon have a small pre-build to familiarize ourselves with this new specification?
       
    15. StormWing0

      StormWing0 Leads the Storm

      Joined:
      Jun 26, 2015
      Messages:
      1,913
      Devbuild hasn't shown up for this yet either, been waiting to see what happens. :)
       
    16. Xskyth

      Joined:
      May 25, 2014
      Messages:
      66
      how far away will this LOD effect take place? and will the range be adjustable in the options/ config file?
       
    17. Sgtwisky

      Joined:
      Dec 3, 2013
      Messages:
      533
      I'm imagining that aside from drawing ships faster at a distance, and being able to highlight systems, this would also allow faster drawing of planets that are in the LOD range right?
       
      • Agree Agree x 4
    18. painnigouto

      Joined:
      Aug 11, 2015
      Messages:
      37
      How about single large entities like 2km+ ships.. if, say, i stand on one end of such an entity, will the opposite end also be affected by this system?
       
      • Agree Agree x 2
      • Like Like x 1
    19. Thadius Faran

      Thadius Faran #1 Top Forum Poster & Raiben Jackpot Winner

      Joined:
      Oct 13, 2013
      Messages:
      4,779
      Oh technical stuff.

      This is a new go.
       
    20. Ithirahad

      Ithirahad Arana'Aethi
      Community Mentor

      Joined:
      Nov 14, 2013
      Messages:
      3,819
      This is pretty awesome!

      I should've figured that convex-hull calculations would be useful for creating optimized LoD meshes.
       
      • Agree Agree x 1
    Loading...