-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaterial.h
61 lines (44 loc) · 1.68 KB
/
material.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
// A Material is the material which defines the coefficients for
// interaction with light.
#ifndef _MATERIAL__H
#define _MATERIAL__H
#include "shapes.h"
#include "light.h"
class Material {
public:
Material();
// Calculates the colour at this point using the material's specific lighting model
// point, normal: the point on the surface of the shape, and normal at that point
virtual VEC3 calculateShading(const Shape *shape, VEC3 point, VEC3 normal, const Light &light, VEC3 eyeDir) const = 0;
};
// Uses Phong to look like a plastic
class Plastic: public Material {
public:
// coefficient affecting the size of the specular highlight
float cPhong;
Plastic(float cPhong);
// Uses Cook-Torrance, from Professor Kim's BDRFs code (see material.cpp)
VEC3 calculateShading(const Shape *shape, VEC3 point, VEC3 normal, const Light &light, VEC3 eyeDir) const;
};
// Uses Cook-Torrance to look like a metal
class Metal: public Material {
public:
// gaussian coefficient: size of the specular highlight
float cGaussian;
// reflection coefficient
float cReflection;
Metal(float cGaussian, float cReflection);
// Uses Cook-Torrance, from Professor Kim's BDRFs code (see material.cpp)
VEC3 calculateShading(const Shape *shape, VEC3 point, VEC3 normal, const Light &light, VEC3 eyeDir) const;
};
class RayTracer;
// Nicer plastic using Glossy Reflections
class GlossyPlastic: public Plastic {
public:
float cPhong;
RayTracer *&rayTracer; // Used to calculate the colour of other rays we need to create
GlossyPlastic(float cPhong, RayTracer *&rayTracer);
// Uses Glossy Reflections
VEC3 calculateShading(const Shape *shape, VEC3 point, VEC3 normal, const Light &light, VEC3 eyeDir) const;
};
#endif