staticskizzles
Member
Hello guys,
I'll try to explain my scenario.
I've been working on a game with a room that's 4000 by 4000. I don't know if that room size is overkill or not but I guess I'm trying to see what limits I can push with my game.
I modified an asset that fills the room with grass vertex buffers (grass sprites), there was no performance issues at all, wonderful asset. However my game needs the grass to disappear when certain tiles change so I went through various ways of trying to make this work. My first idea which worked well was placing many instances around the room which all independently create grass vertex buffers (sprites) inside the tile's dimensions. This worked, I was able to remove that patch of grass sprites by simply using instance_destroy(); on that instance creating grass on that tile. Eventually allowing my character to remove grass on a certain tile using a shovel. Yes I could just use tiles, but I like the dynamic appearance of using windy grass vertex buffers. Anyway it worked. However, the moment I decided to fill my room with all of these objects to have grass everywhere, my fps dropped by half, it went all slow motion and quite frankly unplayable. So I decided to blame the use of too many objects and tried to modify the asset itself.
I added a loop to the creation code for this obj_vertexgrass that creates grass sprites everywhere, and within this loop, a grid the size of the room that stores the buffer id for the grass sprites / vertex buffers in each tile. This is so that I can make the draw event only draw grass sprites on certain tiles, throughouy the entire room. This method also came with a giant performance impact, perhaps worse than just using objects, but further tweaking the draw event to strictly only draw sprites from the grid that are inside the camera's view fixed everything! - or so I thought. I began joyfully running to the bottom right of the room to make sure my code drew grass on all tiles along the x and y axis, and noticed the game getting progressively slower and slower. Player speed slowing, animation slowing, time slowing. The game is getting slower the higher the x and y coordinates are and I honestly have no idea what to do now. I don't even need to walk far to notice the game slow down.
I thought for a moment that maybe running around the room adds more sprites to the draw event, slowing it down,. So I added more code that does buffer_delete() on all grass sprites previously drawn that are now outside the camera's view, so that they get deleted from the draw event if they somehow aren't already and still the same issue. Vertex buffers are much faster to draw than objects aren't they?
I'm genuinely clueless what to do next. Any advice or ideas would be much appreciated.
I'll try to explain my scenario.
I've been working on a game with a room that's 4000 by 4000. I don't know if that room size is overkill or not but I guess I'm trying to see what limits I can push with my game.
I modified an asset that fills the room with grass vertex buffers (grass sprites), there was no performance issues at all, wonderful asset. However my game needs the grass to disappear when certain tiles change so I went through various ways of trying to make this work. My first idea which worked well was placing many instances around the room which all independently create grass vertex buffers (sprites) inside the tile's dimensions. This worked, I was able to remove that patch of grass sprites by simply using instance_destroy(); on that instance creating grass on that tile. Eventually allowing my character to remove grass on a certain tile using a shovel. Yes I could just use tiles, but I like the dynamic appearance of using windy grass vertex buffers. Anyway it worked. However, the moment I decided to fill my room with all of these objects to have grass everywhere, my fps dropped by half, it went all slow motion and quite frankly unplayable. So I decided to blame the use of too many objects and tried to modify the asset itself.
I added a loop to the creation code for this obj_vertexgrass that creates grass sprites everywhere, and within this loop, a grid the size of the room that stores the buffer id for the grass sprites / vertex buffers in each tile. This is so that I can make the draw event only draw grass sprites on certain tiles, throughouy the entire room. This method also came with a giant performance impact, perhaps worse than just using objects, but further tweaking the draw event to strictly only draw sprites from the grid that are inside the camera's view fixed everything! - or so I thought. I began joyfully running to the bottom right of the room to make sure my code drew grass on all tiles along the x and y axis, and noticed the game getting progressively slower and slower. Player speed slowing, animation slowing, time slowing. The game is getting slower the higher the x and y coordinates are and I honestly have no idea what to do now. I don't even need to walk far to notice the game slow down.
I thought for a moment that maybe running around the room adds more sprites to the draw event, slowing it down,. So I added more code that does buffer_delete() on all grass sprites previously drawn that are now outside the camera's view, so that they get deleted from the draw event if they somehow aren't already and still the same issue. Vertex buffers are much faster to draw than objects aren't they?
I'm genuinely clueless what to do next. Any advice or ideas would be much appreciated.