diff --git a/core/Integrator.cpp b/core/Integrator.cpp index d183b0db..e4559773 100644 --- a/core/Integrator.cpp +++ b/core/Integrator.cpp @@ -198,7 +198,7 @@ Spectrum VolumetricPathTracing::SolvingIntegrator(Ray& ray, IntersectionInfo& in return radiance; } -void VolumetricPathTracing::RenderImage(const PostProcessing& post, Spectrum* image) { +void VolumetricPathTracing::RenderImage(const PostProcessing& post, RGBSpectrum* image) { omp_set_num_threads(32); #pragma omp parallel for for (int j = 0; j < height; j++) { diff --git a/core/Integrator.h b/core/Integrator.h index 5a51b71c..5cf2672f 100644 --- a/core/Integrator.h +++ b/core/Integrator.h @@ -27,7 +27,7 @@ class Integrator { virtual Spectrum SolvingIntegrator(Ray& ray, IntersectionInfo& info) = 0; - virtual void RenderImage(const PostProcessing& post, Spectrum* image) = 0; + virtual void RenderImage(const PostProcessing& post, RGBSpectrum* image) = 0; protected: IntegratorType m_type; @@ -44,7 +44,7 @@ class VolumetricPathTracing : public Integrator { virtual Spectrum SolvingIntegrator(Ray& ray, IntersectionInfo& info) override; - virtual void RenderImage(const PostProcessing& post, Spectrum* image) override; + virtual void RenderImage(const PostProcessing& post, RGBSpectrum* image) override; private: int maxBounce; diff --git a/core/Renderer.cpp b/core/Renderer.cpp index e16a10ce..81b481e2 100644 --- a/core/Renderer.cpp +++ b/core/Renderer.cpp @@ -76,7 +76,7 @@ Renderer::~Renderer() { } void Renderer::Run() { - Spectrum* nowTexture = new Spectrum[width * height]; + RGBSpectrum* nowTexture = new RGBSpectrum[width * height]; nowFrame = GetTextureRGB32F(width, height); while (!glfwWindowShouldClose(window)) { diff --git a/core/Spectrum.h b/core/Spectrum.h index 192993c5..29a583f8 100644 --- a/core/Spectrum.h +++ b/core/Spectrum.h @@ -563,6 +563,12 @@ inline CoefficientSpectrum Pow( return ret; } +inline float Luminance(const SampledSpectrum& color) { + RGBSpectrum rgb_color = color.ToRGBSpectrum(); + + return 0.299f * rgb_color[0] + 0.587f * rgb_color[1] + 0.114f * rgb_color[2]; +} + inline float Luminance(const RGBSpectrum& color) { return 0.299f * color[0] + 0.587f * color[1] + 0.114f * color[2]; } diff --git a/core/Utils.h b/core/Utils.h index 2c3619fb..a0ac582f 100644 --- a/core/Utils.h +++ b/core/Utils.h @@ -34,7 +34,7 @@ template class CoefficientSpectrum; class RGBSpectrum;// Now only use rgb class SampledSpectrum; -typedef RGBSpectrum Spectrum; +typedef SampledSpectrum Spectrum; class ToneMapper; class Reinhard; diff --git a/main.cpp b/main.cpp index d0ddc70d..306a9d14 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,8 @@ #include "Renderer.h" int main() { + SampledSpectrum::Init(); + int Width = 800; int Height = 800; @@ -13,7 +15,7 @@ int main() { float sigma_s2[3] = { 0.5f, 0.75f, 0.25f }; float scale2 = 1.0f; auto medium2 = std::make_shared(std::make_shared(), Spectrum::FromRGB(sigma_s2), Spectrum::FromRGB(sigma_a2), scale2); - + //medium2 = NULL; medium = NULL; //std::shared_ptr medium = NULL; //Transform tran = Transform::Rotate(0.0f, 45.0f, 0.0f);