diff --git a/shader/depthshader.cpp b/shader/depthshader.cpp new file mode 100644 index 0000000..59ea643 --- /dev/null +++ b/shader/depthshader.cpp @@ -0,0 +1,12 @@ +#include "depthshader.h" + +Color DepthShader::shade(const Scene &scene, const Ray &ray) const +{ + float brightness = exp(-ray.length * 0.1f); + return brightness * nearColor + (1 - brightness) * farColor; +} + +DepthShader::DepthShader(const Color &nearColor, const Color &farColor) : nearColor(nearColor), farColor(farColor) +{ + +} diff --git a/shader/depthshader.h b/shader/depthshader.h new file mode 100644 index 0000000..fdc33a1 --- /dev/null +++ b/shader/depthshader.h @@ -0,0 +1,21 @@ +#ifndef CG1_TRACER_DEPTHSHADER_H +#define CG1_TRACER_DEPTHSHADER_H + + +#include "shader/shader.h" + +class DepthShader : public Shader { + +public: + DepthShader(Color const &nearColor = Color(1, 1, 1), Color const &farColor = Color(0, 0, 0)); + + // Shader functions + Color shade(Scene const &scene, Ray const &ray) const override; + +private: + Color nearColor; + Color farColor; +}; + + +#endif //CG1_TRACER_DEPTHSHADER_H