-
Notifications
You must be signed in to change notification settings - Fork 0
/
GlossyBSDF.h
35 lines (33 loc) · 1.04 KB
/
GlossyBSDF.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
#pragma once
#include "bsdf.h"
class GlossyBSDF : public BSDF
{
protected:
float coeff;
vec3f color;
public:
void setColor(const vec3f& color) { this->color = color; }
void setCoeff(const float& coeff) { this->coeff = coeff; }
float getCoeff() const { return coeff; }
vec3f getColor() const { return color; }
virtual vec3f evaluate(const LocalFrame& localFrame, const vec3f& inRay, const vec3f& outRay) const
{
if(localFrame.n.dot(inRay)<=0 && localFrame.n.dot(outRay)>=0)
{
vec3f reflDir = -localFrame.n.dot(inRay)*localFrame.n*2 + inRay;
if(reflDir.dot(outRay)>0)
return color * powf(reflDir.dot(outRay), coeff);
}
return vec3f(0,0,0);
};
virtual vec3f evaluate(const LocalFrame& localFrame, const vec3f& inRay, const vec3f& outRay, const vec3f& color, const float& coeff) const
{
if(localFrame.n.dot(inRay)<=0 && localFrame.n.dot(outRay)>=0)
{
vec3f reflDir = -localFrame.n.dot(inRay)*localFrame.n*2 + inRay;
if(reflDir.dot(outRay)>0)
return color * powf(reflDir.dot(outRay), coeff);
}
return vec3f(0,0,0);
};
};