Skip to content
Snippets Groups Projects
Commit 4bae0e20 authored by Yoel's avatar Yoel
Browse files

Changed scatter and implemented new calcLightMulti-func

parent 0c102ae9
No related branches found
No related tags found
No related merge requests found
#include "DiffuseMaterial.h"
#include <cassert>
#include "../tools/Random.h"
#include "texture/Constant.h"
......@@ -28,9 +30,20 @@ util::Vec3 DiffuseMaterial::emission(float texel_x, float texel_y) const {
}
util::Vec3 DiffuseMaterial::scattered_d(const util::Vec3& d,
const util::Vec3& n) const {
return n + util::rand_vec3_in_circle(1);
util::Vec3 rand = util::rand_vec3_in_circle(1);
util::Vec3 result = n + rand;
/*if (util::dot(n, result) <= 0) {
std::cout << n << " " << rand << std::endl;
assert(false);
}*/
return result;
}
bool DiffuseMaterial::scatter() const {
bool DiffuseMaterial::scatter(const util::Vec3& d, const util::Vec3& n) const {
return true;
}
float DiffuseMaterial::calculateLightMultiplier(const util::Vec3& d_in,
const util::Vec3& d_out,
const util::Vec3& n) const {
return util::dot(n, d_in);
}
} // namespace material
\ No newline at end of file
......@@ -14,10 +14,14 @@ class DiffuseMaterial : public Material {
util::Vec3 emission(float texel_x, float texel_y) const override;
util::Vec3 scattered_d(const util::Vec3& d,
const util::Vec3& n) const override;
bool scatter() const override;
bool scatter(const util::Vec3& d, const util::Vec3& n) const override;
float calculateLightMultiplier(const util::Vec3& d_in,
const util::Vec3& d_out,
const util::Vec3& n) const override;
private:
std::shared_ptr<util::Sampler> emission_texture;
std::shared_ptr<util::Sampler> albedo_texture;
std::shared_ptr<util::Sampler> emission_texture;
};
} // namespace material
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