-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgray.h
85 lines (68 loc) · 1.44 KB
/
gray.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef GRAY_H
#define GRAY_H
#include "gmath.h"
#include "gcolor.h"
using namespace GMath;
class GModel;
class GMaterial;
class GBSDF;
class GLight;
class GScene;
class GGameObject;
namespace GMath
{
template <typename T> struct GAABB;
}
struct GRay
{
public:
GRay(): origin(0,0,0),dir(0,0,0),time(0) {};
GRay(vec3 origin, vec3 dir, double time=0);
vec3 GetPos(float t) const;
vec3 origin;
vec3 dir;
double time;
};
struct GRayDifferential
{
public:
GRayDifferential(){};
GRayDifferential(vec3 originX, vec3 dirX, vec3 originY, vec3 dirY);
GRay xRay;
GRay yRay;
};
enum BxDFType;
class GSurfaceInteraction
{
public:
vec3 p;
vec3 normal;
vec3 tangent;
vec3 shadingNormal;
vec3 wo;
vec3 wi;
vec2 uv;
double t;
double time = 0;
bool isFrontFace;
GMaterial* material = nullptr;
GModel* model = nullptr;
GLight* light = nullptr;
BxDFType bxdfTypes;
BxDFType sampledBxDFType;
void SetFaceNormal(const GRay& r, const vec3& outNormal)
{
isFrontFace = dot(r.dir, outNormal) < 0;
normal = isFrontFace ? outNormal : -outNormal;
}
GFColor Le(const GScene& scene, const vec3& w) const;
};
class GHittable
{
public:
virtual ~GHittable() = default;
virtual bool intersect(const GRay& ray, GMath::interval ray_t, GSurfaceInteraction& isect) = 0;
virtual GMath::GAABB<double> bBox() = 0;
GGameObject* owner;
};
#endif // GRAY_H