1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 [Solved] How to handle voxel chunks update?

Discussion in 'Programming' started by GLTH, Feb 13, 2019 at 4:53 PM.

  1. GLTH

    GLTH Member

    Joined:
    Jul 7, 2016
    Posts:
    7
    Hello.
    I'm trying to make some simple voxel engine and I set every chunk to a vertex buffer, so I only pass the vertex to the draw event once for 16x16x256 blocks instead of over 65 thousand times. But then the problem comes when I want to update the chunk (destroying or replacing a block), because from what I can see, I cannot simply delete vertices or change their texture UVs and have to instead redo the whole buffer. I already knew it woudn't end well, but decided to give it a go for science :p. After redoing the chunk buffer the game freezes for about 4 - 5 seconds on my setup for a full chunk of blocks, so even if half of the blocks were air and didn't need to be passed to buffer, it would still freeze for 2 seconds, which is still a no-go.

    So, my question is - is there a secret way to remove some vertices from a buffer, or any way I could go about updating a chunk without waiting for eternity? From what I could tell, submitting too many vertex buffers to draw event is tanking FPS consistently, so splitting a chunk into, let's say, mini chunks for every z is also not ideal.

    Of course I searched for minecraft engines to study, but even when I specifically search for GMS / GMS2 voxel engine or tutorial, all it shows me is that damn Unity >.<
     
  2. Binsk

    Binsk Member

    Joined:
    Jun 22, 2016
    Posts:
    482
    Nope, that's what you have to do. Try optimizing your calculations. A chunk of air shouldn't take two seconds to "model".

    It will be a balancing act between chunk size and number of chunks (cpu VS gpu).

    I have tried this kind of thing several times with GM. I always ended up writing a dll to do the calculations and buffer writing so I could throw it on another thread. GM really is a terrible engine for this kind of thing because of its threading model.
     
  3. GLTH

    GLTH Member

    Joined:
    Jul 7, 2016
    Posts:
    7
    Well, that sucks. Gonna search some more, and experiment on my own.
    Part of the 5 seconds to calculate is that I didn't optimise it yet, like, at all, so I send every vertex, even when it's directly next to another block, to the buffer. But even then, if I had a 3d chess - like pattern, it would still take about 2 seconds, because there are no vertices to cull. I guess I'll just split the chunks so that they're 4x4x256 or something, so that it won't require too much change in code and see how that works out. Thank you for the reply, at least now I know that what I had in mind can't be done and need to solve it somehow else :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice