cloudy-raytracer/shader/shader.h

35 lines
877 B
C++

#ifndef SHADER_H
#define SHADER_H
#include "common/color.h"
#include "common/ray.h"
// Forward declarations
class Scene;
class Shader
{
public:
// Constructor / Desctructor
Shader() = default;
virtual ~Shader() = default;
// Get
virtual bool isTransparent() const
{ return false; }
/**
* Especially used for lighting calculations.
* @brief Returns the light let through the shader in opposite direction of the given ray.
* @param ray Origin and direction of the desired path.
* @return 0 if the shader is opaque, 1 if the shader is transparent, for each color channel.
*/
virtual Color transparency(Scene const &scene, Ray const &ray) const
{ return isTransparent() ? Color(1, 1, 1) : Color(0, 0, 0); }
// Shader functions
virtual Color shade(Scene const &scene, Ray const &ray) const = 0;
};
#endif