Merge branch 'master' of git.cg.cs.tu-bs.de:CG1_WS2223/group_12
This commit is contained in:
commit
373ebda28d
1 changed files with 15 additions and 12 deletions
|
@ -1,3 +1,4 @@
|
|||
#include <array>
|
||||
#include "light/light.h"
|
||||
#include "scene/scene.h"
|
||||
#include "shader/brdfshader.h"
|
||||
|
@ -21,20 +22,22 @@ Color BrdfShader::shade(Scene const &scene, Ray const &ray) const {
|
|||
return Vector3d{
|
||||
((axis_y.y * axis_z.z - axis_y.z * axis_z.y) * vec.x +
|
||||
(axis_y.z * axis_z.x - axis_y.x * axis_z.z) * vec.y +
|
||||
(axis_y.x * axis_z.y - axis_y.y * axis_z.x) * vec.z) / det,
|
||||
(axis_y.x * axis_z.y - axis_z.x * axis_y.y) * vec.z) / det,
|
||||
((axis_x.z * axis_z.y - axis_x.y * axis_z.z) * vec.x +
|
||||
(axis_x.x * axis_z.z - axis_x.x * axis_y.z) * vec.y +
|
||||
(axis_x.y * axis_z.x - axis_x.x * axis_y.x) * vec.z) / det,
|
||||
(axis_x.x * axis_z.z - axis_x.z * axis_z.x) * vec.y +
|
||||
(axis_z.x * axis_x.y - axis_x.x * axis_z.y) * vec.z) / det,
|
||||
((axis_x.y * axis_y.z - axis_x.z * axis_y.y) * vec.x +
|
||||
(axis_x.z * axis_y.x - axis_x.x * axis_y.z) * vec.y +
|
||||
(axis_x.x * axis_y.y - axis_x.y * axis_y.x) * vec.z) / det
|
||||
(axis_y.x * axis_x.z - axis_x.x * axis_y.z) * vec.y +
|
||||
(axis_x.x * axis_y.y - axis_y.x * axis_x.y) * vec.z) / det
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
for (auto &light: scene.lights()) {
|
||||
|
||||
auto illum = light->illuminate(scene, ray);
|
||||
if (dotProduct(ray.normal, illum.direction) <= EPSILON) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto axis = orthoNormalized(ray.normal, ray.direction, illum.direction);
|
||||
auto axis_y = std::get<0>(axis);
|
||||
|
@ -42,16 +45,16 @@ Color BrdfShader::shade(Scene const &scene, Ray const &ray) const {
|
|||
auto axis_z = std::get<2>(axis);
|
||||
|
||||
auto N = normalized(rebase(axis_x, axis_y, axis_z, ray.normal));
|
||||
auto D = normalized(rebase(axis_x, axis_y, axis_z, ray.direction));
|
||||
auto L = normalized(rebase(axis_x, axis_y, axis_z, illum.direction));
|
||||
auto D = normalized(rebase(axis_x, axis_y, axis_z, -ray.direction));
|
||||
auto L = normalized(rebase(axis_x, axis_y, axis_z, -illum.direction));
|
||||
D = axis_y * D.y + axis_z * D.z;
|
||||
L = axis_y * L.y + axis_z * L.z;
|
||||
|
||||
illuminationColor += brdf->lookupBrdfValues(std::acos(dotProduct(illum.direction, ray.normal)),
|
||||
0,
|
||||
std::acos(dotProduct(ray.direction, ray.normal)),
|
||||
illuminationColor += brdf->lookupBrdfValues(std::acos(dotProduct(ray.normal, -ray.direction)),
|
||||
0.0f,
|
||||
std::acos(dotProduct(illum.direction, ray.normal)),
|
||||
std::acos(dotProduct(D, L)));
|
||||
}
|
||||
// IMPLEMENT ME
|
||||
return illuminationColor;
|
||||
return illuminationColor * scale;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue