From: Randy McShandy Date: Wed, 23 Apr 2025 04:23:32 +0000 (-0500) Subject: More messing with shading, lighting etc. Add a build target for easier toggling of... X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=70fdc7aaadaf0eead66f87128ac6687103e4c951;p=barrow_crawler More messing with shading, lighting etc. Add a build target for easier toggling of generation. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 36fd47e..f6c5c88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,15 +11,20 @@ FILE(GLOB POSIX_SRC src/*.c src/platforms/platform_posix.c) FILE(GLOB WINDOWS_SRC src/*.c src/platforms/platform_win.c) add_executable(posix_BC ${POSIX_SRC}) +add_executable(ng_posix_BC ${POSIX_SRC}) add_executable(windows_BC ${WINDOWS_SRC}) target_compile_definitions(posix_BC PUBLIC POSIX_BC=1) +target_compile_definitions(ng_posix_BC PUBLIC POSIX_BC=1) target_compile_definitions(windows_BC PUBLIC WINDOWS_BC=1) -target_compile_options(posix_BC PUBLIC -Wall -g) +target_compile_options(posix_BC PUBLIC -Wall -g -DENABLE_BARROWGEN) +target_compile_options(ng_posix_BC PUBLIC -Wall -g) target_link_libraries(posix_BC -lm -lpthread -lraylib) +target_link_libraries(ng_posix_BC -lm -lpthread -lraylib) target_link_libraries(windows_BC -lm -lpthread -lraylib) set_target_properties(posix_BC PROPERTIES RUNTIME_OUTPUT_DIRECTORY ./bin/) +set_target_properties(ng_posix_BC PROPERTIES RUNTIME_OUTPUT_DIRECTORY ./bin/) set_target_properties(windows_BC PROPERTIES RUNTIME_OUTPUT_DIRECTORY ./bin/) diff --git a/src/main.c b/src/main.c index 187ec7a..7478fb4 100755 --- a/src/main.c +++ b/src/main.c @@ -18,8 +18,7 @@ int main(int argc, char** argv) room_positions = (Vector3*)malloc(sizeof(Vector3)*(room_count + 1)); /* TODO: Clean this up and integrate into platform system. */ -#define ENABLE_BARROWGEN 1 -#if ENABLE_BARROWGEN +#ifdef ENABLE_BARROWGEN barrow.max_iterations *= 1; IVec2 grid_size = {.x = GRID_X*2.0, .y = GRID_Y * 2.0}; GeneratorArgs gargs = diff --git a/src/render_raylib.c b/src/render_raylib.c index 1e40d86..ff2df95 100644 --- a/src/render_raylib.c +++ b/src/render_raylib.c @@ -110,8 +110,8 @@ Vector3 vec3_up = {0.0f, 1.0f, 0.0f}; Vector3 vec3_down = {0.0f, -1.0f, 0.0f}; Vector3 vec3_zero = {0.0f, 0.0f, 0.0f}; -Color orb_color = BLUE; -Color orb_target_color = BLUE; +Color orb_color = SKYBLUE; +Color orb_target_color = SKYBLUE; Vector4 orb_normal_color; float orb_intensity = 1.0f; /* TODO: normalized distance from center, but lighting shader already has this. */ Vector3 orb_directionality = {1.0f, 1.0f, 1.0f}; @@ -165,15 +165,15 @@ void drawing_game_mode() Vector3 each = room_positions[n]; DrawSphere(each, 1.0, RED); } - DrawSphere(map_center, 1.0, BLUE); + DrawSphere(map_center, 1.0, SKYBLUE); DrawSphere(barrow_position, 1.0, GREEN); DrawSphere(floor_position, 1.0, PURPLE); - for (int n = 0; n < spawn_spoke_count; n++) - { - Ray* each = &spawn_spoke_rays[n]; - //DrawRay(*each, RED); - } + //for (int n = 0; n < spawn_spoke_count; n++) + //{ + // Ray* each = &spawn_spoke_rays[n]; + // DrawRay(*each, RED); + //} //DrawRay(player_collide_ray, RED); EndShaderMode(); @@ -306,10 +306,12 @@ void control_game_mode() } if (IsKeyReleased(KEY_ONE)) - orb_target_color = RED; + orb_target_color = SKYBLUE; if (IsKeyReleased(KEY_TWO)) - orb_target_color = BLUE; + orb_target_color = RED; if (IsKeyReleased(KEY_THREE)) + orb_target_color = BLUE; + if (IsKeyReleased(KEY_FOUR)) orb_target_color = GREEN; orb_color = ColorLerp(orb_color, orb_target_color, frame_time * 2); @@ -553,7 +555,6 @@ void start_render_loop() //player_collide_point.y -= 1.0f; controlfuncs[func_idx](); - SetShaderValue(shader, cam_position_shader_loc, &cam.position, SHADER_UNIFORM_VEC3); SetShaderValue(shader, screen_dims_shader_loc, &fscreen_dims, SHADER_UNIFORM_VEC2); SetShaderValue(shader, map_center_shader_loc, &map_center, SHADER_UNIFORM_VEC3); diff --git a/src/shaders/lighting.fs b/src/shaders/lighting.fs index f098e28..4d0f163 100644 --- a/src/shaders/lighting.fs +++ b/src/shaders/lighting.fs @@ -21,11 +21,11 @@ out vec4 finalColor; const vec3 v3_unit = vec3(1.0f, 1.0f, 1.0f); const float max_lum = 1.0f; -const float max_lit_distance = 7.5f; +const float max_lit_distance = 4.0f; const float max_center_distance = 8.0f; vec4 candle_color = vec4(228.0f/255.0f, 103.0f/255.0f, 1.0f/255.0f, 255.0f/255.0f); -vec2 orb_pos = vec2(5.0 * (screen_dims.x/16), 8 * (screen_dims.y/16)); +vec2 orb_pos = vec2(3.0 * (screen_dims.x/16), 8 * (screen_dims.y/16)); float lumWeight = 0.0f; @@ -123,26 +123,31 @@ void main() if(normalized_lit_distance <= 1.0f) { - lumWeight = max(lumWeight, min(0.5f, easeOutExpo(normalized_lit_distance))); + lumWeight = max(lumWeight, min(0.6f, easeOutExpo(normalized_lit_distance))); candle_weight = 1.0f - normalized_lit_distance; } float normal_distance_from_orb = distance(orb_pos, gl_FragCoord.xy)/orb_intensity; if(normal_distance_from_orb < 1.0f) { - lumWeight = 3.0f; + lumWeight = 2.0f; finalColor *= (orb_color * lumWeight); - finalColor.a = (1.5 - easeOutExpo(normal_distance_from_orb)); + finalColor.a = (2.5 - easeOutExpo(normal_distance_from_orb)); } lumWeight = min(lumWeight, max_lum); lumWeights = vec4(1.0f) * lumWeight; lumWeights *= dot(finalColor, lumWeights); - lighting_color = vec4(mix(orb_color.rgb * candle_weight, lumWeights.rgb, 0.4f), 1.0f); + lighting_color = vec4(mix(orb_color.rgb * candle_weight, lumWeights.rgb, 0.2f), 1.0f); //lighting_color = vec4(mix(candle_color.rgb * candle_weight, lumWeights.rgb, 0.4f), 1.0f); finalColor = finalColor * lighting_color; + float factor = 35.0; + finalColor.r = round((finalColor.r) * factor) / factor; + finalColor.g = round((finalColor.g) * factor) / factor; + finalColor.b = round((finalColor.b) * factor) / factor; + // All single color channel variations with this looks cool as FUCK // turns this into three levels going b-r-g //finalColor.b = 0.0f; diff --git a/src/shaders/lighting.vs b/src/shaders/lighting.vs index bc29dc5..1d17586 100644 --- a/src/shaders/lighting.vs +++ b/src/shaders/lighting.vs @@ -12,6 +12,7 @@ uniform vec3 viewPos; uniform vec2 screen_dims; uniform vec3 map_center; uniform mat4 matModel; +uniform float d_time; // Output vertex attributes (to fragment shader) out vec2 fragTexCoord; diff --git a/src/utils.c b/src/utils.c index 47c8db2..5c33a69 100644 --- a/src/utils.c +++ b/src/utils.c @@ -218,6 +218,7 @@ void* generate_rd(void* args) { albedo_buffer[x][y] = 0xFF114769; } + albedo_buffer[x][y] += (0x001F1F1F * (rand() % 2)); } }