From d219cb88a336c8e02b8d7bbc69785df59620ab41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Thu, 29 Aug 2024 20:51:44 +0200 Subject: [PATCH] demo update --- demos/09-shadows.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/demos/09-shadows.c b/demos/09-shadows.c index 87cf96d..8a009a0 100644 --- a/demos/09-shadows.c +++ b/demos/09-shadows.c @@ -60,6 +60,12 @@ int main(int argc, char** argv) { array(light_t) directional_lights = 0; array_push(directional_lights, lit4); + array(light_t) all_lights = 0; + array_push(all_lights, lit); + array_push(all_lights, lit2); + array_push(all_lights, lit3); + array_push(all_lights, lit4); + bool initialized = 0; bool must_reload = 0; @@ -92,19 +98,20 @@ int main(int argc, char** argv) { camera_fps(&cam, mouse.x,mouse.y); enum { - POINT, SPOT, DIR + POINT, SPOT, DIR, ALL }; static unsigned mode = POINT; if (input_down(KEY_1)) mode = POINT; if (input_down(KEY_2)) mode = SPOT; if (input_down(KEY_3)) mode = DIR; - + if (input_down(KEY_4)) mode = ALL; light_t *lights = 0; switch (mode) { case POINT: lights = point_lights; break; case SPOT: lights = spot_lights; break; case DIR: lights = directional_lights; break; + case ALL: lights = all_lights; break; } // Animate light @@ -131,6 +138,23 @@ int main(int argc, char** argv) { lights[0].dir = vec3(1,-1,-1); } + if (mode == ALL) { + lights[0].pos = vec3(0, 5.5, 1); + lights[0].pos.x += sinf(window_time()*2)*4.5f; + lights[0].pos.y += cosf(window_time()*2)*1.0; + lights[0].pos.z += cosf(window_time()*2)*6.0; + + lights[1].pos = vec3(0, 7.5, 1); + lights[1].pos.x += sinf(window_time()*4)*4.5f; + lights[1].pos.y += cosf(window_time()*4)*1.0; + lights[1].pos.z += cosf(window_time()*4)*6.0; + + lights[2].pos = cam.position; + lights[2].dir = cam.lookdir; + + lights[3].dir = vec3(1,-1,-1); + } + // Render shadowmap shadowmap_begin(&sm); {