-
Notifications
You must be signed in to change notification settings - Fork 0
/
material.h
54 lines (49 loc) · 1.45 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
#pragma once
#include <string>
#include "glm/glm.hpp"
#include "shader.h"
using namespace std;
struct PBRMaterial{
PBRMaterial(const glm::vec4 &base_color_factor,
float metallic_factor,
float roughness_facotr,
const string &base_color_texture,
const string &normal_texture,
const string &metallic_roughness_texture,
int alphaMode,float alphaCutOff,bool doubleSided
)
: baseColorFactor(base_color_factor),
metallicFactor(metallic_factor),
roughnessFactor(roughness_facotr),
baseColorTexture(base_color_texture),
normalTexture(normal_texture),
metallicRoughnessTexture(metallic_roughness_texture) ,
alphaMode(alphaMode),alphaCutOff(alphaCutOff),doubleSided(doubleSided)
{
if(!base_color_texture.empty()){
bcMode+= 1<<1;
}
if(baseColorFactor!=glm::vec4(0)){
bcMode+=1<<2;
}
if(!metallic_roughness_texture.empty()){
metallicMode+= 1<<1;roughnessMode+= 1<<1;
}
if(roughnessFactor!=0){
roughnessMode+=1<<2;
}
if(metallicFactor!=0){
metallicMode+=1<<2;
}
}
glm::vec4 baseColorFactor;
float metallicFactor=0;
float roughnessFactor=0;
string baseColorTexture;
string normalTexture;
string metallicRoughnessTexture;
int bcMode=0,metallicMode=0,roughnessMode=0;
bool doubleSided = false;
float alphaCutOff = 0.5;
int alphaMode = 0;
};