Allow more tile types without exceeding 255 limit
Posted: Sun Sep 18, 2022 11:39 am
some mods (eg: alien biomes) consume many tiles. It is nice to have variation, but it causes other problems.
I have 3 ideas that could allow more diverse surfaces within the 255 limit.
- given this a cosmetic only change, it only needs to be calculated for chunks that are being rendered on screen, i believe there can be huge shortcuts here.
1) per surface tile overrides, so that surfaces with 'alternate environments' (other planets, space, interior of factories) can say 'my grass tile here is X'
- only allows variety per surface, not inherent complexity on one surface (eg, dectorio)
- could be complicated by things which allow multiple surfaces to be seen at once (eg: train window)
- but only needs to be held for on-screen tiles, and could be done entirely GPU side as a switchout of a texture map as the player switches.
- increases startup time / time to transition to a new surface.
2a) allow a tile to have multiple variants, and a noise layer to pick which variant is rendered.
- only good for environment, but good for packing many types of desert/forest/grass/... into one tile for rendering variation (eg: alien biomes)
- only a cosmetic change, could potentially not be saved but only held for on-screen entities, at the cost of cpu usage as the user runs around.
- could be done entirely GPU side as an a function pass on the texture table.
2b) allow a tile to be created with a 'rotation / animation frame, or something' via a function call hook called when it is created. this would allow a user hook for an arbitrary function to decide what variant is needed at runtime;
- would allow player placed tiles to be much more dynamic (eg 'r to rotate' decorative tiles, so that placable decorative tiles with a direction to them or a minor color variation (dectorio/hazard concrete) can be packed in one tile
- has a runtime cost for tile placement (possibly even a runtime cost)
both of v2 varients result in more than 255 tiles needing to be rendered, i don't know where certain optimisations are done, and how much could be passed to the GPU to tweak the known texture coordinates based on an optional extra lookup step.
I would anticipate that the parameterised tiles would do something like load dyanmic tiles into the highest values first, so that the c++ level this hook is simply if tileType>normalTileCount renderTilePicture(tileFuncs[tileType]()) else render(tile[tileType])
If this is hooked into a noise generator it would require extra storage; probably a sparse array, given the tiles are sequentially walked for render it wouldn't have that many random seeks for a typical frame. or a full per-tile-in-chunk extra byte if the density of tiles was high enough, combined with the count of random seeks.
3c) provide a special noise layer just for tinting a tile tile, hooked to the rendering the same way pollution water is done.
- can only alter the colour base of a tile based on a pre-defined function
- still may require extra storage, if the color is cached - but only needs to be held for on-screen tiles, and could be done entirely GPU side as a shader.
I have 3 ideas that could allow more diverse surfaces within the 255 limit.
- given this a cosmetic only change, it only needs to be calculated for chunks that are being rendered on screen, i believe there can be huge shortcuts here.
1) per surface tile overrides, so that surfaces with 'alternate environments' (other planets, space, interior of factories) can say 'my grass tile here is X'
- only allows variety per surface, not inherent complexity on one surface (eg, dectorio)
- could be complicated by things which allow multiple surfaces to be seen at once (eg: train window)
- but only needs to be held for on-screen tiles, and could be done entirely GPU side as a switchout of a texture map as the player switches.
- increases startup time / time to transition to a new surface.
2a) allow a tile to have multiple variants, and a noise layer to pick which variant is rendered.
- only good for environment, but good for packing many types of desert/forest/grass/... into one tile for rendering variation (eg: alien biomes)
- only a cosmetic change, could potentially not be saved but only held for on-screen entities, at the cost of cpu usage as the user runs around.
- could be done entirely GPU side as an a function pass on the texture table.
2b) allow a tile to be created with a 'rotation / animation frame, or something' via a function call hook called when it is created. this would allow a user hook for an arbitrary function to decide what variant is needed at runtime;
- would allow player placed tiles to be much more dynamic (eg 'r to rotate' decorative tiles, so that placable decorative tiles with a direction to them or a minor color variation (dectorio/hazard concrete) can be packed in one tile
- has a runtime cost for tile placement (possibly even a runtime cost)
both of v2 varients result in more than 255 tiles needing to be rendered, i don't know where certain optimisations are done, and how much could be passed to the GPU to tweak the known texture coordinates based on an optional extra lookup step.
I would anticipate that the parameterised tiles would do something like load dyanmic tiles into the highest values first, so that the c++ level this hook is simply if tileType>normalTileCount renderTilePicture(tileFuncs[tileType]()) else render(tile[tileType])
If this is hooked into a noise generator it would require extra storage; probably a sparse array, given the tiles are sequentially walked for render it wouldn't have that many random seeks for a typical frame. or a full per-tile-in-chunk extra byte if the density of tiles was high enough, combined with the count of random seeks.
3c) provide a special noise layer just for tinting a tile tile, hooked to the rendering the same way pollution water is done.
- can only alter the colour base of a tile based on a pre-defined function
- still may require extra storage, if the color is cached - but only needs to be held for on-screen tiles, and could be done entirely GPU side as a shader.