Skip to content
Snippets Groups Projects
Commit 70b9cd3f authored by Yoel's avatar Yoel
Browse files

Refactor materials, reflective material still not done

parent 46637d06
No related branches found
No related tags found
No related merge requests found
#include "BackgroundMaterial.h"
#include <cassert>
#include "texture/Constant.h"
namespace material {
......@@ -44,4 +46,10 @@ float BackgroundMaterial::calculateLightMultiplier(const util::Vec3& d_in,
// Background should not be able to receive any light
return 0;
}
float BackgroundMaterial::brdf_pdf(const util::Vec3& d_out,
const util::Vec3& n) const {
// Background can not scatter so this is fine and will never be used
assert(false);
return 0;
}
} // namespace material
\ No newline at end of file
......@@ -21,6 +21,8 @@ class BackgroundMaterial : public Material {
float calculateLightMultiplier(const util::Vec3& d_in,
const util::Vec3& d_out,
const util::Vec3& n) const override;
float brdf_pdf(const util::Vec3& d_out, const util::Vec3& n) const override;
std::optional<float> emission_pdf(float u, float v) const override;
private:
......
......@@ -60,4 +60,11 @@ float DiffuseMaterial::calculateLightMultiplier(const util::Vec3& d_in,
const util::Vec3& n) const {
return M_1_PI;
}
float DiffuseMaterial::brdf_pdf(const util::Vec3& d_out,
const util::Vec3& n) const {
auto dot = util::dot(n, d_out.normalize());
dot = std::max<float>(dot, 0);
return dot * M_1_PI;
}
} // namespace material
\ No newline at end of file
......@@ -24,6 +24,7 @@ class DiffuseMaterial : public Material {
float calculateLightMultiplier(const util::Vec3& d_in,
const util::Vec3& d_out,
const util::Vec3& n) const override;
float brdf_pdf(const util::Vec3& d_out, const util::Vec3& n) const override;
std::optional<float> emission_pdf(float u, float v) const override;
private:
......
......@@ -58,4 +58,10 @@ float ReflectiveMaterial::calculateLightMultiplier(const util::Vec3& d_in,
return std::cos(std::min<float>(theta * 3, M_PI / 2));
}
float ReflectiveMaterial::brdf_pdf(const util::Vec3& d_out,
const util::Vec3& n) const {
// This is gonna be a problem, because this material can scatter
return 0;
}
} // namespace material
\ No newline at end of file
......@@ -22,6 +22,7 @@ class ReflectiveMaterial : public Material {
float calculateLightMultiplier(const util::Vec3& d_in,
const util::Vec3& d_out,
const util::Vec3& n) const override;
float brdf_pdf(const util::Vec3& d_out, const util::Vec3& n) const override;
private:
std::shared_ptr<util::Sampler> albedo_texture;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment