From 329310a3e932c1eb006092e320bd58ad9b4f4980 Mon Sep 17 00:00:00 2001 From: Randy McShandy Date: Thu, 9 May 2024 22:43:08 -0500 Subject: [PATCH] Some changes I like but mostly End Of Day --- src/render_raylib.c | 13 ++++++++++--- src/shaders/lighting.fs | 23 ++++++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/render_raylib.c b/src/render_raylib.c index 2eeff4e..ecefbf6 100644 --- a/src/render_raylib.c +++ b/src/render_raylib.c @@ -5,7 +5,6 @@ Vector2 fscreen_dims; Camera3D cam; - Image barrow_image; Texture barrow_texture; Texture barrow_albedo; @@ -33,7 +32,7 @@ int screen_dims_shader_loc; Vector3 player_velocity; Vector3 player_rotation; -float forward_speed = 0.025f; +float forward_speed = 0.015f; float forward_speed_decay = 0.05f; float rotate_speed = 0.8f; float rotate_speed_decay = 0.10f; @@ -76,9 +75,13 @@ void process_inputs() while((key = GetKeyPressed())); } +void initialize_prerenderer() +{ + fscreen_dims = (Vector2){.x=1200.0f, .y=800.0f}; +} + void initialize_renderer() { - fscreen_dims = (Vector2){.x=screen_dims.x, .y=screen_dims.y}; shader = LoadShader("./src/shaders/lighting.vs", "./src/shaders/lighting.fs"); shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos"); @@ -137,7 +140,9 @@ void initialize_renderer() void start_render_loop() { + initialize_prerenderer(); InitWindow(fscreen_dims.x, fscreen_dims.y, screen_title); + SetWindowState(FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE); initialize_renderer(); Rectangle minimap_dest = {.width = 64.0f*img_export_scale.x, .height = 64.0f*img_export_scale.y, .x = 0.0f, .y = 0.0f}; @@ -151,6 +156,7 @@ void start_render_loop() SetShaderValue(shader, screen_dims_shader_loc, &fscreen_dims, SHADER_UNIFORM_VEC2); UpdateCameraPro(&cam, player_velocity, player_rotation, 0.0f); + BeginDrawing(); ClearBackground(BLACK); @@ -162,6 +168,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); EndDrawing(); diff --git a/src/shaders/lighting.fs b/src/shaders/lighting.fs index 1490625..30d1922 100644 --- a/src/shaders/lighting.fs +++ b/src/shaders/lighting.fs @@ -17,6 +17,8 @@ out vec4 finalColor; const vec3 v3_unit = vec3(1.0f, 1.0f, 1.0f); float lumWeight = 0.0f; +const vec2 candle_pos = vec2(0.5, 0.5); + // A single iteration of Bob Jenkins' One-At-A-Time hashing algorithm. uint hash( uint x ) { x += ( x << 10u ); @@ -80,12 +82,12 @@ void main() // Texel color fetching from texture sampler vec4 texelColor = texture(texture0, fragTexCoord); - // NOTE: Implement here your fragment shader code - - const float max_dist = 6.0f; + const float max_dist = 4.0f; const float max_lum = 0.7f; float cam_dist_z = gl_FragCoord.z/gl_FragCoord.w; - float norm_dist_z = cam_dist_z/max_dist; + float norm_dist_z = (cam_dist_z/max_dist); + + vec2 uv = gl_FragCoord.xy/screen_dims; finalColor = texelColor*colDiffuse; @@ -93,7 +95,7 @@ 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); @@ -101,4 +103,15 @@ void main() 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) + { + finalColor.b = 1.0f; + } } -- 2.49.0