]> git.mcshandy.xyz Git - barrow_crawler/commitdiff
More toying with lighting and also add an entrance lol
authorRandy McShandy <randy@mcshandy.xyz>
Sun, 12 May 2024 03:48:25 +0000 (22:48 -0500)
committerRandy McShandy <randy@mcshandy.xyz>
Sun, 12 May 2024 03:48:25 +0000 (22:48 -0500)
src/render_raylib.c
src/shaders/lighting.fs
src/structs.c
src/utils.c

index ecefbf62e8a81c543f30e048f2eacf6db7c7f1ac..6448bfa9a682363277eafcbd074ac2214bf96fb3 100644 (file)
@@ -66,6 +66,11 @@ void process_inputs()
                        player_rotation.x = rotate_speed;
                }
 
+               if (IsKeyDown(KEY_SPACE) || IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT))
+               {
+                       //player_velocity.x *= 2.0f;
+               }
+
                switch(key)
                {
                        default:
@@ -77,7 +82,7 @@ void process_inputs()
 
 void initialize_prerenderer()
 {
-       fscreen_dims = (Vector2){.x=1200.0f, .y=800.0f};
+       fscreen_dims = (Vector2){.x=screen_dims.x, .y=screen_dims.y};
 }
 
 void initialize_renderer()
@@ -129,10 +134,11 @@ void initialize_renderer()
        cam = (Camera3D){0};
        cam.position    = barrow_position;
        cam.position.y -= 0.5f;
-       cam.position.x = barrow_scale.x/2 + barrow_position.x;
+       cam.position.x = 0;//barrow_scale.x/2;
+       cam.position.z = -barrow_scale.z/2;
        cam.target              = (Vector3){0.0f, cam.position.y - 12.0f, 0.0f};
        cam.up                          = (Vector3){0.0f, 1.0f, 0.0f};
-       cam.fovy                        = 75.0f;
+       cam.fovy                        = 90.0f;
        cam.projection= CAMERA_PERSPECTIVE;
 
        DisableCursor();
@@ -168,8 +174,7 @@ void start_render_loop()
                        EndMode3D();
 
                        DrawTexturePro(barrow_texture, minimap_src, minimap_dest, (Vector2){0.0f, 0.0f}, 0.0f, RAYWHITE);
-                       DrawText(TextFormat("%f, %f", fscreen_dims.x, fscreen_dims.y), 0, 32, 32, RAYWHITE);
-                       DrawFPS(10, 10);
+                       DrawFPS(fscreen_dims.x - 80, 10);
                EndDrawing();
 
                /* Decay forward velocity and rotation */
index 30d1922a3471fe6e03147c9bee3f9e129673b07c..b8437bbb7e43d59fd29884a6f3bf342fca75828f 100644 (file)
@@ -82,8 +82,9 @@ void main()
     // Texel color fetching from texture sampler
     vec4 texelColor = texture(texture0, fragTexCoord);
 
-               const float max_dist = 4.0f;
-               const float max_lum = 0.7f;
+               const float max_dist = 7.5f;
+               const float lit_dist = 2.5f;
+               const float max_lum = 1.0f;
                float cam_dist_z = gl_FragCoord.z/gl_FragCoord.w;
                float norm_dist_z = (cam_dist_z/max_dist);
 
@@ -96,22 +97,23 @@ void main()
                        float norm_x_dist = abs(gl_FragCoord.x - (screen_dims.x/2))/(screen_dims.x/2);
                        lumWeight = min(max_lum, 1.0f - easeInQuart(norm_dist_z));
                }
-
                vec3 lumWeights = v3_unit * lumWeight;
-               float lum = dot(finalColor.rgb, lumWeights);
-               float rand = random(fragTexCoord);
-               lumWeights *= lum;
-               finalColor.rgb = mix(vec3(227/255, 60/255, 0/255), finalColor.rgb, lumWeights);
-               finalColor.a = 1.0f;
 
                // All single color channel variations with this looks cool as FUCK
                // turns this into three levels going b-r-g
