Hi all,
this time I have been playing with a system that builds a tiled fullscreen MMI2D from a single bit noise map.
The tileset consists in a tile for each variant of a 8 bits mask.
It first builds a single bit map from a perlin noise algorithm that fits the screen visible tiles. It then computes the corresponding tile uv coordinates for each tile from its neighborhood.
const vec2 offset[8] = {
vec2( 1.0, 0.0 ),
vec2( 1.0, 1.0 ),
vec2( 0.0, 1.0 ),
vec2( -1.0, 1.0 ),
vec2( -1.0, 0.0 ),
vec2( -1.0, -1.0 ),
vec2( 0.0, -1.0 ),
vec2( 1.0, -1.0 )
};
const float bits[8] = { 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0 };
...
float mask = 0.0;
for( int i = 0; i < 8; i += 1 ) {
mask += get_mask( world_pos + offset[i] ) * bits[i];
}
mask *= 1.0 - get_mask( world_pos );
vec2 tile_uv;
tile_uv.x = mod( mask, 16.0 ) / 16.0;
tile_uv.y = floor( mask / 16.0 ) / 16.0;
It looks pretty cool, isn’t it?