added debug cvars
[fishladder.git] / fishladder_resources.h
index a029421bebe4625a12979c768313da9b83f9dfdd..00cb199a780b3334f02ed0eb9201c46fc7939d0a 100644 (file)
@@ -1,23 +1,29 @@
+// TEXTURES
+// ===========================================================================================================
+
 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, &tex_background };
+
+// AUDIO
+// ===========================================================================================================
 
-vg_tex2d *texture_list[] = { &tex_tile_detail, &tex_tile_data, &tex_wood, &tex_ball };
+sfx_vol_control audio_volume_sfx =             { .val = 1.0f, .name = "Sound effects" };
+sfx_vol_control audio_volume_music =   { .val = 1.0f, .name = "Music" };
 
-sfx_system_t audio_system_sfx = 
+sfx_system audio_system_sfx = 
 {
  .vol = 1.f,
- .spd = 1.f,
  .ch = 1,
- .cur = 0,
- .vol_src = &g_vol_sfx,
- .flags = 0x00,
- .fadeout = FADEOUT_LENGTH,
+ .vol_src = &audio_volume_sfx,
  .name = "sfx"
 };
 
-sfx_set_t audio_tile_mod = 
+sfx_set audio_tile_mod = 
 {
  .sources = "\
 sound/mod_01.ogg\0\
@@ -29,6 +35,60 @@ sound/mod_06.ogg\0",
  .flags = 0
 };
 
+sfx_set audio_splitter =
+{
+ .sources = "\
+sound/splitter_01.ogg\0"
+};
+
+sfx_set audio_rolls = 
+{
+ .sources = "\
+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 =
+{
+       .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx, 
+       .name = "Balls Rolling", .flags = SFX_FLAG_REPEAT
+};
+
+// Various oneshots
+sfx_system audio_system_balls_switching =
+{
+       .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx, 
+       .name = "Balls Switching"
+};
+
+// Gameplay critical sounds eg. splitter sound rocking
+sfx_system audio_system_balls_important =
+{
+       .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx, 
+       .name = "Balls Gameplay"
+};
+
+// Suplemental sounds
+sfx_system audio_system_balls_extra = 
+{
+       .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx, 
+       .name = "Balls Extra"
+};
+
 static void resource_load_main(void)
 {
        // Textures
@@ -36,12 +96,19 @@ static void resource_load_main(void)
        
        // Audio
        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
@@ -143,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;"
        ""
@@ -159,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 );"
@@ -167,7 +235,46 @@ 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 = world_pos * 0.25;"
+       "}",
+       
+       // FRAGMENT
+       "out vec4 FragColor;"
+       ""
+       "uniform sampler2D uTexMain;"
+       ""
+       "in vec2 aTexCoords;"
+       ""
+       "vec2 hash22(vec2 p)"
+       "{"
+               "vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));"
+               "p3 += dot(p3, p3.yzx+33.33);"
+               "return fract((p3.xx+p3.yz)*p3.zy);"
+       "}"
+       ""
+       "void main()"
+       "{"
+               "vec2 random_offset = floor( hash22( floor( aTexCoords * 4.0 ) ) * 4.0 ) * 0.25;"
+               "vec4 background = texture( uTexMain, aTexCoords );"
+               "FragColor = vec4( background.rgb * (1.0+random_offset.r*0.015), 1.0 );"
+       "}"
+       ,
+       UNIFORMS({ "uPv", "uOffset", "uTexMain" })
 )
 
 void vg_register(void)
@@ -175,4 +282,5 @@ void vg_register(void)
        SHADER_INIT( shader_tile_colour );
        SHADER_INIT( shader_tile_main );
        SHADER_INIT( shader_ball );
+       SHADER_INIT( shader_background );
 }