Skip to content
Snippets Groups Projects
BackgroundMaterial.cpp 1.6 KiB
Newer Older
Postea's avatar
Postea committed
#include "BackgroundMaterial.h"
Yoel's avatar
Yoel committed

#include "texture/Constant.h"
Postea's avatar
Postea committed

namespace material {
Yoel's avatar
Yoel committed
BackgroundMaterial::BackgroundMaterial(
    const std::shared_ptr<util::Sampler>& texture)
Yoel's avatar
Yoel committed
    : emission_profile({texture}) {
}
BackgroundMaterial::BackgroundMaterial(
    const std::shared_ptr<util::Sampler>& texture,
    const util::Image& distribution)
    : emission_profile({texture, distribution}) {
BackgroundMaterial::BackgroundMaterial(const util::Vec3& albedo)
Yoel's avatar
Yoel committed
    : emission_profile({std::make_shared<Constant>(albedo)}) {
util::Vec3 BackgroundMaterial::albedo(const std::pair<float, float>& uv) const {
Yoel's avatar
Yoel committed
	return util::Vec3(1, 1, 1);
util::Vec3 BackgroundMaterial::emission(
    const std::pair<float, float>& uv) const {
Yoel's avatar
Yoel committed
	return emission_profile.color(uv.first, uv.second);
}
std::pair<float, float> BackgroundMaterial::sampleEmissionProfile() const {
	return emission_profile.sample();
}

std::optional<float> BackgroundMaterial::emission_pdf(float u, float v) const {
	return emission_profile.pdf(u, v);
Yoel's avatar
Yoel committed
util::Vec3 BackgroundMaterial::scattered_d(const util::Vec3& d,
Yoel's avatar
Yoel committed
	return util::Vec3(0, 0, 0);
bool BackgroundMaterial::scatter(const util::Vec3& d,
                                 const util::Vec3& n) const {
Yoel's avatar
Yoel committed
	return false;

float BackgroundMaterial::calculateLightMultiplier(const util::Vec3& d_in,
                                                   const util::Vec3& d_out,
                                                   const util::Vec3& n) const {
	// Background should not be able to receive any light
	return 0;
}
Yoel's avatar
Yoel committed
}  // namespace material