-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbsdf.cpp
More file actions
27 lines (23 loc) · 730 Bytes
/
bsdf.cpp
File metadata and controls
27 lines (23 loc) · 730 Bytes
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
#include "bsdf.h"
BSDF::BSDF(std::string diffuseTexname, std::string alphaTexname, Vector3f diffuse, float alpha) {
this->diffuse = diffuse;
if (diffuseTexname != "") {
this->diffuseTexture = Texture(diffuseTexname);
}
this->alpha = alpha;
if (alphaTexname != "") {
this->alphaTexture = Texture(alphaTexname);
}
}
Vector3f BSDF::eval(Interaction *si, Vector3f wo) {
Vector3f diffuseColor = diffuse;
if (this->hasDiffuseTexture())
diffuseColor = this->diffuseTexture.nearestNeighbourFetch(si->uv);
return diffuseColor / M_PI;
}
bool BSDF::hasDiffuseTexture() {
return diffuseTexture.data != 0;
}
bool BSDF::hasAlphaTexture() {
return alphaTexture.data != 0;
}