NadirRoGue/RenderEngine

Infinite tile generation

arash28134 opened this issue · 2 comments

I understand that this project uses tile-based rendering for more efficiency and better performance, but I can't understand something.
new generated tiles are "connected" to previous tiles as they sort of "continue" each other, meaning that for instance if the nearest tile in front of the camera doesn't have much depth, the next tile that gets generated doesn't out of a sudden receive a whole new heightmap (e.g. doesn't generate big hills out of a sudden).

does it work by saving previous tile's position and passing those to the new tile?

The tile geometry is generated on the GPU. I use 2D Perlin noise to generate a heightmap and move the vertices accordingly.
Perlin noise generates noise values continuously on a 2D grid, given that the input coordinates are continuously as well.
Each tile is assigned the 2D coordinates where they are placed on the plane XY (the coordinates are stored as the UV coordinates of each of the 4 vertices that make up the tile), and they are 1 unit in length in both dimensions.

Thanks to this, I can continue the noise from the end of one tile to the beginning of the next.

Furthermore, the engine features dynamic lod. The geometry of the tile is tesselated on the GPU using tesselation shaders, but the tesselation level depends on the distance of the camera. For this I made a little tesselation level algorithm based on the coordinates of each edge of the tiles, to ensure that to connecting tiles have the same tesselation level on the connecting edge.

The assigment of the 2D coordinates to each tile can be found here:

The implementation of the noise generation, heightmap and tesselation can be found on the terrain shaders:
https://github.com/NadirRoGue/RenderEngine/tree/master/RenderEngine/RenderEngine/shaders/terrain

The tile geometry is generated on the GPU. I use 2D Perlin noise to generate a heightmap and move the vertices accordingly. Perlin noise generates noise values continuously on a 2D grid, given that the input coordinates are continuously as well. Each tile is assigned the 2D coordinates where they are placed on the plane XY (the coordinates are stored as the UV coordinates of each of the 4 vertices that make up the tile), and they are 1 unit in length in both dimensions.

Thanks to this, I can continue the noise from the end of one tile to the beginning of the next.

Furthermore, the engine features dynamic lod. The geometry of the tile is tesselated on the GPU using tesselation shaders, but the tesselation level depends on the distance of the camera. For this I made a little tesselation level algorithm based on the coordinates of each edge of the tiles, to ensure that to connecting tiles have the same tesselation level on the connecting edge.

The assigment of the 2D coordinates to each tile can be found here:

The implementation of the noise generation, heightmap and tesselation can be found on the terrain shaders: https://github.com/NadirRoGue/RenderEngine/tree/master/RenderEngine/RenderEngine/shaders/terrain

Thank you a lot!