Skip to content

Commit

Permalink
test sampled spectrum
Browse files Browse the repository at this point in the history
  • Loading branch information
GraphicsEnthusiast committed Jan 11, 2024
1 parent 55f7984 commit 7ee179b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/Integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
4 changes: 2 additions & 2 deletions core/Integrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 6 additions & 0 deletions core/Spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@ inline CoefficientSpectrum<nSpectrumSamples> 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];
}
Expand Down
2 changes: 1 addition & 1 deletion core/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ template <int nSpectrumSamples>
class CoefficientSpectrum;
class RGBSpectrum;// Now only use rgb
class SampledSpectrum;
typedef RGBSpectrum Spectrum;
typedef SampledSpectrum Spectrum;

class ToneMapper;
class Reinhard;
Expand Down
4 changes: 3 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "Renderer.h"

int main() {
SampledSpectrum::Init();

int Width = 800;
int Height = 800;

Expand All @@ -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<Homogeneous>(std::make_shared<Isotropic>(), Spectrum::FromRGB(sigma_s2), Spectrum::FromRGB(sigma_a2), scale2);

//medium2 = NULL;
medium = NULL;
//std::shared_ptr<Medium> medium = NULL;
//Transform tran = Transform::Rotate(0.0f, 45.0f, 0.0f);
Expand Down

0 comments on commit 7ee179b

Please sign in to comment.