From 00f25bcce58789ad0f8082406f233de461d7ccf2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 9 Jan 2024 20:18:17 +0000 Subject: Add lights resource set and test scene --- test/test-assetFactory.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test') diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp index c8183df..e7ba19c 100644 --- a/test/test-assetFactory.cpp +++ b/test/test-assetFactory.cpp @@ -9,6 +9,8 @@ #include "assetFactory/object.h" #include "assetFactory/texturePacker.h" #include "game/scenary/foliage.h" +#include "game/scenary/illuminator.h" +#include "game/scenary/light.h" #include "game/scenary/plant.h" #include "game/vehicles/railVehicle.h" #include "game/vehicles/railVehicleClass.h" @@ -125,6 +127,29 @@ BOOST_AUTO_TEST_CASE(foliage, *boost::unit_test::timeout(5)) render(6000); } +BOOST_AUTO_TEST_CASE(lights, *boost::unit_test::timeout(5)) +{ + auto mf = AssetFactory::loadXML(RESDIR "/lights.xml"); + BOOST_REQUIRE(mf); + auto rlight = mf->assets.at("r-light"); + BOOST_REQUIRE(rlight); + auto rlight_f = std::dynamic_pointer_cast(rlight); + BOOST_REQUIRE(rlight_f); + + auto light1 = std::make_shared(rlight_f, Location {{0, 0, 0}, {0, 0, 0}}); + auto light2 = std::make_shared(rlight_f, Location {{-4000, 0, 0}, {0, -1, 0}}); + auto light3 = std::make_shared(rlight_f, Location {{-4000, -4000, 0}, {0, -3, 0}}); + auto light4 = std::make_shared(rlight_f, Location {{3000, 4600, 0}, {0, 1, 0}}); + objects.objects.push_back(rlight_f); + + // yes I'm hacking some floor to light up as though its a bush + auto floorf = std::dynamic_pointer_cast(mf->assets.at("floor")); + auto floor = std::make_shared(floorf, Location {}); + objects.objects.push_back(floorf); + + render(6000); +} + BOOST_AUTO_TEST_SUITE_END(); BOOST_AUTO_TEST_CASE(loadall) -- cgit v1.2.3 From 8740d30b01f6c12e2fcea0450df73736cd17dc87 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 10 Jan 2024 01:10:44 +0000 Subject: Add spot light definition, loader, and rendering Rendering is untested, data is passed to whatever GL program is currently active. --- test/test-assetFactory.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp index e7ba19c..91a5321 100644 --- a/test/test-assetFactory.cpp +++ b/test/test-assetFactory.cpp @@ -49,6 +49,7 @@ public: lights(const SceneShader & shader) const override { shader.pointLight.add({-3, 1, 5}, {1, 1, 1}, .1F); + objects.apply(&Renderable::lights, shader); } void -- cgit v1.2.3 From b8401062e1d3f5e6554ab7fd9b983ea63cfb05c5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 10 Jan 2024 19:04:30 +0000 Subject: Initial commit with working light instancing --- test/test-assetFactory.cpp | 6 +++--- test/test-render.cpp | 29 ----------------------------- 2 files changed, 3 insertions(+), 32 deletions(-) (limited to 'test') diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp index 91a5321..bc93729 100644 --- a/test/test-assetFactory.cpp +++ b/test/test-assetFactory.cpp @@ -138,9 +138,9 @@ BOOST_AUTO_TEST_CASE(lights, *boost::unit_test::timeout(5)) BOOST_REQUIRE(rlight_f); auto light1 = std::make_shared(rlight_f, Location {{0, 0, 0}, {0, 0, 0}}); - auto light2 = std::make_shared(rlight_f, Location {{-4000, 0, 0}, {0, -1, 0}}); - auto light3 = std::make_shared(rlight_f, Location {{-4000, -4000, 0}, {0, -3, 0}}); - auto light4 = std::make_shared(rlight_f, Location {{3000, 4600, 0}, {0, 1, 0}}); + auto light2 = std::make_shared(rlight_f, Location {{-4000, 0, 0}, {0, 2, 0}}); + auto light3 = std::make_shared(rlight_f, Location {{-4000, -4000, 0}, {0, 1, 0}}); + auto light4 = std::make_shared(rlight_f, Location {{3000, 4600, 0}, {0, 3, 0}}); objects.objects.push_back(rlight_f); // yes I'm hacking some floor to light up as though its a bush diff --git a/test/test-render.cpp b/test/test-render.cpp index 66b4d46..47d146c 100644 --- a/test/test-render.cpp +++ b/test/test-render.cpp @@ -188,33 +188,4 @@ BOOST_AUTO_TEST_CASE(pointlight) Texture::save(outImage, "/tmp/pointlight.tga"); } -BOOST_AUTO_TEST_CASE(spotlight) -{ - SceneRenderer ss {size, output}; - ss.camera.setView({-10000, -10000, 60000}, glm::normalize(glm::vec3 {1, 1, -0.5F})); - - class PointLightScene : public TestScene { - public: - void - environment(const SceneShader &, const SceneRenderer & r) const override - { - r.setAmbientLight({0.2F, 0.2F, 0.2F}); - r.setDirectionalLight({0.2F, 0.2F, 0.2F}, west + down, *this); - } - - void - lights(const SceneShader & shader) const override - { - shader.spotLight.add({50000, 50000, 15000}, down, {1.0, 1.0, 1.0}, 0.01F, 1); - shader.spotLight.add({51000, 59500, 1000}, north, {1.0, 1.0, 1.0}, 0.001F, .5); - shader.spotLight.add({53000, 59500, 1000}, north, {1.0, 1.0, 1.0}, 0.001F, .5); - shader.spotLight.add({60000, 50000, 3000}, north + east, {1.0, 1.0, 1.0}, 0.0001F, .7F); - } - }; - - const PointLightScene scene; - ss.render(scene); - Texture::save(outImage, "/tmp/spotlight.tga"); -} - BOOST_AUTO_TEST_SUITE_END(); -- cgit v1.2.3 From 51eb25ea0f1373ca0442b02049406af38eae3b33 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 12 Jan 2024 19:35:58 +0000 Subject: Add model support for point lights Still invokes non-instanced point light shader --- test/test-assetFactory.cpp | 1 - test/test-render.cpp | 30 ------------------------------ 2 files changed, 31 deletions(-) (limited to 'test') diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp index bc93729..9e278c4 100644 --- a/test/test-assetFactory.cpp +++ b/test/test-assetFactory.cpp @@ -48,7 +48,6 @@ public: void lights(const SceneShader & shader) const override { - shader.pointLight.add({-3, 1, 5}, {1, 1, 1}, .1F); objects.apply(&Renderable::lights, shader); } diff --git a/test/test-render.cpp b/test/test-render.cpp index 47d146c..41731dd 100644 --- a/test/test-render.cpp +++ b/test/test-render.cpp @@ -158,34 +158,4 @@ BOOST_AUTO_TEST_CASE(terrain) Texture::save(outImage, "/tmp/terrain.tga"); } -BOOST_AUTO_TEST_CASE(pointlight) -{ - SceneRenderer ss {size, output}; - ss.camera.setView({-10000, -10000, 60000}, glm::normalize(glm::vec3 {1, 1, -0.5F})); - - class PointLightScene : public TestScene { - public: - void - environment(const SceneShader &, const SceneRenderer & r) const override - { - r.setAmbientLight({0.2F, 0.2F, 0.2F}); - r.setDirectionalLight({0.2F, 0.2F, 0.2F}, west + down, *this); - } - - void - lights(const SceneShader & shader) const override - { - for (int x = 50000; x < 100000; x += 20000) { - for (int y = 50000; y < 2000000; y += 20000) { - shader.pointLight.add({x, y, 4000}, {1.0, 1.0, 1.0}, 0.1F); - } - } - } - }; - - const PointLightScene scene; - ss.render(scene); - Texture::save(outImage, "/tmp/pointlight.tga"); -} - BOOST_AUTO_TEST_SUITE_END(); -- cgit v1.2.3 From 48a5de8943bda62ba5caefe3b64c66a0d9024dff Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 13 Jan 2024 10:05:58 +0000 Subject: Add old street lamp model --- test/test-assetFactory.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp index 9e278c4..8341fbf 100644 --- a/test/test-assetFactory.cpp +++ b/test/test-assetFactory.cpp @@ -133,14 +133,19 @@ BOOST_AUTO_TEST_CASE(lights, *boost::unit_test::timeout(5)) BOOST_REQUIRE(mf); auto rlight = mf->assets.at("r-light"); BOOST_REQUIRE(rlight); + auto oldlamp = mf->assets.at("old-lamp"); + BOOST_REQUIRE(oldlamp); auto rlight_f = std::dynamic_pointer_cast(rlight); BOOST_REQUIRE(rlight_f); + auto oldlamp_f = std::dynamic_pointer_cast(oldlamp); + BOOST_REQUIRE(oldlamp_f); - auto light1 = std::make_shared(rlight_f, Location {{0, 0, 0}, {0, 0, 0}}); + auto light1 = std::make_shared(oldlamp_f, Location {{0, 0, 0}, {0, 0, 0}}); auto light2 = std::make_shared(rlight_f, Location {{-4000, 0, 0}, {0, 2, 0}}); auto light3 = std::make_shared(rlight_f, Location {{-4000, -4000, 0}, {0, 1, 0}}); - auto light4 = std::make_shared(rlight_f, Location {{3000, 4600, 0}, {0, 3, 0}}); + auto light4 = std::make_shared(oldlamp_f, Location {{3000, 4600, 0}, {0, 2, 0}}); objects.objects.push_back(rlight_f); + objects.objects.push_back(oldlamp_f); // yes I'm hacking some floor to light up as though its a bush auto floorf = std::dynamic_pointer_cast(mf->assets.at("floor")); -- cgit v1.2.3