Added fun depth shader
This commit is contained in:
parent
351bfa2984
commit
a374c31938
2 changed files with 33 additions and 0 deletions
12
shader/depthshader.cpp
Normal file
12
shader/depthshader.cpp
Normal 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
21
shader/depthshader.h
Normal 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
|
Loading…
Reference in a new issue