Added fun depth shader

This commit is contained in:
Maximilian Giller 2023-01-23 04:09:48 +01:00
parent 351bfa2984
commit a374c31938
2 changed files with 33 additions and 0 deletions

12
shader/depthshader.cpp Normal file
View file

@ -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)
{
}

21
shader/depthshader.h Normal file
View file

@ -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