-               //float norm_y_dist = (gl_FragCoord.y * screen_dims.y) / screen_dims.y;
                float norm_y_dist = uv.y;
                finalColor.b = 0.0f;
 
-               if(distance(uv, vec2(0.25, 0.35)) <= 0.25)
+               if(cam_dist_z < lit_dist)
                {
-                       finalColor.b = 1.0f;
+                       float norm_x_dist = abs(gl_FragCoord.x - (screen_dims.x/2))/(screen_dims.x/2);
+                       lumWeights.r = 1.8f * (1.0f - norm_dist_z);
                }
+
+               float lum = dot(finalColor.rgb, lumWeights);
+               float rand = random(fragTexCoord);
+               lumWeights *= lum;
+               finalColor.rgb = mix(vec3(227/255, 60/255, 0/255), finalColor.rgb, lumWeights);
+               finalColor.a = 1.0f;
+
 }
index dcab0bdfc8c16436e0df246a9031bfbe8f276f8b..2d2ea9295d3288f2a72c22e56b73d3683424de8b 100644 (file)
@@ -72,7 +72,7 @@ const Mat3 laplacian_kernel =
 const char chars[6] = {' ', ' ', ' ', '+', '#', '@'};
 const int max_chars = sizeof(chars) / sizeof(chars[0]) - 1;
 
-const IVec2 screen_dims = {.x = 1200, .y = 800};
+const IVec2 screen_dims = {.x = 1800, .y = 1200};
 const char* screen_title = "Barrow Crawler";
 const int target_fps = 60;
 
index 8e75c34933bc5ed676010fbff9e4b445dffd7225..78618d7cd53304b651237aeab11b25e73a428a4d 100644 (file)
@@ -122,7 +122,7 @@ int initialize(int worker_count, RD_Opts active_opt)
        }
 
        /* Set up seed-points to create connected rooms */
-       const int seed_count = 9;//sqrt(grid_size.x) * 2;
+       const int seed_count = 10;//sqrt(grid_size.x) * 2;
        const int width = 12 * (grid_size.x/128);
        const int height = width * 1;
        const float small_room_radius = 16.0f;
@@ -135,7 +135,9 @@ int initialize(int worker_count, RD_Opts active_opt)
                angle += phase;
 
                int seed_x = ((cosf(angle) * (grid_size.x/4.0f)) + (grid_size.x/2.0f));
-               int seed_y = ((sinf(angle) * (grid_size.x/4.0f)) + (grid_size.x/2.0f));
+               int seed_y = ((sinf(angle) * (grid_size.y/4.0f)) + (grid_size.y/2.0f));
+
+
                grid[seed_x][seed_y].b = 1.0f;
                grid[seed_x][seed_y].c = 0.0f;
 
@@ -172,6 +174,18 @@ int generate_rd(int worker_count, RD_Opts active_opt, FVec2 **grid_buffer, IVec2
        uint32_t albedo_buffer[pgrid_size.x][pgrid_size.y];
        uint32_t large_albedo_buffer[pgrid_size.x*img_export_scale.x][pgrid_size.y*img_export_scale.y];
 
+       int entrance_radius = 16.0f;
+       int seed_x = grid_size.x/2;
+       int seed_y = entrance_radius;
+       for (int x = seed_x-entrance_radius; x < seed_x+entrance_radius; x++)
+       {
+               for (int y = seed_y-entrance_radius; y < seed_y+entrance_radius; y++)
+               {
+                       if ((sqrtf(((x-seed_x)*(x-seed_x))+((y-seed_y)*(y-seed_y))) < entrance_radius))
+                               grid_buffer[x][y].a = 0.0f;
+               }
+       }
+
        for (int x = 0; x < pgrid_size.x; x++)
        {
                for (int y = 0; y < pgrid_size.y; y++)