Add semantic pixel asserts for lighting scenes

This commit is contained in:
2026-04-05 16:46:47 +08:00
parent cda4a57756
commit 54a699aa26
11 changed files with 282 additions and 96 deletions

View File

@@ -3,6 +3,7 @@
#include <gtest/gtest.h>
#include "../RenderingIntegrationImageAssert.h"
#include "../RenderingIntegrationMain.h"
#include <XCEngine/Components/CameraComponent.h>
@@ -45,6 +46,18 @@ constexpr const char* kVulkanScreenshot = "multi_light_scene_vulkan.ppm";
constexpr uint32_t kFrameWidth = 1280;
constexpr uint32_t kFrameHeight = 720;
void ExpectMultiLightKeyPixels(const RenderingIntegrationTestUtils::PpmImage& image) {
using namespace RenderingIntegrationTestUtils;
ExpectPixelLuminanceAtMost(image, 320, 320, 24, "background remains dark");
ExpectPixelLuminanceAtLeast(image, 625, 285, 540, "left point-light highlight");
ExpectPixelChannelDominates(image, 625, 285, 0, 80, "left point-light highlight stays warm");
ExpectPixelLuminanceAtLeast(image, 640, 315, 470, "center cube receives main light");
ExpectPixelChannelDominates(image, 640, 315, 0, 40, "center cube keeps warm directional tint");
ExpectPixelLuminanceAtLeast(image, 758, 311, 300, "right cube receives cool fill");
ExpectPixelChannelDominates(image, 758, 311, 2, 20, "right cube keeps cool fill tint");
}
void AppendQuadFace(
std::vector<StaticMeshVertex>& vertices,
std::vector<uint32_t>& indices,
@@ -459,6 +472,8 @@ TEST_P(MultiLightSceneTest, RenderMultiLightScene) {
if (frameCount >= targetFrameCount) {
commandQueue->WaitForIdle();
ASSERT_TRUE(TakeScreenshot(screenshotFilename));
const auto screenshotImage = RenderingIntegrationTestUtils::LoadPpmImage(screenshotFilename);
ExpectMultiLightKeyPixels(screenshotImage);
ASSERT_TRUE(CompareWithGoldenTemplate(screenshotFilename, "GT.ppm", static_cast<float>(comparisonThreshold)));
break;
}