From: Randy McShandy Date: Sun, 12 May 2024 03:48:25 +0000 (-0500) Subject: More toying with lighting and also add an entrance lol X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=9c6d0d6ae0907f102c0edfccd5833dd78b468f78;p=barrow_crawler More toying with lighting and also add an entrance lol --- diff --git a/src/render_raylib.c b/src/render_raylib.c index ecefbf6..6448bfa 100644 --- a/src/render_raylib.c +++ b/src/render_raylib.c @@ -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 */ diff --git a/src/shaders/lighting.fs b/src/shaders/lighting.fs index 30d1922..b8437bb 100644 --- a/src/shaders/lighting.fs +++ b/src/shaders/lighting.fs @@ -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; + } diff --git a/src/structs.c b/src/structs.c index dcab0bd..2d2ea92 100644 --- a/src/structs.c +++ b/src/structs.c @@ -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; diff --git a/src/utils.c b/src/utils.c index 8e75c34..78618d7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -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++)