I am planning to create a game with square tile based map.
There are 6 types of tiles:
- Horizontal tile with no height (0)
- Horizontal tile with height != 0
- (North or East direction) sloped planar tile
- Tile with 2 non-planar triangles (edge between 2 triangles can be / or )
- Cliff to connect neighbor tiles with different heights
All textures for tile mosaic and pickup bonus (pickup bonus + mosaic = multitexture) are stored in a 2d texture array. So for every tile, only the index (or indices) of texture array needed.
Any of these tiles has its own structure, different from other types both in contents and size. To differentiate one tile structure from another, first integer member in every structure contains type information. (e.g. A horizontal tile with no height needs 3 integers and a tile with 2 non-planar triangles needs 11 integers. Another horizontal tile with no height needs 4 integers because needs 2 textures).
My design is like this:
- Tile based map is made up from West to East stripes of tiles.
- There is a (read-only) shader storage buffer with all structures of tiles in game map.
- Vertex shader is a pass-through shader. Every vertex1d (POINT) is a tile (see next).
- Vertex array buffer, has nothing to do with vertices. It has only the pointer to shader storage buffer of tile data for the specific tile.
- Geometry shader takes vertex1d from vertex shader and access the shader storage buffer with vertex1d as pointer (offset).
- Geometry shader creates everything for the tile: vertices, texcoords for one or more textures, normals etc. Tile is a 2-triangle triangle-strip.
- Because structures in shader storage buffer varies, I prefer a big array of integers
Questions:
- Is this design viable? (It is a silly question, but I am beginner)
- For sure, to avoid all of these, discard geometry shader and add all things in vertex array buffer, is faster. But how slower can be my design? 2 times slower or 1000 times slower?