From dcf51ba20e8019d8d65cb5fdd45cdc2858f1afbb Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 15 Oct 2024 10:23:14 -0700 Subject: [PATCH] more --- tools/rainbowgen/src/RainbowGenerator.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/rainbowgen/src/RainbowGenerator.cpp b/tools/rainbowgen/src/RainbowGenerator.cpp index 2a739d2259..a0fea3034f 100644 --- a/tools/rainbowgen/src/RainbowGenerator.cpp +++ b/tools/rainbowgen/src/RainbowGenerator.cpp @@ -56,11 +56,11 @@ void RainbowGenerator::build(JobSystem& js) { std::vector rainbow(angleCount, float3{}); // The sun appears as about half a degree in the sky - std::default_random_engine rng{ std::random_device{}() }; - std::uniform_real_distribution dist{ -f::DEG_TO_RAD * 0.25f, f::DEG_TO_RAD * 0.25f }; + std::default_random_engine const rng{ std::random_device{}() }; + std::uniform_real_distribution const dist{ -f::DEG_TO_RAD * 0.25f, f::DEG_TO_RAD * 0.25f }; size_t count = 16384; - float const s = f::PI * float(angleCount) / ((maxDeviation - minDeviation) * count); + float const s = 2.0f * float(angleCount) / ((maxDeviation - minDeviation) * count * CIE_XYZ_COUNT); for (size_t i = 0; i < count; i++) { float const impact = (float(i) / count) * 2.0f - 1.0f; @@ -83,7 +83,7 @@ void RainbowGenerator::build(JobSystem& js) { ((phi - minDeviation) / (maxDeviation - minDeviation)) * angleCount); if (index < angleCount) { float const T = (1 - F) * std::pow(1 - F, internalBounces) * F; - rainbow[index] += CIE_XYZ[j] * (T * s / 118.518f); + rainbow[index] += (T * s) * (CIE_XYZ[j] / 118.518f); } } } @@ -101,12 +101,16 @@ void RainbowGenerator::build(JobSystem& js) { float3 c; if (i == 3) { c = rainbow[index]; + auto d = c; + d = linear_to_sRGB(XYZ_to_sRGB(d)); + if (y == 0) std::cout << d.r << ", " << d.g << ", " << d.b << std::endl; +// if (y == 0) std::cout << d.r << std::endl; } else { c = float3{ i == 0, i == 1, i == 2 } * rainbow[index][i]; } c = XYZ_to_sRGB(c); - c = linear_to_sRGB(c);// * sun*0.5 + sky*0.5); + c = linear_to_sRGB(c) * 56;// * sun*0.5 + sky*0.5); uint3 const rgb = uint3(saturate(c) * 255); tga_set_pixel(image, index, y+i*16, { .b = (uint8_t)rgb.v[2],