diff --git a/light/ltface.cc b/light/ltface.cc index 81d57347..fbed728e 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -1312,6 +1312,11 @@ static void LightFace_Sky(const sun_t *sun, lightsurf_t *lightsurf, lightmapdict return; } + // check lighting channels (currently sunlight is always on CHANNEL_MASK_DEFAULT) + if (!(lightsurf->modelinfo->object_channel_mask.value() & CHANNEL_MASK_DEFAULT)) { + return; + } + /* Check each point... */ raystream_intersection_t &rs = lightsurf->intersection_stream; rs.clearPushedRays(); diff --git a/testmaps/q2_light_group.map b/testmaps/q2_light_group.map index ed5101c7..ac2f6cb8 100644 --- a/testmaps/q2_light_group.map +++ b/testmaps/q2_light_group.map @@ -7,6 +7,8 @@ "_bounce" "0" "_minlight" "0.5" "_minlightMottle" "0" +"_sunlight_mangle" "90 -5 0" +"_sunlight" "300" // brush 0 { ( 480 1088 928 ) ( 480 1089 928 ) ( 480 1088 929 ) e1u1/twall2_1 0 32 0 1 1 @@ -32,7 +34,7 @@ ( 704 1072 928 ) ( 705 1072 928 ) ( 704 1073 928 ) e1u1/twall2_1 0 -16 0 1 1 ( 944 1456 1248 ) ( 944 1457 1248 ) ( 945 1456 1248 ) e1u1/twall2_1 0 -16 0 1 1 ( 944 1088 944 ) ( 945 1088 944 ) ( 944 1088 945 ) e1u1/twall2_1 0 32 0 1 1 -( 1056 1456 944 ) ( 1056 1456 945 ) ( 1056 1457 944 ) e1u1/twall2_1 16 32 0 1 1 +( 784 1456 944 ) ( 784 1456 945 ) ( 784 1457 944 ) e1u1/twall2_1 16 32 0 1 1 } // brush 3 { @@ -70,6 +72,15 @@ ( 736 1200 960 ) ( 737 1200 960 ) ( 736 1200 961 ) e1u1/twall2_1 0 32 0 1 1 ( 720 1200 960 ) ( 720 1200 961 ) ( 720 1201 960 ) e1u1/twall2_1 32 32 0 1 1 } +// brush 7 +{ +( 784 1456 944 ) ( 784 1457 944 ) ( 784 1456 945 ) e1u1/sky1 16 32 0 1 1 0 4 0 +( 704 1072 928 ) ( 704 1072 929 ) ( 705 1072 928 ) e1u1/sky1 0 32 0 1 1 0 4 0 +( 704 1072 928 ) ( 705 1072 928 ) ( 704 1073 928 ) e1u1/sky1 0 -16 0 1 1 0 4 0 +( 944 1456 1248 ) ( 944 1457 1248 ) ( 945 1456 1248 ) e1u1/sky1 0 -16 0 1 1 0 4 0 +( 944 1088 944 ) ( 945 1088 944 ) ( 944 1088 945 ) e1u1/sky1 0 32 0 1 1 0 4 0 +( 1056 1456 944 ) ( 1056 1456 945 ) ( 1056 1457 944 ) e1u1/sky1 16 32 0 1 1 0 4 0 +} } // entity 1 { @@ -84,7 +95,6 @@ "light" "300" "_light_channel_mask" "2" "_shadow_channel_mask" "2" -"wait" ".5" } // entity 3 { @@ -118,3 +128,17 @@ ( 704 1312 960 ) ( 704 1312 961 ) ( 704 1313 960 ) e1u1/twall2_1 -32 0 0 1 1 } } +// entity 4 +{ +"classname" "func_wall" +"_object_channel_mask" "4" +// brush 0 +{ +( 880 1248 944 ) ( 880 1249 944 ) ( 880 1248 945 ) e1u1/twall2_1 0 0 0 1 1 +( 880 1248 944 ) ( 880 1248 945 ) ( 881 1248 944 ) e1u1/twall2_1 -96 0 0 1 1 +( 880 1248 960 ) ( 881 1248 960 ) ( 880 1249 960 ) e1u1/twall2_1 -96 0 0 1 1 +( 928 1280 1040 ) ( 928 1281 1040 ) ( 929 1280 1040 ) e1u1/twall2_1 -96 0 0 1 1 +( 928 1264 960 ) ( 929 1264 960 ) ( 928 1264 961 ) e1u1/twall2_1 -96 0 0 1 1 +( 928 1280 960 ) ( 928 1280 961 ) ( 928 1281 960 ) e1u1/twall2_1 0 0 0 1 1 +} +} diff --git a/tests/test_ltface.cc b/tests/test_ltface.cc index 152c7f8b..8a9801b6 100644 --- a/tests/test_ltface.cc +++ b/tests/test_ltface.cc @@ -296,7 +296,7 @@ TEST_CASE("negative lights work") { TEST_CASE("light channel mask (_object_channel_mask, _light_channel_mask, _shadow_channel_mask)") { auto [bsp, bspx] = LoadTestmap("q2_light_group.map", {}); - REQUIRE(2 == bsp.dmodels.size()); + REQUIRE(3 == bsp.dmodels.size()); { INFO("world doesn't receive light from the light ent with _light_channel_mask 2"); @@ -341,4 +341,15 @@ TEST_CASE("light channel mask (_object_channel_mask, _light_channel_mask, _shado CHECK(sample[0] > 100); }); } + + { + INFO("sunlight doesn't cast on _object_channel_mask 2 bmodel"); + + auto *face = BSP_FindFaceAtPoint(&bsp, &bsp.dmodels[2], {904, 1248, 1016}); + REQUIRE(face); + + CheckFaceLuxels(bsp, *face, [](qvec3b sample) { + CHECK(sample[0] == 0); + }); + } }