28 lines
1 KiB
C++
28 lines
1 KiB
C++
#include "light/light.h"
|
|
#include "scene/scene.h"
|
|
#include "shader/materialshader.h"
|
|
#include <cmath>
|
|
|
|
Vector3d tangentToWorldSpace(const Vector3d &surfaceNormal, const Vector3d &surfaceTangent, const Vector3d &surfaceBitangent, const Vector3d &textureNormal) {
|
|
return textureNormal.x * surfaceTangent + textureNormal.y * surfaceBitangent + textureNormal.z * surfaceNormal;
|
|
}
|
|
|
|
MaterialShader::MaterialShader() : opacity(1.0f), normalCoefficient(1.0f), diffuseCoefficient(0.5f), reflectance(0.0f), specularCoefficient(0.5f), shininessExponent(8) {}
|
|
|
|
Color MaterialShader::shade(Scene const &scene, Ray const &ray) const {
|
|
Color fragmentColor;
|
|
|
|
// IMPLEMENT ME
|
|
|
|
// (Normal Map) Calculate the new normal vector
|
|
|
|
// (Diffuse-/Specular Map) Accumulate the light over all light sources
|
|
|
|
// (Reflection Map) Calculate the reflectance, create a reflection ray
|
|
|
|
// (Alpha Map) Calculate the opacity, create a background ray
|
|
|
|
return fragmentColor;
|
|
}
|
|
|
|
bool MaterialShader::isTransparent() const { return this->opacity < 1.0f || this->alphaMap; }
|