Devblog 6th June 2017

    schema

    Cat God
    Joined
    Feb 17, 2012
    Messages
    1,552
    Reaction score
    2,604
    • Schine
    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.​


    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:


    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.



    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.



    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.



    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.



    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.



    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
     

    alterintel

    moderator
    Joined
    May 24, 2015
    Messages
    869
    Reaction score
    596
    • Likeable
    • Community Content - Bronze 2
    • Legacy Citizen 3
    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.
     
    Last edited:

    LunaIsBestPony

    token ruskie
    Joined
    Jun 25, 2013
    Messages
    129
    Reaction score
    34
    • Legacy Citizen 2
    • Legacy Citizen
    • Community Content - Bronze 1
    Today is June 6.



    post was originally titled june 4
     
    Last edited:

    MrFURB

    Madman of the Girders
    Joined
    Jan 31, 2013
    Messages
    1,116
    Reaction score
    413
    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?
     

    nightrune

    Wizard/Developer/Project Manager
    Joined
    May 11, 2015
    Messages
    1,324
    Reaction score
    577
    • Schine
    • Top Forum Contributor
    • Thinking Positive
    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?
    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.
     

    therimmer96

    The Cake Network Staff Senior button unpusher
    Joined
    Jun 21, 2013
    Messages
    3,603
    Reaction score
    1,053
    • Legacy Citizen 10
    • Top Forum Contributor
    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.
    I think he thinks you plan to use these meshes for ships, which is what I took away from it as well :/
     

    nightrune

    Wizard/Developer/Project Manager
    Joined
    May 11, 2015
    Messages
    1,324
    Reaction score
    577
    • Schine
    • Top Forum Contributor
    • Thinking Positive
    I think he thinks you plan to use these meshes for ships, which is what I took away from it as well :/
    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
    Reactions: MacThule

    kiddan

    Cobalt-Blooded Bullet Mirror
    Joined
    May 12, 2014
    Messages
    1,131
    Reaction score
    358
    • Top Forum Contributor
    • Legacy Citizen 4
    • Purchased!
    Remember; If LOD doesn't look too good, just turn on Star Trek lens flare mode!
     
    Joined
    Feb 21, 2015
    Messages
    228
    Reaction score
    145
    Thanks Guys - really appreciate the explanations of game mechanics given with the blogs !
     
    Joined
    Aug 29, 2015
    Messages
    27
    Reaction score
    7
    • Purchased!
    Will we soon have a small pre-build to familiarize ourselves with this new specification?
     

    StormWing0

    Leads the Storm
    Joined
    Jun 26, 2015
    Messages
    2,126
    Reaction score
    316
    • Community Content - Bronze 1
    Devbuild hasn't shown up for this yet either, been waiting to see what happens. :)
     
    Joined
    May 25, 2014
    Messages
    84
    Reaction score
    22
    • Purchased!
    • Legacy Citizen 3
    • Community Content - Bronze 1
    how far away will this LOD effect take place? and will the range be adjustable in the options/ config file?
     
    Joined
    Dec 3, 2013
    Messages
    552
    Reaction score
    182
    • Legacy Citizen 9
    • Purchased!
    • Community Content - Bronze 1
    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?
     

    PainNigouto

    Emperor/Toymaker
    Joined
    Aug 11, 2015
    Messages
    47
    Reaction score
    86
    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?
     
    • Like
    Reactions: Blodge

    Reilly Reese

    #1 Top Forum Poster & Raiben Jackpot Winner
    Joined
    Oct 13, 2013
    Messages
    5,140
    Reaction score
    1,365
    • Legacy Citizen 8
    • Thinking Positive
    • Purchased!
    Oh technical stuff.

    This is a new go.
     

    Ithirahad

    Arana'Aethi
    Joined
    Nov 14, 2013
    Messages
    4,150
    Reaction score
    1,330
    • Purchased!
    • Top Forum Contributor
    • Legacy Citizen 8
    This is pretty awesome!

    I should've figured that convex-hull calculations would be useful for creating optimized LoD meshes.