-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteraction.hpp
More file actions
64 lines (50 loc) · 2.16 KB
/
Interaction.hpp
File metadata and controls
64 lines (50 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>
#include <glm/gtx/intersect.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <memory>
class Material;
class Medium;
class PhaseFunction;
class Light;
struct GeometricInteraction{
glm::vec3 p = { 0,0,0 };
glm::vec3 n = { 0,0,0 };//geometric normal
std::shared_ptr<Medium> medium = nullptr;
bool isSurfaceInteraction() const{
return n != glm::vec3(0, 0, 0);
}
bool isMediumInteraction() const{
return !isSurfaceInteraction();
}
std::shared_ptr<Medium> getMedium(const glm::vec3& dir) const{
if(glm::dot(dir, n) < 0)return medium;//going into surface
return nullptr;
}
GeometricInteraction() = default;
GeometricInteraction(const glm::vec3& point, const glm::vec3& geometric_normal, const std::shared_ptr<Medium>& interactionMedium = nullptr) : p { point }, n { geometric_normal }, medium(interactionMedium){
}
};
struct SurfaceInteraction : public GeometricInteraction{
SurfaceInteraction(const glm::vec3& point, const glm::vec3& geometric_normal, const glm::vec2& uvCoord, const std::shared_ptr<Medium>& interactionMedium = nullptr) : GeometricInteraction { point,geometric_normal,interactionMedium }, uv { uvCoord }{
}
SurfaceInteraction() = default;
SurfaceInteraction(const GeometricInteraction& interaction) : GeometricInteraction { interaction }{
}
glm::vec2 uv = { 0,0 };
float t = 0;//we dont need t if we have point? t = glm::length(ray)
glm::vec3 ns = { 0,0,0 };
std::shared_ptr<Material> mat = nullptr;
glm::vec3 tangent = { 0,0,0 };
std::shared_ptr<Light> AreaLight = nullptr;
};
struct MediumInteraction : public GeometricInteraction{
MediumInteraction(const glm::vec3& point, const glm::vec3& geometric_normal, const std::shared_ptr<Medium>& interactionMedium, const std::shared_ptr<PhaseFunction>& phaseFunc) : GeometricInteraction { point,geometric_normal,interactionMedium }, phaseFunction { phaseFunc }{
}
MediumInteraction() = default;
bool isValid() const{
return phaseFunction != nullptr;
}
std::shared_ptr<PhaseFunction> phaseFunction = nullptr;
};