Do these 7-parts of every tile really all need to be dynamic? I’ve seen games that allocate a render target for all the background stuff and never have to render it again.
I’m not sure actually.
Here are some details:
The world is separated into chunks which are received from the server when the player approaches them (so they don’t have to download the entire world’s information at login). Each update & draw phase I grab the information for the tiles that are visible on the screen (basically a set of IDs, height values, and a hidden variant value that determines which variant of a tile will appear on that spot, as our tile textures all have 8 variants so they look less repetitive despite being the same material). As the player moves around, the area I need to draw changes, so I rebuild the information and draw it. The tile segments are to allow a smooth blend between tile textures no matter what is on the tile (could be dirt, grass, sand, road, brick, etc), and I use a shader with an int to tell it which direction I want the individual draws alpha faded. To draw an edge (for example left to right), I just draw the same segment twice, once from the left, fading to the right, with the left tile’s texture, and once from the right fading to the left with the right tile’s texture, which makes a nice blend.
IS there a way I could just draw it to a rendertarget once and not have to draw it again? I’d still have to update it when their location changed to another tile (and move the rendered image around as they move around within the tile they’re on) but it does sound like a good idea for the other X frames where I don’t need to be recalculating this data. I will try it but I’m still learning here, lol.
Then it sounds like a ‘chunk’ is the size you should allocate a render target for, one for each one in ‘scope’ of the player. When you receive the chunk, draw it once and hold onto the render target.
That sounds awesome and I’m definitely going to give it a try. I just have to learn how to use a render target other than the default Googling is in order. It sounds like that would totally solve my problem.
Do I just use more than one renderTarget if I want to draw separate layers? Like tiles and world stuff on one, player and entities on another?
Reason I ask is the player/entities need to appear behind things properly since this world is technically 3D despite it being a 2D game. You will be able to walk behind things and rotate the camera to get a better view, etc. Falling in holes will look something like an old Dragon Quest game where everything above you is blackened out so you can see the level you’re on. But the camera doesn’t “rotate,” it just snaps to a different perspective (N/S/E/W), and then the world is drawn programatically from that direction.
I’m trying to think of how I could make that work if the world is baked per chunk. (And it would obviously need a re-bake on camera rotate)