GM:S 1.4 isometric depth sorting with multi tile objects

Discussion in 'Programming' started by YanBG, Jan 15, 2020.

  1. YanBG

    YanBG Member

    Joined:
    Jun 25, 2016
    Posts:
    607
    Last edited: Jan 15, 2020
  2. RujiK

    RujiK Member

    Joined:
    Jun 21, 2016
    Posts:
    180
    If you haven't seen it already, this thread is worth a read: Smart Isometric Drawing Order

    I was in the same boat as you last year. I read almost every topic about 2d isometric depth and this was what I ended up on:
    Code:
    var xx = x >> 4; //this is the same as "xx = floor(x/16)*16" but in binary. My tile sizes are 16x16x16
    var yy = y >> 4;
    var zz = z >> 4;
    depth = -(-xx*2+yy*3-zz)*16; 
    It worked probably 95% of the time but it had a lot of special cases that needed awful code patches to fix. Stuff like : if 1 pixel away from wall on right (Depth += 10) Still, it was the best solution I could find for a 2d projection.

    When I switched over to GMS2, my game went from 200 FPS > 1 FPS. GMS2 handles depth and tiles very differently so I just ditched the whole idea and made my game 3d using vertex buffers. 3D has it's own issues, but I definitely prefer it over 2d for isometric views. It took me a few months to implement it as I'm a 3d noob, but it was worth it in the end. The GPU somehow does all the magic for me.

    I briefly talked about the 2d>3d transition in this thread if you are interested: Devlog

    Sorry I don't have a silver bullet answer, but after a long time searching, I'm not convinced there is one. Every 2d isometric implementation I could find had it's own weirdness. Good luck
     
    YanBG and JeffJ like this.
  3. JeffJ

    JeffJ Member

    Joined:
    Jun 20, 2016
    Posts:
    354
    This is really a shame. For my next project I'm going for this sort of overhead view. It would be incredibly helpful if we could opt out of auto managed layers (or layers at all) for certain projects, making it run more akin to GMS1 and below - 3d really shouldn't be necessary when projects like yours ran just fine before GMS2. Sigh.
     
    RujiK likes this.
  4. YanBG

    YanBG Member

    Joined:
    Jun 25, 2016
    Posts:
    607
    @RujiK thank you, i was looking through that thread and some others but couldn't figure much, was the conclusion to go for 3d? z/vertex buffer? Seems a bit too advanced for me, shouldn't there be a simple script that checks the width and height of the the object? Isn't 3d heavier, i want this to be fast, i'm even using tiles not instances.

    The size of each cell is the green diamond square. Walls, bookcases and all other background objects i'll be adding will be bigger. You can see it's 45d isometric rotation and there are 4situations, in 2(topleft and topright) you need to be behind and in the other 2(bottomleft, bottomright) in front.

    [​IMG]
     
    Last edited: Jan 16, 2020
  5. Rob

    Rob Member

    Joined:
    Jul 12, 2016
    Posts:
    748
    I was hired to make a simulation game that involved isometric art that covered multiple tiles, could be rotated, and things could be picked up, moved, and have objects placed on top of other objects.

    My solution was whenever an object was placed/moved etc to run a script that would do the following:

    • Use a list to determine what order to draw things
    • Check each cell from the top left to the bottom right
    • If an object was bigger than 1 cell vertically, check for any objects to the left of it (that were on any of the same vertical cells)
    • These objects would also have to check to their left and add any objects
    • Once all the previous objects were added to the list, then the original object is added
    • Walls were not added to the list and were drawn either before or after the cell that they were connected to
    I don't know how useful this will be to you but I understand your isometric pain!
     
    YanBG likes this.
  6. YanBG

    YanBG Member

    Joined:
    Jun 25, 2016
    Posts:
    607
    @Rob thank you, yeah i'm thinking that something like a list with x,y,width,height of each object would be needed(they are just tiles and a grid entry now so it's quite fast). I have a csv with id, name and properties for each "furniture" item. I load it to the game, then populate a second terrain grid with the id of each prop/object/furniture that is placed in the world.
     
    RujiK and Rob like this.

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