X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=fishladder_resources.h;h=511854b8c107fc8d25d44d5b615f84ef263c41a2;hb=155f3c26eb39c89057d52d72b45898819edfe640;hp=cd73f52899a380f01c0137c8194b7c72045dcde6;hpb=d94e286c52dcfd5faf7cbd12690268f9d68957ef;p=fishladder.git diff --git a/fishladder_resources.h b/fishladder_resources.h index cd73f52..511854b 100644 --- a/fishladder_resources.h +++ b/fishladder_resources.h @@ -5,8 +5,9 @@ vg_tex2d tex_tile_data = { .path = "textures/tileset.png" }; vg_tex2d tex_tile_detail = { .path = "textures/tile_overlays.png" }; vg_tex2d tex_wood = { .path = "textures/wood.png" }; vg_tex2d tex_ball = { .path = "textures/ball.png", .flags = VG_TEXTURE_CLAMP }; +vg_tex2d tex_background = { .path = "textures/background.png" }; -vg_tex2d *texture_list[] = { &tex_tile_detail, &tex_tile_data, &tex_wood, &tex_ball }; +vg_tex2d *texture_list[] = { &tex_tile_detail, &tex_tile_data, &tex_wood, &tex_ball, &tex_background }; // AUDIO // =========================================================================================================== @@ -47,6 +48,19 @@ sound/rolling_01.ogg\0\ sound/rolling_02.ogg\0" }; +sfx_set audio_random = +{ + .sources = "\ +sound/random_01.ogg\0\ +sound/random_02.ogg\0\ +sound/random_03.ogg\0\ +sound/random_04.ogg\0\ +sound/random_05.ogg\0\ +sound/random_06.ogg\0\ +sound/random_07.ogg\0\ +sound/random_08.ogg\0" +}; + // One two or three layers of rolling noise sfx_system audio_system_balls_rolling = { @@ -84,14 +98,17 @@ static void resource_load_main(void) sfx_set_init( &audio_tile_mod, NULL ); sfx_set_init( &audio_splitter, NULL ); sfx_set_init( &audio_rolls, NULL ); + sfx_set_init( &audio_random, NULL ); } static void resource_free_main(void) { - vg_tex2d_free( texture_list, vg_list_size( texture_list ) ); + vg_tex2d_free( texture_list, vg_list_size( texture_list ) ); + sfx_set_free( &audio_tile_mod ); sfx_set_free( &audio_splitter ); sfx_set_free( &audio_rolls ); + sfx_set_free( &audio_random ); } // SHADERS @@ -193,6 +210,7 @@ SHADER_DEFINE( shader_tile_main, "uniform sampler2D uTexGlyphs;" "uniform sampler2D uTexWood;" "uniform float uGhost;" + "uniform float uForeground;" "uniform vec2 uMousePos;" "uniform vec4 uColour;" "" @@ -209,7 +227,7 @@ SHADER_DEFINE( shader_tile_main, "vec3 shadows = mix( vec3( 0.85, 0.7344, 0.561 ), vec3(1.0,1.0,1.0), glyph.r );" - "vec4 output_regular = vec4( wood_comp * shadows, glyph.b );" + "vec4 output_regular = vec4( wood_comp * shadows, mix( glyph.a, glyph.b, uForeground ) );" "float ghost_dist = clamp( 1.5 - distance(uMousePos, aWorldCoords), 0.0, 1.0 );" "vec4 output_ghost = vec4( 1.0, 1.0, 1.0, glyph.g * ghost_dist );" @@ -217,7 +235,61 @@ SHADER_DEFINE( shader_tile_main, "FragColor = mix( output_regular, output_ghost, uGhost ) * uColour;" "}" , - UNIFORMS({ "uPv", "uOffset", "uTexGlyphs", "uTexWood", "uSubTransform", "uGhost", "uMousePos", "uColour" }) + UNIFORMS({ "uPv", "uOffset", "uTexGlyphs", "uTexWood", "uSubTransform", "uGhost", "uMousePos", "uColour", "uForeground" }) +) + +SHADER_DEFINE( shader_background, + // VERTEX + "layout (location=0) in vec2 a_co;" + "uniform mat3 uPv;" + "uniform vec3 uOffset;" + "" + "out vec2 aTexCoords;" + "" + "void main()" + "{" + "vec2 world_pos = a_co * uOffset.z + uOffset.xy;" + "gl_Position = vec4( uPv * vec3( world_pos, 1.0 ), 1.0 );" + "aTexCoords = a_co;" + "}", + + // FRAGMENT + "out vec4 FragColor;" + "" + "uniform sampler2D uTexMain;" + "uniform sampler2D uSamplerNoise;" + "uniform float uVariance;" + "" + "in vec2 aTexCoords;" + "" + "void main()" + "{" + "float ao_accum = 0.0;" + "for( int i=0; i<10; ++i )" + "{" + "vec2 random_noise = (texture( uSamplerNoise, aTexCoords * 20.0 + float(i) * 0.2 ).xy - vec2( 0.5, 0.5 )) * uVariance;" + "vec4 background = texture( uTexMain, aTexCoords + random_noise );" + "ao_accum += background.r * clamp((1.0 - length( random_noise )), 0.0, 1.0);" + "}" + "ao_accum *= 0.15;" + + "vec4 data_this_tile = texture( uTexMain, aTexCoords );" + + "ao_accum -= data_this_tile.r;" + + "vec3 colour_main = vec3( 0.369768, 0.3654, 0.42 );" + + "vec2 square_coords = fract( aTexCoords * 64.0 );" + "vec2 grid_coords = abs( square_coords - 0.5 );" + "float edge_contrast = (1.0-ao_accum*0.2);" + + "float gridline = step( 0.49, max(grid_coords.x,grid_coords.y) );" + "float gridline_fadeout = min(max(edge_contrast-1.0, 0.0)*40.0 + data_this_tile.g,10.0);" + + "FragColor = vec4( colour_main * edge_contrast + gridline * 0.02 * gridline_fadeout, 1.0 );" + "}" + , + UNIFORMS({ "uPv", "uOffset", "uTexMain", "uVariance", "uSamplerNoise" }) ) void vg_register(void) @@ -225,4 +297,24 @@ void vg_register(void) SHADER_INIT( shader_tile_colour ); SHADER_INIT( shader_tile_main ); SHADER_INIT( shader_ball ); + SHADER_INIT( shader_background ); } + +/* + 0000 0 | 0001 1 | 0010 2 | 0011 3 + | | | | | + X | X= | X | X= + | | | + 0100 4 | 0101 5 | 0110 6 | 0111 7 + | | | | | + =X | =X= | =X | =X= + | | | + 1000 8 | 1001 9 | 1010 10 | 1011 11 + | | | | | + X | X= | X | X= + | | | | | | | + 1100 12 | 1101 13 | 1110 14 | 1111 15 + | | | | | + =X | =X= | =X | =X= + | | | | | | | +*/