mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 17:43:12 +02:00
* feat: load exr map * feat: scale and flip the hdr map * feat: added camera * feat: add simple slow but working photonmapping * feat: added cpp version of photonmapping * chore: extracted vector class to separate file * chore: split classes into separate files * chore: removed constant parameters from main * feat: added statistics to main cpp * feat: added statistic for time of execution
27 lines
782 B
C++
27 lines
782 B
C++
#ifndef PLANE_H
|
|
|
|
class Plane {
|
|
public:
|
|
Vector3 point; // A point on the plane
|
|
Vector3 normal; // Normal to the plane
|
|
Vector3 color;
|
|
|
|
Plane(const Vector3& p, const Vector3& n, const Vector3& col)
|
|
: point(p), normal(n.normalize()), color(col) {}
|
|
|
|
bool intersect(const Vector3& ray_origin, const Vector3& ray_direction, double& t, Vector3& hit_point, Vector3& hit_normal) const {
|
|
double denom = normal.dot(ray_direction);
|
|
if (std::abs(denom) > 1e-6) {
|
|
t = (point - ray_origin).dot(normal) / denom;
|
|
if (t >= 1e-4) {
|
|
hit_point = ray_origin + ray_direction * t;
|
|
hit_normal = normal;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
|
|
#endif |