]> git.mcshandy.xyz Git - barrow_crawler/commitdiff
Some changes I like but mostly End Of Day
authorRandy McShandy <randy@mcshandy.xyz>
Fri, 10 May 2024 03:43:08 +0000 (22:43 -0500)
committerRandy McShandy <randy@mcshandy.xyz>
Fri, 10 May 2024 03:43:08 +0000 (22:43 -0500)
src/render_raylib.c
src/shaders/lighting.fs

index 2eeff4e4494d24b982e08aa0b5cd0329c8ae8193..ecefbf62e8a81c543f30e048f2eacf6db7c7f1ac 100644 (file)
@@ -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();
 
index 14906255222f838e4934af3653aeedb122e01b69..30d1922a3471fe6e03147c9bee3f9e129673b07c 100644 (file)
@@ -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;
+               }
 }