-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaterial.h
More file actions
64 lines (54 loc) · 2.12 KB
/
Material.h
File metadata and controls
64 lines (54 loc) · 2.12 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
#ifndef MATERIAL_H_
#define MATERIAL_H_
#include <initializer_list>
#include <stdexcept>
#include "stdio.h"
#include <glm.hpp>
#include "InstanceAttribute.h"
//TODO Define material as a module offering an instance attribute
#include "Modules/Light.h" // non-module classes should not depend on modules
/*
* This is material.
* Material interacts with light.
* The outcome is the color that is rendered.
* Material has 4 properties:
* a) Absorption (Which colors are how much absorped?)
* b) Reflection (Which colors are how much reflected?)
* c) Transmission (How much light passes through the material?)
* d) Shininess (How sleek is the material?)
* You can assign materials to models.
* Materials are independent from geometry.
* Geometry are vertex positions and normals.
* The factory creates geometry.
*/
class Material : public InstanceAttribute {
struct Array {
// Number and order of these members must not be changed!
// The reason is that they are loaded "as are" into a GPU buffer.
// Default values are a white material (zero absorption, full reflection)
float absorption_rgb_[3] = {0.0f, 0.0f, 0.0f};
float reflection_rgb_[3] = {1.0f, 1.0f, 1.0f};
float transmission_strength_ = 0.0f;
float shininess_ = 0.0f;
} properties;
glm::vec3 get_RGB(float wavelength, float width, float strength);
public:
// Wavelength in [380,750]: Color, that is most absorped/reflected.
// Width in [0,1]: Absorped/reflected width of the color spectrum in percent.
// Strength in [0,1]: Absorped/reflected intensity in percent.
Material(
float absorption_wavelength, float absorption_width, float absorption_strength,
float reflection_wavelength, float reflection_width, float reflection_strength,
float transmission_strength, float shininess
);
Material(float r, float g, float b);
Material();
~Material();
// SETTER
void absorb(float absorption_wavelength, float absorption_width, float absorption_strength);
void reflect(float reflection_wavelength, float reflection_width, float reflection_strength);
void reflectRGB(float r, float g, float b);
void transmit(float transmission_strength);
void shine(float shininess);
};
#endif